Spaces:
Sleeping
Sleeping
Commit
·
f897f98
1
Parent(s):
e8c1600
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import openai
|
2 |
import gradio as gr
|
3 |
from gradio import HuggingFaceDatasetSaver
|
|
|
4 |
|
5 |
-
def openai_chat(prompt
|
6 |
-
openai.api_key = api_key
|
7 |
completions = openai.Completion.create(
|
8 |
engine="text-davinci-003",
|
9 |
prompt=prompt+"The following is the prompt from teacher working in canvas infrastructure",
|
@@ -11,29 +11,23 @@ def openai_chat(prompt, api_key):
|
|
11 |
temperature=0.5,
|
12 |
stop=[" Human:", " AI:"]
|
13 |
)
|
|
|
14 |
message = completions.choices[0].text
|
15 |
return message.strip()
|
16 |
|
17 |
-
def chatbot(input,
|
18 |
-
output = openai_chat(input
|
19 |
history.append((input, output))
|
20 |
return history, history
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
],
|
34 |
-
cache_examples=False,
|
35 |
-
title="GPT-3 Модель: Text-davinci-003",
|
36 |
-
allow_flagging="manual"
|
37 |
-
)
|
38 |
-
|
39 |
-
iface.launch()
|
|
|
1 |
import openai
|
2 |
import gradio as gr
|
3 |
from gradio import HuggingFaceDatasetSaver
|
4 |
+
openai.api_key ='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'
|
5 |
|
6 |
+
def openai_chat(prompt):
|
|
|
7 |
completions = openai.Completion.create(
|
8 |
engine="text-davinci-003",
|
9 |
prompt=prompt+"The following is the prompt from teacher working in canvas infrastructure",
|
|
|
11 |
temperature=0.5,
|
12 |
stop=[" Human:", " AI:"]
|
13 |
)
|
14 |
+
|
15 |
message = completions.choices[0].text
|
16 |
return message.strip()
|
17 |
|
18 |
+
def chatbot(input, history=[]):
|
19 |
+
output = openai_chat(input)
|
20 |
history.append((input, output))
|
21 |
return history, history
|
22 |
|
23 |
+
gr.Interface(fn = chatbot,
|
24 |
+
inputs = ["text",'state'],
|
25 |
+
outputs = ["chatbot",'state'],
|
26 |
+
examples = [
|
27 |
+
["Armar un itinerario para viajar a Madrid, por 7 días, con familia, tener en cuenta que quiero hacer puntos turísticos y museos."],
|
28 |
+
["Armar un plan de viaje para 10 días en Italia."],
|
29 |
+
["Conseguir el vuelo más barato desde Buenos Aires a Nueva York, para un viaje de 7 días en marzo de 2023."],
|
30 |
+
],
|
31 |
+
cache_examples=False,
|
32 |
+
title="Demo app",
|
33 |
+
allow_flagging="manual").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|