Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import openai
|
3 |
+
|
4 |
+
openai.api_key = "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"
|
5 |
+
|
6 |
+
def GenerateResponse(input_text):
|
7 |
+
response = openai.Completion.create(model="text-davinci-003", prompt=input_text,max_tokens= 50,temperature=0.1)
|
8 |
+
output = response.choices[0].text
|
9 |
+
return output.strip()
|
10 |
+
|
11 |
+
def chatbot(input,history=[]):
|
12 |
+
result=GenerateResponse(input)
|
13 |
+
history.append((input,result))
|
14 |
+
return history,history
|
15 |
+
|
16 |
+
import gradio as gr
|
17 |
+
|
18 |
+
app = gr.Interface(fn=chatbot,inputs=["text","state"],
|
19 |
+
outputs=["chatbot","state"],
|
20 |
+
title="ChatGPT Demo")
|
21 |
+
|
22 |
+
app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.0.22
|
2 |
+
openai
|
3 |
+
aiohttp
|
4 |
+
fsspec
|
5 |
+
paramiko
|