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, command): messages.append({"role": "user", "content": user_input+command}) 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 = ["text", gradio.Radio(["Provide source of the information", "subtract", "multiply", "divide"])], outputs = "text", title = "Psycology consultation") demo.launch()