seawolf2357 commited on
Commit
530aed8
โ€ข
1 Parent(s): 1e32ed3

initial commit

Browse files
Files changed (1) hide show
  1. app.py +26 -0
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()