khalednabawi11 commited on
Commit
3d6970c
·
verified ·
1 Parent(s): 10ffa61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -95,40 +95,40 @@ class TimeoutCallback(BaseCallbackHandler):
95
  raise TimeoutError("LLM processing timeout")
96
 
97
  # Prompt template
98
- def generate_prompt(question: str) -> str:
99
- lang = detect(question)
100
- if lang == "ar":
101
- return f"""أجب على السؤال الطبي التالي بلغة عربية فصحى، بإجابة دقيقة ومفصلة. إذا لم تجد معلومات كافية في السياق، استخدم معرفتك الطبية السابقة.
102
- وتأكد من ان:
103
- - عدم تكرار أي نقطة أو عبارة أو كلمة
104
- - وضوح وسلاسة كل نقطة
105
- - تجنب الحشو والعبارات الزائدة
106
- السؤال: {question}
107
- الإجابة:"""
108
- else:
109
- return f"""Answer the following medical question in clear English with a detailed, non-redundant response. Do not repeat ideas or restate the question. If the context lacks information, rely on prior medical knowledge.
110
- Question: {question}
111
- Answer:"""
112
-
113
-
114
  # def generate_prompt(question: str) -> str:
115
  # lang = detect(question)
116
  # if lang == "ar":
117
- # return (
118
- # "أجب على السؤال الطبي التالي بلغة عربية فصحى، بإجابة دقيقة ومفصلة. إذا لم تجد معلومات كافية في السياق، استخدم معرفتك الطبية السابقة. \n"
119
- # "- عدم تكرار أي نقطة أو عبارة أو كلمة\n"
120
- # "- وضوح وسلاسة كل نقطة\n"
121
- # "- تجنب الحشو والعبارات الزائدة\n"
122
- # f"\nالسؤال: {question}\nالإجابة:"
123
- # )
124
  # else:
125
- # return (
126
- # "Answer the following medical question in clear English with a detailed, non-redundant response. "
127
- # "Do not repeat ideas, phrases, or restate the question in the answer. If the context lacks relevant "
128
- # "information, rely on your prior medical knowledge. If the answer involves multiple points, list them "
129
- # "in concise and distinct bullet points:\n"
130
- # f"Question: {question}\nAnswer:"
131
- # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  # Input schema
134
  # class ChatRequest(BaseModel):
 
95
  raise TimeoutError("LLM processing timeout")
96
 
97
  # Prompt template
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  # def generate_prompt(question: str) -> str:
99
  # lang = detect(question)
100
  # if lang == "ar":
101
+ # return f"""أجب على السؤال الطبي التالي بلغة عربية فصحى، بإجابة دقيقة ومفصلة. إذا لم تجد معلومات كافية في السياق، استخدم معرفتك الطبية السابقة.
102
+ # وتأكد من ان:
103
+ # - عدم تكرار أي نقطة أو عبارة أو كلمة
104
+ # - وضوح وسلاسة كل نقطة
105
+ # - تجنب الحشو والعبارات الزائدة
106
+ # السؤال: {question}
107
+ # الإجابة:"""
108
  # else:
109
+ # return f"""Answer the following medical question in clear English with a detailed, non-redundant response. Do not repeat ideas or restate the question. If the context lacks information, rely on prior medical knowledge.
110
+ # Question: {question}
111
+ # Answer:"""
112
+
113
+
114
+ def generate_prompt(question: str) -> str:
115
+ lang = detect(question)
116
+ if lang == "ar":
117
+ return (
118
+ "أجب على السؤال الطبي التالي بلغة عربية فصحى، بإجابة دقيقة ومفصلة. إذا لم تجد معلومات كافية في السياق، استخدم معرفتك الطبية السابقة. \n"
119
+ "- عدم تكرار أي نقطة أو عبارة أو كلمة\n"
120
+ "- وضوح وسلاسة كل نقطة\n"
121
+ "- تجنب الحشو والعبارات الزائدة\n"
122
+ f"\nالسؤال: {question}\nالإجابة:"
123
+ )
124
+ else:
125
+ return (
126
+ "Answer the following medical question in clear English with a detailed, non-redundant response. "
127
+ "Do not repeat ideas, phrases, or restate the question in the answer. If the context lacks relevant "
128
+ "information, rely on your prior medical knowledge. If the answer involves multiple points, list them "
129
+ "in concise and distinct bullet points:\n"
130
+ f"Question: {question}\nAnswer:"
131
+ )
132
 
133
  # Input schema
134
  # class ChatRequest(BaseModel):