Spaces:
Sleeping
Sleeping
Tafazzul-Nadeeem
commited on
Commit
·
2ef477b
1
Parent(s):
feef0b6
Precription feature done
Browse files- app.py +12 -8
- prompts.py +1 -1
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
| 4 |
import base64
|
| 5 |
import time
|
| 6 |
import copy
|
|
|
|
| 7 |
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
# Load environment variables from .env file
|
|
@@ -40,7 +41,7 @@ with gr.Blocks() as demo:
|
|
| 40 |
|
| 41 |
def agent4_get_prescription_text(messages):
|
| 42 |
"""
|
| 43 |
-
|
| 44 |
"""
|
| 45 |
prescription_text = get_prescription_text(messages)
|
| 46 |
return prescription_text
|
|
@@ -141,14 +142,17 @@ with gr.Blocks() as demo:
|
|
| 141 |
response = agent3_llm_agent(clean_messages)
|
| 142 |
#######################################################################
|
| 143 |
|
| 144 |
-
history.append({"role": "assistant", "content": response})
|
| 145 |
-
return history
|
| 146 |
|
| 147 |
-
|
| 148 |
-
#
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
|
| 154 |
##########################################################################
|
|
|
|
| 4 |
import base64
|
| 5 |
import time
|
| 6 |
import copy
|
| 7 |
+
import re
|
| 8 |
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
# Load environment variables from .env file
|
|
|
|
| 41 |
|
| 42 |
def agent4_get_prescription_text(messages):
|
| 43 |
"""
|
| 44 |
+
Openai agent to get prescription text.
|
| 45 |
"""
|
| 46 |
prescription_text = get_prescription_text(messages)
|
| 47 |
return prescription_text
|
|
|
|
| 142 |
response = agent3_llm_agent(clean_messages)
|
| 143 |
#######################################################################
|
| 144 |
|
| 145 |
+
# history.append({"role": "assistant", "content": response})
|
| 146 |
+
# return history
|
| 147 |
|
| 148 |
+
history.append({"role": "assistant", "content": ""})
|
| 149 |
+
# Split by sentence boundaries (naive but works for most cases)
|
| 150 |
+
chunks = re.split(r'(?<=[.!?]) +', response)
|
| 151 |
+
|
| 152 |
+
for chunk in chunks:
|
| 153 |
+
history[-1]["content"] += chunk + " "
|
| 154 |
+
time.sleep(0.3)
|
| 155 |
+
yield history
|
| 156 |
|
| 157 |
|
| 158 |
##########################################################################
|
prompts.py
CHANGED
|
@@ -11,7 +11,7 @@ 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 in an agentic AI framework.
|
| 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 |
If the user has uploaded an image and an agent has replied in the message that No prescription
|
|
|
|
| 11 |
**Can I help you with anything?**
|
| 12 |
"""
|
| 13 |
openai_opening_system_message = """"You are a helpful assistant of a diagnostic
|
| 14 |
+
services business in an agentic AI framework. Provide the response in markdown format.
|
| 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 |
If the user has uploaded an image and an agent has replied in the message that No prescription
|