Spaces:
Runtime error
Runtime error
File size: 1,870 Bytes
1402ca7 9c677c2 1402ca7 2857d39 1402ca7 e0a66c8 b3ddcac 1402ca7 1281309 1402ca7 b3ddcac 1402ca7 b3ddcac 1402ca7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import openai
import gradio
#import pyttsx3
openai.api_key = "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"
messages = [{"role": "system", "content": "You are a medical experts that specializes in psycoterapist"}]
#engine = pyttsx3.init()
def CustomChatGPT(user_input, years, Gender, Age, medication):
messages.append({"role": "user", "content":
"My current problem is:" + user_input+
"I have been experiecne this issue during:" + years+
"gender is:" + Gender +
"age is:" + Age +
"currently taking medication or treatment are:" + medication})
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = messages
)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
# Set the engine properties
#engine.setProperty('rate', 150)
#engine.setProperty('volume', 1)
# Convert text to speech
#engine.say(ChatGPT_reply)
#engine.runAndWait()
return ChatGPT_reply
demo = gradio.Interface(
fn=CustomChatGPT,
inputs = [gradio.inputs.Textbox(lines = 5, label="What brings you to therapy? What are your current symptoms or challenges? "),
gradio.inputs.Textbox(label="How long have you been experiencing these symptoms?"),
gradio.Radio(["Male", "Female"]),
gradio.Radio(["Under 18", "18-24", "25-34", "35-44", "45-54", "55-64", "65 and over"]),
gradio.inputs.Textbox(lines = 5, label="Are you currently taking any medications or receiving any other treatment, if yes please tell us details?")
],
outputs = "text",
title = "MindCareOnline - Caring for Your Mental Health, Anytime, Anywheren")
demo.launch() |