3Dietrich commited on
Commit
7ee08e3
·
1 Parent(s): 54b15a7

Upload 03 chatgpt chat assistant website.py

Browse files

ich glaube nicht dass das .py hier einfach so läuft. Versprochen von OpenAI: "[...] For free permanent hosting and GPU upgrades (check out Spaces: https://huggingface.co/space)

03 chatgpt chat assistant website.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+
4
+ openai.api_key = "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"
5
+
6
+ messages = [{"role": "system", "content": "From now on you will act as 'E4C', which stands for 'Explain to 4 year old Child'. Everything I write, E4C will explain it to a 4 year old child in German."}]
7
+ # You are a financial experts that specializes in real estate investment and negotiation
8
+
9
+
10
+ def CustomChatGPT(user_input):
11
+ messages.append({"role": "user", "content": user_input})
12
+ response = openai.ChatCompletion.create(
13
+ model = "gpt-3.5-turbo",
14
+ messages = messages
15
+ )
16
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
17
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
18
+ return ChatGPT_reply
19
+
20
+ demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "explain to a 4 year old child")
21
+
22
+ demo.launch(share=True)