rukeshpaudel commited on
Commit
b5411ad
Β·
unverified Β·
2 Parent(s): 9fa0506968b163

Merge pull request #2 from rukeshpaudel/chatbot

Browse files
app.py CHANGED
@@ -1,84 +1,104 @@
1
- import gradio as gr
2
- import os
3
  import time
4
-
5
- # Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video).
6
- # Plus shows support for streaming text.
7
-
8
-
9
- def print_like_dislike(x):
10
- print(x.index, x.value, x.liked)
11
-
12
-
13
- def add_text(history, text):
14
- history = history + [(text, None)]
15
- return history, gr.Textbox(value="", interactive=False)
16
-
17
-
18
- def add_file(history, file):
19
- history = history + [((file.name,), None)]
20
- return history
21
-
22
-
23
- def bot(history):
24
- response = "**That's cool!**"
25
- history[-1][1] = ""
26
- for character in response:
27
- history[-1][1] += character
28
- time.sleep(0.05)
29
- yield history
30
-
31
-
32
- with gr.Blocks() as demo:
33
- image_path = os.path.join(
34
- os.path.dirname(__file__),
35
- "utils",
36
- "images",
37
- "health_assistant_chatbot_icon.png",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  )
39
- chatbot = gr.Chatbot(
40
- [],
41
- elem_id="chatbot",
42
- bubble_full_width=False,
43
- avatar_images=(None, image_path),
 
 
44
  )
45
 
46
- with gr.Row():
47
- txt = gr.Textbox(
48
- show_label=False,
49
- )
50
 
51
- with gr.Tab("Chatbot"):
52
- chatbot = gr.Chatbot(
53
- [],
54
- elem_id="chatbot",
55
- bubble_full_width=False,
56
- avatar_images=(None, "utils\images\health_assitant_chatbot_icon.png"),
57
  )
58
 
 
 
 
 
 
 
 
 
 
59
  with gr.Row():
60
- txt = gr.Textbox(
61
- scale=4,
62
- show_label=False,
63
- placeholder="Enter text and press enter, or upload an image",
64
- container=False,
65
- )
66
- btn = gr.UploadButton("πŸ“", file_types=["image", "video", "audio"])
67
-
68
- txt_msg = txt.submit(
69
- add_text, [chatbot, txt], [chatbot, txt], queue=False
70
- ).then(bot, chatbot, chatbot, api_name="bot_response")
71
- txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
72
- file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(
73
- bot, chatbot, chatbot
 
 
 
 
 
74
  )
75
 
76
- chatbot.like(print_like_dislike, None, None)
77
-
78
- with gr.Tab("Medical Report storage"):
79
- with gr.Row("Upload your document here:"):
80
- pass
81
-
82
- demo.queue()
83
  if __name__ == "__main__":
84
- demo.launch()
 
 
 
1
  import time
2
+ import os
3
+ import gradio as gr
4
+ from utils.doc_contact import Doctor
5
+ from openai import OpenAI
6
+
7
+ client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
8
+
9
+ # Initialize the client
10
+ # Set your OpenAI API key
11
+
12
+ """file = client.files.create(
13
+ file=open("songs.txt", "rb"),
14
+ purpose='assistants'
15
+ )"""
16
+
17
+ # Step 1: Create an Assistant
18
+ # assistant = client.beta.assistants.create(
19
+ # name="MeroHealthAI",
20
+ # instructions="You are a highly qualified and skilled doctor \
21
+ # who can ask all the right questions to the patient \
22
+ # and create an engaging and interesting conversation \
23
+ # and make patients let out all the diseases they are \
24
+ # suffering from. Then you will create a medical report \
25
+ # based on the symptoms. If you are 100% sure, you can also\
26
+ # predict the disease else just report the symptoms in a formal \
27
+ # formatted diagnosis report. Make sure to include all the vital \
28
+ # informations by asking the patients. Ask their name, address and\
29
+ # other personal details information before beginning asking for symptoms. \
30
+ # Also ask their weight and height, calculate BMI index, ask if they have the details\
31
+ # of the test they've previously taken. If they have any previous medical reports, ask \
32
+ # for their sugar level, blood pressure and other necessary information that are done in a whole \
33
+ # body checkup. Ask one question at a time so that the user doesn't feel overwhelmed. After completing asking the \
34
+ # symptoms, automatically generate the symptoms in a medical report like format along with the patient's information.",
35
+ # model="gpt-3.5-turbo",
36
+ # # file_ids=[file.id],
37
+ # #tools=[{"type": "retrieval"}]
38
+ # )
39
+ # Step 2: Create a Thread
40
+ thread = client.beta.threads.create()
41
+
42
+
43
+ def create_thread():
44
+ thread = client.beta.threads.create()
45
+ return thread.id
46
+
47
+
48
+ def main(query, history):
49
+ # Step 3: Add a Message to a Thread
50
+ history = (history,)
51
+ message = client.beta.threads.messages.create(
52
+ thread_id=thread.id, role="user", content=query
53
  )
