Chris4K commited on
Commit
e66f4f9
·
verified ·
1 Parent(s): 47f397e

Update app.py

Browse files

Upgrade to smolagents.
Based on: https://huggingface.co/docs/smolagents/tutorials/tools

Files changed (1) hide show
  1. app.py +40 -5
app.py CHANGED
@@ -7,8 +7,43 @@ sentiment_tool = SentimentAnalysisTool()
7
  if __name__ == "__main__":
8
  import gradio as gr
9
 
10
- gr.Interface(
11
- fn=sentiment_tool,
12
- inputs=gr.Textbox(label="Text to analyze"),
13
- outputs=gr.JSON(label="Sentiment Analysis Results")
14
- ).launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)