Spaces:
No application file
No application file
baotoan2002
commited on
Commit
•
fbf900e
1
Parent(s):
0bd325c
Delete app.py
Browse files
app.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
import openai
|
2 |
-
import gradio as gr
|
3 |
-
|
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,
|
10 |
-
max_tokens=1024,
|
11 |
-
n=1,
|
12 |
-
temperature=0.5,
|
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']).launch(debug = False, inline = False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|