Spaces:
Running
Running
Update app.py
Browse filesUpgrade to smolagents.
Based on: https://huggingface.co/docs/smolagents/tutorials/tools
app.py
CHANGED
@@ -7,8 +7,43 @@ sentiment_tool = SentimentAnalysisTool()
|
|
7 |
if __name__ == "__main__":
|
8 |
import gradio as gr
|
9 |
|
10 |
-
gr.
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
if __name__ == "__main__":
|
8 |
import gradio as gr
|
9 |
|
10 |
+
with gr.Blocks(title="Sentiment Analysis Tool") as demo:
|
11 |
+
gr.Markdown("# Sentiment Analysis Tool")
|
12 |
+
|
13 |
+
with gr.Row():
|
14 |
+
with gr.Column():
|
15 |
+
text_input = gr.Textbox(
|
16 |
+
label="Enter text to analyze",
|
17 |
+
placeholder="Type your text here...",
|
18 |
+
lines=5
|
19 |
+
)
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
analyze_btn = gr.Button("Analyze Sentiment")
|
23 |
+
clear_btn = gr.Button("Clear")
|
24 |
+
|
25 |
+
with gr.Column():
|
26 |
+
output = gr.JSON(label="Sentiment Analysis Results")
|
27 |
+
|
28 |
+
analyze_btn.click(
|
29 |
+
fn=sentiment_tool,
|
30 |
+
inputs=text_input,
|
31 |
+
outputs=output
|
32 |
+
)
|
33 |
+
|
34 |
+
clear_btn.click(
|
35 |
+
fn=lambda: ("", None),
|
36 |
+
inputs=None,
|
37 |
+
outputs=[text_input, output]
|
38 |
+
)
|
39 |
+
|
40 |
+
gr.Examples(
|
41 |
+
examples=[
|
42 |
+
["I love this product! It's amazing and works perfectly."],
|
43 |
+
["This movie was terrible. I was very disappointed."],
|
44 |
+
["The service was okay, but could be improved in several ways."]
|
45 |
+
],
|
46 |
+
inputs=text_input
|
47 |
+
)
|
48 |
+
|
49 |
+
demo.launch(share=True)
|