54
+
55
+ # Step 4: Run the Assistant
56
+ run = client.beta.threads.runs.create(
57
+ thread_id=thread.id,
58
+ assistant_id="asst_x34DeLtsxGXQBZCwN5aZhfBf",
59
+ instructions="User is a health patient, who is suffering from {disease}. You are supposed to create a medical report based on the symptoms. If you are 100% sure, you can also predict the disease else just report the symptoms in a formal formatted diagnosis report.\
60
+ Make sure to include all the vital informations by asking the patients. Ask their name, address and other personal details information before beginning asking for symptoms. Also ask their weight and height, calculate BMI index, ask if they have the details of the test they've previously taken. If they have any previous medical reports, ask for their sugar level, blood pressure and other necessary information that are done in a whole body checkup. Ask one question at a time so that the user doesn't feel overwhelmed. After completing asking the symptoms, automatically generate the symptoms in a medical report like format along with the patient's information.",
61
  )
62
 
63
+ while True:
64
+ # Wait for 5 seconds
65
+ time.sleep(0.5)
 
66
 
67
+ # Retrieve the run status
68
+ run_status = client.beta.threads.runs.retrieve(
69
+ thread_id=thread.id, run_id=run.id
 
 
 
70
  )
71
 
72
+
73
+ # If run is completed, get messages
74
+ if run_status.status == "completed":
75
+ messages = client.beta.threads.messages.list(thread_id=thread.id)
76
+ response = ""
77
+ # Create a Gradio Interface
78
+ with gr.Blocks() as iface:
79
+ with gr.Tab("MeroHealthAI Chatbot"):
80
+ gr.Markdown("MeroHealthAI is an AI assited chatbot that gathers symptoms from the user, documents it and sends it to the nearest most relevant doctor available. Our app also suppors medical report analysis")
81
  with gr.Row():
82
+ symptom_chatbot = gr.ChatInterface(
83
+ main
84
+ ) # , description="MeroHealthAI is an AI assited chatbot that gathers symptoms from the user, documents it and sends it to the nearest most relevant doctor available. Our app also suppors medical report analysis",\
85
+ # examples=["How can I find the right doctor for my ailment?",\
86
+ # "How do I contact a doctor without making an appointment?",\
87
+
88
+ # "I don't understant this medical report, can you describe it to me?", \
89
+ # "I have been having severe panic and anxiety attack, what could be the reason behind it?"]).queue()
90
+
91
+ symptom_chatbot
92
+ with gr.Tab("Contact Doctor "):
93
+ profession_key = gr.Textbox(label="Profession", interactive=True)
94
+ doc_info = gr.Textbox(label="Doctor Information") # Define textbox globally
95
+
96
+ gr.Button("Display_profession").click(
97
+ # Pass textbox element directly
98
+ Doctor.display_profession,
99
+ inputs=profession_key,
100
+ outputs=doc_info,
101
  )
102
 
 
 
 
 
 
 
 
103
  if __name__ == "__main__":
