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