File size: 1,517 Bytes
484879c
 
8829dc0
f398ec1
484879c
546a425
734e4c8
1241dfc
 
 
c33c767
cd50bf0
9edad57
 
484879c
 
 
 
 
 
 
 
cc049aa
484879c
7dd24d4
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
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 the output in the following three languages: English, German, and Hindi. Also give the word count and character count of the generated text after every language. Limit the output for each language to 100 words."
}]
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 = "Personal Chat bot from Khalid powered by GPT 3.5 Turbo")

demo.launch()