104
+ iface.launch()
jupytermeroHealthAI.ipynb ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 5,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "from openai import OpenAI \n",
10
+ "import os\n",
11
+ "\n",
12
+ "client = OpenAI(\n",
13
+ " api_key=os.environ['QUALZ_OPEN_API_KEY']\n",
14
+ ") \n",
15
+ "\n",
16
+ "assistant = client.beta.assistants.create(\n",
17
+ " name=\"meroHeatlhAI\",\n",
18
+ " instructions=\"You are a highly qualified and skilled doctor who can ask all the right questions to the patient and create an engaging and interesting conversation and make patients let out all the diseases they are suffering from. Then you will create a medical report based on the symptoms. If you are 100% sure, you can also predict the disease else just report the symptoms in a formal formatted diagnosis report. Make sure to include all the vital informations by asking the patients. Ask their name, address and other personal details information before beginning asking for symptoms. Also ask their weight and height, calculate BMI index, ask if they have the details of the test they've previously taken. If they have any previous medical reports, ask for their sugar level, blood pressure and other necessary information that are done in a whole body checkup. Ask one question at a time so that the user doesn't feel overwhelmed. After completing asking the symptoms, automatically generate the symptoms in a medical report like format along with the patient's information.\",\n",
19
+ " tools=[{\"type\": \"code_interpreter\"}],\n",
20
+ " model=\"gpt-3.5-turbo\"\n",
21
+ ")"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": 6,
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "thread = client.beta.threads.create()"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 7,
36
+ "metadata": {},
37
+ "outputs": [],
38
+ "source": [
39
+ "message = client.beta.threads.messages.create(\n",
40
+ " thread_id=thread.id,\n",
41
+ " role=\"user\",\n",
42
+ " content=\"I am having panic attack. Can you help me?\"\n",
43
+ ")"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": 8,
49
+ "metadata": {},
50
+ "outputs": [],
51
+ "source": [
52
+ "run = client.beta.threads.runs.create(\n",
53
+ " thread_id=thread.id,\n",
54
+ " assistant_id=assistant.id,\n",
55
+ " instructions=\"Please address the user as Jane Doe. The user has a premium account.\"\n",
56
+ ")"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": 9,
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": [
65
+ "run = client.beta.threads.runs.retrieve(\n",
66
+ " thread_id=thread.id,\n",
67
+ " run_id=run.id\n",
68
+ ")"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": 10,
74
+ "metadata": {},
75
+ "outputs": [],
76
+ "source": [
77
+ "messages = client.beta.threads.messages.list(\n",
78
+ " thread_id=thread.id\n",
79
+ ")"
80
+ ]
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": 11,
85
+ "metadata": {},
86
+ "outputs": [
87
+ {
88
+ "name": "stdout",
89
+ "output_type": "stream",
90
+ "text": [
91
+ "SyncCursorPage[ThreadMessage](data=[ThreadMessage(id='msg_VlngIDB8OA8W0yXPkV9LX90J', assistant_id='asst_5iXApo7o4K2tQNxV9ZVL3kca', content=[MessageContentText(text=Text(annotations=[], value=\"I'm really sorry to hear that you're experiencing a panic attack, but I'm unable to provide the help that you need. It's important to reach out to a mental health professional or a healthcare provider for assistance. They will be able to offer guidance and support during this difficult time.\"), type='text')], created_at=1707376241, file_ids=[], metadata={}, object='thread.message', role='assistant', run_id='run_wuW9vVaYIPRLWNM3V0alAErM', thread_id='thread_CBuF63Y1dOLSJMDBl7f8wfVi'), ThreadMessage(id='msg_eC0sVacO4speeWSzF8KeJdzt', assistant_id=None, content=[MessageContentText(text=Text(annotations=[], value='I am having panic attack. Can you help me?'), type='text')], created_at=1707376237, file_ids=[], metadata={}, object='thread.message', role='user', run_id=None, thread_id='thread_CBuF63Y1dOLSJMDBl7f8wfVi')], object='list', first_id='msg_VlngIDB8OA8W0yXPkV9LX90J', last_id='msg_eC0sVacO4speeWSzF8KeJdzt', has_more=False)\n"
92
+ ]
93
+ }
94
+ ],
95
+ "source": [
96
+ "print(messages)"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "code",
101
+ "execution_count": 13,
102
+ "metadata": {},
103
+ "outputs": [
104
+ {
105
+ "ename": "AttributeError",
106
+ "evalue": "'list' object has no attribute 'text'",
107
+ "output_type": "error",
108
+ "traceback": [
109
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
110
+ "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
111
+ "Cell \u001b[1;32mIn[13], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmessages\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtext\u001b[49m\u001b[38;5;241m.\u001b[39mvalue)\n",
112
+ "\u001b[1;31mAttributeError\u001b[0m: 'list' object has no attribute 'text'"
113
+ ]
114
+ }
115
+ ],
116
+ "source": [
117
+ "print(messages.data[0].content[0].text.value)"
118
+ ]
119
+ },
120
+ {
121
+ "cell_type": "code",
122
+ "execution_count": null,
123
+ "metadata": {},
124
+ "outputs": [],
125
+ "source": []
126
+ }
127
+ ],
128
+ "metadata": {
129
+ "kernelspec": {
130
+ "display_name": ".venv",
131
+ "language": "python",
132
+ "name": "python3"
133
+ },
134
+ "language_info": {
135
+ "codemirror_mode": {
136
+ "name": "ipython",
137
+ "version": 3
138
+ },
139
+ "file_extension": ".py",
140
+ "mimetype": "text/x-python",
141
+ "name": "python",
142
+ "nbconvert_exporter": "python",
143
+ "pygments_lexer": "ipython3",
144
+ "version": "3.11.4"
145
+ }
146
+ },
147
+ "nbformat": 4,
148
+ "nbformat_minor": 2
149
+ }
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
utils/chatbot.py CHANGED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
+ import os
3
+ import gradio as gr
4
+
5
+ client = OpenAI(
6
+ api_key=os.environ['QUALZ_OPEN_API_KEY']
7
+ )
8
+
9
+ assistant = client.beta.assistants.create(
10
+ name="meroHeatlhAI",
11
+ instructions="You are a highly qualified and skilled doctor who can ask all the right questions to the patient and create an engaging and interesting conversation and make patients let out all the diseases they are suffering from. Then you will create a medical report based on the symptoms. If you are 100% sure, you can also predict the disease else just report the symptoms in a formal formatted diagnosis report. Make sure to include all the vital informations by asking the patients. Ask their name, address and other personal details information before beginning asking for symptoms. Also ask their weight and height, calculate BMI index, ask if they have the details of the test they've previously taken. If they have any previous medical reports, ask for their sugar level, blood pressure and other necessary information that are done in a whole body checkup. Ask one question at a time so that the user doesn't feel overwhelmed. After completing asking the symptoms, automatically generate the symptoms in a medical report like format along with the patient's information.",
12
+ tools=[{"type": "code_interpreter"}],
13
+ model="gpt-3.5-turbo",
14
+ )
15
+
16
+ def chat_response(user_input,thread_id):
17
+ thread = client.beta.threads.create()
18
+ user_input= user_input
19
+ message = client.beta.threads.messages.create(
20
+ thread_id=thread.id,
21
+ role="user",
22
+ content=user_input
23
+ )
24
+
25
+ run = client.beta.threads.runs.create(
26
+ thread_id=thread.id,
27
+ assistant_id=assistant.id,
28
+ )
29
+
30
+ run = client.beta.threads.runs.retrieve(
31
+ thread_id=thread.id,
32
+ run_id=run.id
33
+ )
34
+
35
+ messages = client.beta.threads.messages.list(
36
+ thread_id=thread.id
37
+ )
38
+
39
+ chat_response_message = messages.data[0].content[0].text.value
40
+ return chat_response_message
41
+ # Create the Gradio interface
42
+ with gr.Blocks() as iface:
43
+ gr.ChatInterface(
44
+ fn=chat_response,
45
+ title="Chat with this bot!"
46
+ )
47
+
48
+ # Launch the interface
49
+ iface.launch()
utils/database_helper.py CHANGED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ import pymongo
4
+ from pymongo.errors import PyMongoError
5
+ import os
6
+ import dotenv
7
+ from pymongo.server_api import ServerApi
8
+
9
+ class DatabaseIO:
10
+ def __init__(self, db_name=None, collection_name=None):
11
+ dotenv.load_dotenv()
12
+
13
+ mongo_username = os.environ['MONGO_USERNAME']
14
+ mongo_password = os.environ['MONGO_PASSWORD']
15
+ client_url = os.environ['MONGO_CLIENT_URL_DEV']
16
+ uri = f"mongodb+srv://{mongo_username}:{mongo_password}@{client_url}/?retryWrites=true&w=majority"
17
+
18
+ if not db_name:
19
+ db_name = os.environ['MONGO_DATABASE_NAME']
20
+ if not collection_name:
21
+ collection_name = os.environ['MONGO_COLLECTION']
22
+
23
+ self.client = pymongo.MongoClient(uri, server_api=ServerApi('1'))
24
+ self.db = self.client[db_name]
25
+ self.collection = self.db[collection_name]
26
+
27
+ def insert_document(self, article, collection=None, unique_on='_id', upsert=False):
28
+
29
+ if not collection:
30
+ collection = self.collection
31
+
32
+ article['date_modified'] = datetime.now().utcnow()
33
+ existing_document = collection.find_one({unique_on: article[unique_on]})
34
+ if existing_document:
35
+ # there is something like with the reddit id already
36
+
37
+ if upsert:
38
+ collection.update_one({unique_on: article[unique_on]}, {"$set": article})
39
+ else:
40
+ article['date_created'] = datetime.now().utcnow()
41
+ collection.insert_one(article)
42
+
43
+ def __enter__(self):
44
+ return self
45
+
46
+ def __exit__(self, exc_type, exc_value, traceback):
47
+ try:
48
+ self.client.close()
49
+ except PyMongoError as e:
50
+ print(f"An error occurred while closing the database connection: {e}")
51
+ raise
52
+
53
+ def __del__(self):
54
+ try:
55
+ self.client.close()
56
+ except Exception as e:
57
+ print(e)
58
+
59
+ def read_documents(self, query=None, sort_by=None, sort_order=None):
60
+ if query is None:
61
+ query = {}
62
+ try:
63
+ if sort_by:
64
+ if not sort_order or sort_order not in [1, -1]:
65
+ sort_order= 1
66
+ for article in self.collection.find(query).sort(sort_by, sort_order):
67
+ yield article
68
+ else:
69
+ for article in self.collection.find(query):
70
+ yield article
71
+ except Exception as e:
72
+ print(e)
73
+
74
+ def count_documents(self, query=None):
75
+ if query is None:
76
+ query = {}
77
+ try:
78
+ return self.collection.count_documents(query)
79
+ except Exception as e:
80
+ print(e)
81
+
82
+ def update_documents(self, query, update, upsert=True):
83
+ try:
84
+ self.collection.update_one(query, update, upsert=upsert)
85
+ except Exception as e:
86
+ print(e)
87
+
88
+ def delete_document(self, query):
89
+ try:
90
+ self.collection.delete_one(query)
91
+ except Exception as e:
92
+ print(e)
utils/doc_contact.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ class Doctor():
4
+
5
+ doctor_professions = {
6
+ "neurologist": "Dr. Ram Hari",
7
+ "psychiatrist": "Dr. Sita",
8
+ "cardiologist": "Dr. Deals",
9
+ "dermatologist": "Dr. Hari",
10
+ }
11
+
12
+ def display_profession(profession_key):
13
+ # Handle invalid key (same as previous example)
14
+ if profession_key not in Doctor.doctor_professions:
15
+ return "Invalid profession. Please choose from available options."
16
+
17
+ doctor_data = Doctor.doctor_professions[profession_key]
18
+ # Build desired output format (adjust to your preference)
19
+ output = f"\n**Doctor details:**\n - Name: {doctor_data}\n - Profession: {profession_key}"
20
+
21
+ return output
utils/docsnearme.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import googlemaps
3
+ from geopy.geocoders import Nominatim
4
+ import os
5
+ # Initialize Google Maps API client
6
+ gmaps = googlemaps.Client(key="AIzaSyB0gKa0rMc_OqxK0KvtDRDbghy8IRssjlY")
7
+
8
+ # Function to find nearest doctors
9
+ def find_nearest_doctors(location):
10
+ # Convert address to coordinates
11
+ geolocator = Nominatim(user_agent="geoapiExercises")
12
+ loc = geolocator.geocode(location)
13
+ latitude = loc.latitude
14
+ longitude = loc.longitude
15
+
16
+ # Find nearby doctors (you might need to adjust the radius)
17
+ places = gmaps.places_nearby(location=(latitude, longitude), radius=1000, type='doctor')
18
+
19
+ # Extract doctors' locations
20
+ doctors_locations = [(place['name'], place['geometry']['location']['lat'], place['geometry']['location']['lng']) for place in places['results']]
21
+
22
+ return doctors_locations
23
+
24
+ # Create Gradio interface
25
+ def nearest_doctors(location):
26
+ doctors_locations = find_nearest_doctors(location)
27
+
28
+ # Generate HTML for Google Maps display
29
+ map_html = f"<iframe width='600' height='500' src='https://maps.google.com/maps?q={location}&output=embed'></iframe>"
30
+
31
+ # Add markers for doctors on the map
32
+ for doctor in doctors_locations:
33
+ map_html += f"<p>{doctor[0]}</p><iframe width='600' height='500' src='https://www.google.com/maps/embed/v1/place?q={doctor[1]},{doctor[2]}&key=YOUR_API_KEY'></iframe>"
34
+
35
+ return map_html
36
+
37
+ # Create Gradio interface
38
+ iface = gr.Interface(fn=nearest_doctors,
39
+ inputs="text",
40
+ outputs="html",
41
+ title="Find Nearest Doctors",
42
+ description="Enter your location to find nearest doctors.")
43
+ iface.launch(share=True)
utils/prompts.py DELETED
File without changes
utils/prompts.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Example prompts for cardiology:
2
+ * What are the possible causes of the patient's symptoms?
3
+ * Consider their medical history and risk factors.
4
+ * Are there any diagnostic tests you recommend?
5
+ * What treatment options could be appropriate?
6
+ * Remember, I cannot provide medical advice, only information.