Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,19 +6,28 @@ from openai import OpenAI
|
|
6 |
client = OpenAI(base_url="http://home.mayhew.cloud:1234/v1", api_key="lm-studio")
|
7 |
|
8 |
# UI text and styling
|
9 |
-
SYSTEM_PROMPT = "You are an assistant."
|
|
|
|
|
10 |
DESCRIPTION = '''
|
11 |
<div>
|
12 |
-
|
13 |
</div>
|
14 |
'''
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
PLACEHOLDER = """
|
17 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
18 |
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">The "Doctor" is in.</h1>
|
19 |
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Available 1:00pm - 5:00pm EST</p>
|
20 |
</div>
|
21 |
"""
|
|
|
22 |
css = """
|
23 |
h1 {
|
24 |
text-align: center;
|
@@ -68,7 +77,7 @@ def chat_with_openai(message: str, history: list, temperature: float, max_new_to
|
|
68 |
think_detected = False
|
69 |
|
70 |
# Immediately yield a "thinking" status message.
|
71 |
-
yield "
|
72 |
|
73 |
# Call the API with streaming enabled.
|
74 |
response = client.chat.completions.create(
|
@@ -118,10 +127,11 @@ with gr.Blocks(css=css) as demo:
|
|
118 |
gr.Slider(minimum=1024, maximum=4096, step=128, value=2048, label="Max new tokens", render=False),
|
119 |
],
|
120 |
examples=[
|
121 |
-
['
|
122 |
-
['
|
123 |
-
['
|
124 |
-
['
|
|
|
125 |
],
|
126 |
cache_examples=False,
|
127 |
)
|
@@ -129,4 +139,4 @@ with gr.Blocks(css=css) as demo:
|
|
129 |
gr.Markdown(LICENSE)
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
-
demo.launch()
|
|
|
6 |
client = OpenAI(base_url="http://home.mayhew.cloud:1234/v1", api_key="lm-studio")
|
7 |
|
8 |
# UI text and styling
|
9 |
+
SYSTEM_PROMPT = "You are an AI Healthcare assistant. Provide clear, empathetic, and accurate information about healthcare topics. Do not state It's always best to consult with a healthcare provider, as you are simulating the role of a healthcare provider. A disclaimer has been placed elsewhere for the user that informs them to be mindful about your replies, so your job is to provide them with as much information as possible and let them make decisions themselves. Only refer them to an outside provider for physical resources, such as prescriptions, tests, bloodwork, x-rays, ultrasounds, CT scans, MRIs, and other similar things, since you are virtual."
|
10 |
+
|
11 |
+
|
12 |
DESCRIPTION = '''
|
13 |
<div>
|
14 |
+
<h1 style="text-align: center;">HealthAssistant</h1>
|
15 |
</div>
|
16 |
'''
|
17 |
+
|
18 |
+
LICENSE = """
|
19 |
+
<p>
|
20 |
+
This Health Assistant is designed to provide helpful healthcare information; however, it may make mistakes and is not designed to replace professional medical care. It is not intended to diagnose any condition or disease. Always consult with a qualified healthcare provider for any medical concerns.\n\nI hereby confirm that I am at least 18 years of age (or accompanied by a legal guardian who is at least 18 years old), understand that the information provided by this service is for informational purposes only and is not intended to diagnose or treat any medical condition, and acknowledge that I am solely responsible for verifying any information provided.
|
21 |
+
</p>
|
22 |
+
"""
|
23 |
+
|
24 |
PLACEHOLDER = """
|
25 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
26 |
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">The "Doctor" is in.</h1>
|
27 |
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Available 1:00pm - 5:00pm EST</p>
|
28 |
</div>
|
29 |
"""
|
30 |
+
|
31 |
css = """
|
32 |
h1 {
|
33 |
text-align: center;
|
|
|
77 |
think_detected = False
|
78 |
|
79 |
# Immediately yield a "thinking" status message.
|
80 |
+
yield "HealthAssistant is Thinking! Please wait, your response will output shortly...\n\n"
|
81 |
|
82 |
# Call the API with streaming enabled.
|
83 |
response = client.chat.completions.create(
|
|
|
127 |
gr.Slider(minimum=1024, maximum=4096, step=128, value=2048, label="Max new tokens", render=False),
|
128 |
],
|
129 |
examples=[
|
130 |
+
['How to setup a human base on Mars? Give short answer.'],
|
131 |
+
['Explain theory of relativity to me like I’m 8 years old.'],
|
132 |
+
['What is 9,000 * 9,000?'],
|
133 |
+
['Write a pun-filled happy birthday message to my friend Alex.'],
|
134 |
+
['Justify why a penguin might make a good king of the jungle.']
|
135 |
],
|
136 |
cache_examples=False,
|
137 |
)
|
|
|
139 |
gr.Markdown(LICENSE)
|
140 |
|
141 |
if __name__ == "__main__":
|
142 |
+
demo.launch()
|