Spaces:
Runtime error
Runtime error
seawolf2357
commited on
Commit
โข
530aed8
1
Parent(s):
1e32ed3
initial commit
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from openai import api_request
|
3 |
+
|
4 |
+
def openai_response(input_string):
|
5 |
+
response = api_request(
|
6 |
+
"engines/chatbot/run",
|
7 |
+
{
|
8 |
+
"text": input_string,
|
9 |
+
"engine": "chatgpt",
|
10 |
+
"temperature": 0.5,
|
11 |
+
"max_tokens": 100
|
12 |
+
},
|
13 |
+
headers={"Authorization": "Bearer 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"}
|
14 |
+
)
|
15 |
+
|
16 |
+
return response['choices'][0]['text']
|
17 |
+
|
18 |
+
# ์ฌ์ฉ์ ์
๋ ฅ์ ๋ฐ์์ openai์ ์์ฒญ
|
19 |
+
input_text = gr.inputs.Textbox(lines=3, label="๋ํ ์
๋ ฅ")
|
20 |
+
|
21 |
+
# openai์ ์๋ต์ ์ถ๋ ฅํ๊ธฐ ์ํ ์ธํฐํ์ด์ค
|
22 |
+
output_text = gr.outputs.Textbox(label="openAI ๋๋ต")
|
23 |
+
|
24 |
+
# openai_response ํจ์์ ์ฌ์ฉ์์ ์
๋ ฅ์ ์ ๋ฌ
|
25 |
+
interaction = gr.Interaction(input_text, output_text, openai_response)
|
26 |
+
interaction.launch()
|