File size: 2,788 Bytes
a1dea48 5992984 a1dea48 5992984 a1dea48 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import gradio as gr
# Define a dictionary of 20 dental terminologies and their definitions
dental_terms = {
"cavity": "A cavity is a hole in a tooth caused by decay.",
"gingivitis": "Gingivitis is the inflammation of the gums, often caused by plaque buildup.",
"implant": "A dental implant is a surgical component that interfaces with the jawbone to support a dental prosthesis.",
"orthodontics": "Orthodontics is a branch of dentistry that corrects teeth and jaw alignment issues.",
"plaque": "Plaque is a sticky, colorless film of bacteria that forms on teeth.",
"enamel": "Enamel is the hard, outer surface layer of your teeth that protects against decay.",
"braces": "Braces are orthodontic devices used to straighten teeth and correct bite issues.",
"root canal": "A root canal is a treatment to repair and save a badly damaged or infected tooth.",
"crown": "A crown is a dental cap placed over a tooth to restore its shape, size, and strength.",
"veneers": "Veneers are thin shells placed over the front of teeth to improve appearance.",
"halitosis": "Halitosis is chronic bad breath caused by bacteria or other factors.",
"periodontitis": "Periodontitis is a serious gum infection that damages gums and can destroy the jawbone.",
"denture": "Dentures are removable appliances that replace missing teeth and surrounding tissues.",
"bridge": "A dental bridge is a fixed prosthetic device that replaces missing teeth.",
"tartar": "Tartar is hardened plaque that forms on teeth and can only be removed by a dentist.",
"x-ray": "A dental x-ray is an imaging technique used to view the inside of teeth and surrounding tissues.",
"flossing": "Flossing is the process of cleaning between your teeth with dental floss.",
"sealant": "A sealant is a protective coating applied to teeth to prevent decay.",
"bitewing": "A bitewing is a type of dental x-ray that shows the upper and lower back teeth.",
"occlusion": "Occlusion refers to the alignment and contact between teeth when the jaws close."
}
def chatbot_response(message, history):
# Convert the message to lowercase for case-insensitive matching
message = message.lower()
# Check if the message matches a term in the dictionary
if message in dental_terms:
return dental_terms[message]
else:
return "I'm sorry, I am just a simple chatbot, and I don't understand that term. Please try another dental term."
# Set up the Gradio interface
demo = gr.ChatInterface(
chatbot_response,
type="messages",
title="Dental Terminology Chatbot",
description="Enter a dental term to get its definition. If the term is not recognized, the chatbot will let you know."
)
if __name__ == "__main__":
demo.launch()
|