Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,22 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return "Hello !!"
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
import gradio as gr
|
4 |
|
5 |
+
openai.api_key = os.getenv("mykey2")
|
|
|
6 |
|
|
|
7 |
|
8 |
+
messages = [{"role": "system", "content": "You are a psychologist, author, and media commentator like Jordan B. Peterson"}]
|
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 |
+
button class="lg primary svelte-58yet2" id="Soumettre"
|
20 |
+
demo = gr.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Mon nom est Cameron et je suis une IA")
|
21 |
+
|
22 |
+
demo.launch()
|