Spaces:
Runtime error
Runtime error
KUNAL SHAW
commited on
Commit
·
1879b51
1
Parent(s):
c4e05ba
Increase max_tokens to 1024 and improve prompts for detailed medical responses
Browse files
app.py
CHANGED
|
@@ -383,7 +383,16 @@ def generate_stream(prompt, model=None):
|
|
| 383 |
messages=[
|
| 384 |
{
|
| 385 |
"role": "system",
|
| 386 |
-
"content": "You are VitalSync AI,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
},
|
| 388 |
{
|
| 389 |
"role": "user",
|
|
@@ -392,7 +401,7 @@ def generate_stream(prompt, model=None):
|
|
| 392 |
],
|
| 393 |
stream=True,
|
| 394 |
temperature=0.7,
|
| 395 |
-
max_tokens=
|
| 396 |
)
|
| 397 |
return response
|
| 398 |
# Zephyr formatter
|
|
@@ -438,15 +447,27 @@ def full_prompt(
|
|
| 438 |
context=" ".join(context)
|
| 439 |
#print(context)
|
| 440 |
default_system_message = f"""
|
| 441 |
-
You
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
"""
|
| 451 |
system_message = os.environ.get("SYSTEM_MESSAGE", default_system_message)
|
| 452 |
formatted_prompt = format_prompt_zephyr(question, history, system_message=system_message)
|
|
|
|
| 383 |
messages=[
|
| 384 |
{
|
| 385 |
"role": "system",
|
| 386 |
+
"content": """You are VitalSync AI, an expert medical health assistant developed by Kunal Shaw. Your role is to provide detailed, accurate, and helpful health information.
|
| 387 |
+
|
| 388 |
+
Guidelines:
|
| 389 |
+
- Provide comprehensive and medically accurate responses
|
| 390 |
+
- Structure your answers clearly with relevant details
|
| 391 |
+
- Include possible causes, symptoms, and general recommendations when appropriate
|
| 392 |
+
- Always recommend consulting a healthcare professional for proper diagnosis and treatment
|
| 393 |
+
- Be empathetic and supportive in your tone
|
| 394 |
+
- If you're uncertain about something, acknowledge it honestly
|
| 395 |
+
- Never provide specific medication dosages or treatment plans - always defer to medical professionals"""
|
| 396 |
},
|
| 397 |
{
|
| 398 |
"role": "user",
|
|
|
|
| 401 |
],
|
| 402 |
stream=True,
|
| 403 |
temperature=0.7,
|
| 404 |
+
max_tokens=1024,
|
| 405 |
)
|
| 406 |
return response
|
| 407 |
# Zephyr formatter
|
|
|
|
| 447 |
context=" ".join(context)
|
| 448 |
#print(context)
|
| 449 |
default_system_message = f"""
|
| 450 |
+
You are VitalSync AI, an expert health assistant. Please follow these guidelines:
|
| 451 |
+
|
| 452 |
+
1. **Provide Detailed Responses**: Give comprehensive answers that address the user's health concerns thoroughly.
|
| 453 |
+
|
| 454 |
+
2. **Be Medically Accurate**: Base your responses on the provided medical context and established medical knowledge.
|
| 455 |
+
|
| 456 |
+
3. **Structure Your Answer**:
|
| 457 |
+
- Start with a direct answer to the question
|
| 458 |
+
- Explain relevant causes or factors
|
| 459 |
+
- Provide helpful recommendations or next steps
|
| 460 |
+
- Mention when professional medical consultation is advised
|
| 461 |
+
|
| 462 |
+
4. **Be Empathetic**: Show understanding and compassion for health concerns.
|
| 463 |
+
|
| 464 |
+
5. **Safety First**: Always recommend consulting a healthcare provider for proper diagnosis and treatment.
|
| 465 |
+
|
| 466 |
+
6. **Use the Context**: Reference the following medical context to provide accurate information:
|
| 467 |
+
|
| 468 |
+
Medical Context: {context}
|
| 469 |
+
|
| 470 |
+
Remember: You are here to help users understand their health concerns better, not to replace professional medical advice.
|
| 471 |
"""
|
| 472 |
system_message = os.environ.get("SYSTEM_MESSAGE", default_system_message)
|
| 473 |
formatted_prompt = format_prompt_zephyr(question, history, system_message=system_message)
|