Rename re to app.pyff
Browse files
app.pyff
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
sentiment = pipeline("sentiment-analysis")
|
5 |
+
|
6 |
+
def sentiment_getter(input_text):
|
7 |
+
return sentiment(input_text)
|
8 |
+
|
9 |
+
iface = gr.Interface(fn = sentiment_getter,
|
10 |
+
input = 'text' ,
|
11 |
+
outputs = ["text"],
|
12 |
+
title = "sentiment analysis" ,
|
13 |
+
description = "this app is analyze out sentence and give the results")
|
14 |
+
iface.launch()
|
re
DELETED
@@ -1,26 +0,0 @@
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|