Spaces:
Runtime error
Runtime error
zaeemzafar
commited on
Commit
•
7ffbf80
1
Parent(s):
0f50574
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,15 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
6 |
"""
|
7 |
client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def respond(
|
11 |
message,
|
@@ -15,6 +24,8 @@ def respond(
|
|
15 |
temperature,
|
16 |
top_p,
|
17 |
):
|
|
|
|
|
18 |
messages = [{"role": "system", "content": system_message}]
|
19 |
|
20 |
for val in history:
|
@@ -35,18 +46,16 @@ def respond(
|
|
35 |
top_p=top_p,
|
36 |
):
|
37 |
token = message.choices[0].delta.content
|
38 |
-
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
-
|
43 |
"""
|
44 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
45 |
"""
|
46 |
demo = gr.ChatInterface(
|
47 |
respond,
|
48 |
additional_inputs=[
|
49 |
-
gr.Textbox(value=
|
50 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
51 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
52 |
gr.Slider(
|
@@ -59,6 +68,5 @@ demo = gr.ChatInterface(
|
|
59 |
],
|
60 |
)
|
61 |
|
62 |
-
|
63 |
if __name__ == "__main__":
|
64 |
-
demo.launch()
|
|
|
6 |
"""
|
7 |
client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
|
8 |
|
9 |
+
# Specialized prompt for the system message
|
10 |
+
ophthalmology_prompt = (
|
11 |
+
"Act as an experienced ophthalmologist with extensive knowledge in clinical diagnosis, "
|
12 |
+
"surgical treatments, and current research trends. Explain your answers with detailed insights "
|
13 |
+
"and clear medical terminology, providing up-to-date information and guidance. When appropriate, "
|
14 |
+
"outline differential diagnoses, treatment options, or advanced procedural steps. Additionally, "
|
15 |
+
"summarize any relevant clinical studies or guidelines that support your responses, making sure to "
|
16 |
+
"keep explanations clear and tailored to both professionals and non-specialists."
|
17 |
+
)
|
18 |
|
19 |
def respond(
|
20 |
message,
|
|
|
24 |
temperature,
|
25 |
top_p,
|
26 |
):
|
27 |
+
# Set the system message to the ophthalmology prompt
|
28 |
+
system_message = ophthalmology_prompt if not system_message else system_message
|
29 |
messages = [{"role": "system", "content": system_message}]
|
30 |
|
31 |
for val in history:
|
|
|
46 |
top_p=top_p,
|
47 |
):
|
48 |
token = message.choices[0].delta.content
|
|
|
49 |
response += token
|
50 |
yield response
|
51 |
|
|
|
52 |
"""
|
53 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
54 |
"""
|
55 |
demo = gr.ChatInterface(
|
56 |
respond,
|
57 |
additional_inputs=[
|
58 |
+
gr.Textbox(value=ophthalmology_prompt, label="System message"),
|
59 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
60 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
61 |
gr.Slider(
|
|
|
68 |
],
|
69 |
)
|
70 |
|
|
|
71 |
if __name__ == "__main__":
|
72 |
+
demo.launch()
|