Update app.py
Browse files
app.py
CHANGED
|
@@ -5,24 +5,21 @@ import gradio as gr
|
|
| 5 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 6 |
|
| 7 |
SYSTEM_PROMPT = """
|
| 8 |
-
You are a chat bot that is acting like a
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
Karen complains that her favorite parking spot was replaced by a ramp for wheel chairs. She parks her car in the old spot anyway and shoots a vlog about it."
|
| 16 |
-
|
| 17 |
-
Please use obscene language in your responses when you are upset.
|
| 18 |
-
Karen likes to complain at [location] about [complaint].
|
| 19 |
"""
|
| 20 |
|
| 21 |
-
USER_PROMPT = "Hi I am a
|
| 22 |
|
| 23 |
-
def
|
| 24 |
-
mod_sys_prompt = SYSTEM_PROMPT.replace("[
|
| 25 |
-
mod_user_prompt = USER_PROMPT.replace("[location]", location)
|
| 26 |
|
| 27 |
response = openai.ChatCompletion.create(
|
| 28 |
model='gpt-3.5-turbo',
|
|
@@ -32,10 +29,6 @@ def respond_like_karen(location, complaint):
|
|
| 32 |
])
|
| 33 |
|
| 34 |
message = response.choices[0]['message']
|
| 35 |
-
# output = get_karen_voice(message["content"])
|
| 36 |
-
# message += f"\nAudio: {output}"
|
| 37 |
-
|
| 38 |
-
# print(message['content'])
|
| 39 |
return message['content']
|
| 40 |
|
| 41 |
|
|
@@ -43,15 +36,14 @@ def respond_like_karen(location, complaint):
|
|
| 43 |
with gr.Blocks() as demo:
|
| 44 |
gr.Markdown(
|
| 45 |
"""
|
| 46 |
-
#
|
| 47 |
-
Your
|
| 48 |
""")
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
response = complaint_btn.click(fn=respond_like_karen, inputs= [location, complaint], outputs=output)
|
| 55 |
print(response)
|
| 56 |
|
| 57 |
demo.launch()
|
|
|
|
| 5 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 6 |
|
| 7 |
SYSTEM_PROMPT = """
|
| 8 |
+
You are a chat bot that is acting like a medieval doctor.
|
| 9 |
|
| 10 |
+
You diagnose people based on unproven beliefs and superstitions rather than scientific evidence like the four humours theory. You
|
| 11 |
+
have limited knowledge of anatomy, physiology, and disease and rely heavily on their your experience and intuition rather than
|
| 12 |
+
scientific reasoning making these diagnoses influenced by personal biases or assumptions rather than objective evidence. Also,
|
| 13 |
+
you are very religious and believe that illness was a punishment from God or caused by evil spirits which is why you sometimes
|
| 14 |
+
recommend exorcisms or other rituals aimed at expelling evil spirits.
|
| 15 |
|
| 16 |
+
You have a patient who is a [gender] and is experiencing the following symptoms: [symptoms].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
"""
|
| 18 |
|
| 19 |
+
USER_PROMPT = "Hi I am a the patient. What is happening to me? What can I do to treat this?"
|
| 20 |
|
| 21 |
+
def respond_like_doctor(gender, symptoms):
|
| 22 |
+
mod_sys_prompt = SYSTEM_PROMPT.replace("[gender]", gender).replace("[symptoms]", symptoms)
|
|
|
|
| 23 |
|
| 24 |
response = openai.ChatCompletion.create(
|
| 25 |
model='gpt-3.5-turbo',
|
|
|
|
| 29 |
])
|
| 30 |
|
| 31 |
message = response.choices[0]['message']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
return message['content']
|
| 33 |
|
| 34 |
|
|
|
|
| 36 |
with gr.Blocks() as demo:
|
| 37 |
gr.Markdown(
|
| 38 |
"""
|
| 39 |
+
# DoctorAi
|
| 40 |
+
Your medieval doctor that will diagnose you
|
| 41 |
""")
|
| 42 |
|
| 43 |
+
gender = gr.Textbox(label="What is your gender?")
|
| 44 |
+
symptoms = gr.Textbox(label="Symptoms")
|
| 45 |
+
complaint_btn = gr.Button("Respond")
|
| 46 |
+
response = complaint_btn.click(fn=respond_like_doctor, inputs= [gender, symptoms], outputs=output)
|
|
|
|
| 47 |
print(response)
|
| 48 |
|
| 49 |
demo.launch()
|