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()