ggureung commited on
Commit
0c036d3
ยท
verified ยท
1 Parent(s): a498796

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -25
app.py CHANGED
@@ -1,26 +1,2 @@
1
- import openai
2
  import gradio as gr
3
-
4
- # OpenAI API ์ธ์ฆ ์ •๋ณด ์„ค์ •
5
- api_key = "YOUR_OPENAI_API_KEY"
6
- openai.api_key = api_key
7
-
8
- # ๊ฐ์„ฑ ๋ถ„์„์„ ์œ„ํ•œ ํ•จ์ˆ˜
9
- def analyze_sentiment(text):
10
- # OpenAI API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ ๊ฐ์„ฑ ๋ถ„์„ ์ˆ˜ํ–‰
11
- response = openai.Completion.create(
12
- engine="text-davinci-002", # ๊ฐ์„ฑ ๋ถ„์„ ์—”์ง„ ์„ ํƒ
13
- prompt=text,
14
- temperature=0,
15
- max_tokens=1
16
- )
17
- # ๊ฒฐ๊ณผ์—์„œ ๊ฐ์„ฑ ๋ ˆ์ด๋ธ” ์ถ”์ถœ
18
- sentiment = response.choices[0].text.strip()
19
- return sentiment
20
-
21
- # Gradio๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์›น ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
22
- input_text = gr.inputs.Textbox(lines=5, label="Enter text for sentiment analysis")
23
- output_text = gr.outputs.Textbox(label="Sentiment")
24
-
25
- # Gradio UI ๊ตฌ์„ฑ
26
- gr.Interface(analyze_sentiment, inputs=input_text, outputs=output_text).launch()
 
1
+ from transformers import pipeline
2
  import gradio as gr