Spaces:
No application file
No application file
Create ggggggu
Browse files
ggggggu
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|