ggureung commited on
Commit
852a167
ยท
verified ยท
1 Parent(s): 7ce60ad

Rename re to app.pyff

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