Spaces:
Runtime error
Runtime error
Tricia Nieva
commited on
Commit
·
3e530ed
1
Parent(s):
dac8133
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[ ]:
|
5 |
+
|
6 |
+
|
7 |
+
import os
|
8 |
+
import openai
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
openai.organization = "org-orRhfBkKOfOuNACbjPyWKbUt"
|
12 |
+
openai.api_key = "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"
|
13 |
+
|
14 |
+
def predict(input,initial_prompt, history=[]):
|
15 |
+
|
16 |
+
response = openai.Completion.create(
|
17 |
+
model="davinci:ft-placeholder:ai-dhd-2022-12-07-10-09-37",
|
18 |
+
prompt= initial_prompt + "\n" + str(s),
|
19 |
+
temperature=0.09,
|
20 |
+
max_tokens=608,
|
21 |
+
top_p=1,
|
22 |
+
frequency_penalty=0,
|
23 |
+
presence_penalty=0
|
24 |
+
)
|
25 |
+
|
26 |
+
# tokenize the new input sentence
|
27 |
+
response2 = response["choices"][0]["text"]
|
28 |
+
history.append((input, response2))
|
29 |
+
|
30 |
+
return history, history
|
31 |
+
|
32 |
+
|
33 |
+
gr.Interface(fn=predict,
|
34 |
+
inputs=["text","text",'state'],
|
35 |
+
|
36 |
+
outputs=["chatbot",'state']).launch()
|