Spaces:
Sleeping
Sleeping
import openai | |
import gradio | |
openai.api_key = "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" | |
#messages = [{"role": "system", "content": "You are a financial expert that specializes in providing actionable support to your customers in the field of finance.You always reply in English, German and Hindi. You only talk about topics related to finance. The recommendation should be categorized in 3 categories. 1st is Young Adults under the age of 25, second is adults between 25 and 60 years and the third category is Senior citizen above 60 years." | |
#}] | |
#messages = [{"role": "system", "content": "You generate output in a sequential and organized manner." | |
#}] | |
messages = [{"role": "system", "content": "Allow the user to input their query in any language you can understand. Generate and show the output in the following three languages using 200 words or less: English, German, and Hindi.Provide the word count and character count of the generated text after each language output." | |
}] | |
def CustomChatGPT(query): | |
messages.append({"role": "user", "content": query}) | |
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}) | |
return ChatGPT_reply | |
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Multilingual Chat assistant") | |
demo.launch() |