Spaces:
Sleeping
Sleeping
Tafazzul-Nadeeem commited on
Commit ·
4052a3c
1
Parent(s): 7ff33ff
Precription feature done
Browse files- app.py +8 -40
- prompts.py +31 -0
app.py
CHANGED
|
@@ -11,51 +11,12 @@ load_dotenv()
|
|
| 11 |
|
| 12 |
from agents import rag_decision
|
| 13 |
from agents import get_top_k
|
|
|
|
| 14 |
|
| 15 |
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 16 |
|
| 17 |
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
-
bot_welcome_message = """Hello! I'm Rijulata, your AI assistant.
|
| 20 |
-
I am programmed to assist you with information about our diagnostic services and
|
| 21 |
-
current running offers and discounts.
|
| 22 |
-
You can ask questions or share part of your prescription (without names or any
|
| 23 |
-
personal informations) to get details of tests advised by your doctor.
|
| 24 |
-
Disclaimer: I am not a medical professional, and my responses are based on the
|
| 25 |
-
information available to me.
|
| 26 |
-
Always consult a qualified healthcare provider for medical advice or concerns.
|
| 27 |
-
Also, the final service rates and offers will be available at the time of booking,
|
| 28 |
-
and may vary from the information provided here.
|
| 29 |
-
**Can I help you with anything?**
|
| 30 |
-
"""
|
| 31 |
-
openai_opening_system_message = """"You are a helpful assistant of a diagnostic
|
| 32 |
-
services business.
|
| 33 |
-
The system uses RAG to retrieve relevant information from a knowledge base.
|
| 34 |
-
You can also answer questions based on the information provided by the user.
|
| 35 |
-
Do not provide any medical advice or diagnosis.
|
| 36 |
-
"""
|
| 37 |
-
prescription_upload_message = """The user has uploaded an image.
|
| 38 |
-
Check if the image contains a prescription, if not, ask the user to upload a valid prescription
|
| 39 |
-
image or provide details about the tests they are interested in. Do not provide
|
| 40 |
-
information about any other image if the image is not a prescription. Just reply that "I am
|
| 41 |
-
only trained to assist with prescription images and the uploaded image does not seem
|
| 42 |
-
to be a prescription." Do not answer any question if the uploaded
|
| 43 |
-
image is not a prescription.
|
| 44 |
-
If the image contains a prescription, extract the tests advised by the doctor
|
| 45 |
-
and provide details about those tests like rates and offers. For the tests
|
| 46 |
-
which are not in your knowledge base, say, "Not in our lab".
|
| 47 |
-
At last, also ask the user if You missed any test.
|
| 48 |
-
Do not provide any medical advice or diagnosis.
|
| 49 |
-
"""
|
| 50 |
-
chatbot = gr.Chatbot(type="messages")
|
| 51 |
-
chat_input = gr.MultimodalTextbox(
|
| 52 |
-
interactive=True,
|
| 53 |
-
file_count="multiple",
|
| 54 |
-
placeholder="Enter message or upload file...",
|
| 55 |
-
show_label=False
|
| 56 |
-
)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
################################ AGENTS ###################################
|
| 60 |
# Agent1 - RAG Decision Agent (whether RAG is needed for the user's query)
|
| 61 |
def agent1_rag_decision(query):
|
|
@@ -171,6 +132,13 @@ Do not provide any medical advice or diagnosis.
|
|
| 171 |
|
| 172 |
|
| 173 |
##########################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
clear = gr.Button("Refresh Chat")
|
| 175 |
clear.click(
|
| 176 |
clear_and_load,
|
|
|
|
| 11 |
|
| 12 |
from agents import rag_decision
|
| 13 |
from agents import get_top_k
|
| 14 |
+
from prompts import bot_welcome_message, openai_opening_system_message, prescription_upload_message
|
| 15 |
|
| 16 |
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 17 |
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
################################ AGENTS ###################################
|
| 21 |
# Agent1 - RAG Decision Agent (whether RAG is needed for the user's query)
|
| 22 |
def agent1_rag_decision(query):
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
##########################################################################
|
| 135 |
+
chatbot = gr.Chatbot(type="messages")
|
| 136 |
+
chat_input = gr.MultimodalTextbox(
|
| 137 |
+
interactive=True,
|
| 138 |
+
file_count="multiple",
|
| 139 |
+
placeholder="Enter message or upload file...",
|
| 140 |
+
show_label=False
|
| 141 |
+
)
|
| 142 |
clear = gr.Button("Refresh Chat")
|
| 143 |
clear.click(
|
| 144 |
clear_and_load,
|
prompts.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bot_welcome_message = """Hello! I'm Rijulata, your AI assistant.
|
| 2 |
+
I am programmed to assist you with information about our diagnostic services and
|
| 3 |
+
current running offers and discounts.
|
| 4 |
+
You can ask questions or share part of your prescription (without names or any
|
| 5 |
+
personal informations) to get details of tests advised by your doctor.
|
| 6 |
+
Disclaimer: I am not a medical professional, and my responses are based on the
|
| 7 |
+
information available to me.
|
| 8 |
+
Always consult a qualified healthcare provider for medical advice or concerns.
|
| 9 |
+
Also, the final service rates and offers will be available at the time of booking,
|
| 10 |
+
and may vary from the information provided here.
|
| 11 |
+
**Can I help you with anything?**
|
| 12 |
+
"""
|
| 13 |
+
openai_opening_system_message = """"You are a helpful assistant of a diagnostic
|
| 14 |
+
services business.
|
| 15 |
+
The system uses RAG to retrieve relevant information from a knowledge base.
|
| 16 |
+
You can also answer questions based on the information provided by the user.
|
| 17 |
+
Do not provide any medical advice or diagnosis.
|
| 18 |
+
"""
|
| 19 |
+
prescription_upload_message = """The user has uploaded an image.
|
| 20 |
+
Check if the image contains a prescription, if not, ask the user to upload a valid prescription
|
| 21 |
+
image or provide details about the tests they are interested in. Do not provide
|
| 22 |
+
information about any other image if the image is not a prescription. Just reply that "I am
|
| 23 |
+
only trained to assist with prescription images and the uploaded image does not seem
|
| 24 |
+
to be a prescription." Do not answer any question if the uploaded
|
| 25 |
+
image is not a prescription.
|
| 26 |
+
If the image contains a prescription, extract the tests advised by the doctor
|
| 27 |
+
and provide details about those tests like rates and offers. For the tests
|
| 28 |
+
which are not in your knowledge base, say, "Not in our lab".
|
| 29 |
+
At last, also ask the user if You missed any test.
|
| 30 |
+
Do not provide any medical advice or diagnosis.
|
| 31 |
+
"""
|