Cascade Assistant commited on
Commit
be1c032
·
1 Parent(s): dacebd1

Upload correct app.py and requirements.txt

Browse files
Files changed (2) hide show
  1. app.py +41 -0
  2. requirements.txt +2 -0
app.py CHANGED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def sentiment_analysis(text: str) -> dict:
5
+ """
6
+ Performs sentiment analysis on the input text.
7
+
8
+ Args:
9
+ text (str): The text to analyze.
10
+
11
+ Returns:
12
+ dict: A dictionary containing polarity, subjectivity, and a qualitative assessment.
13
+ """
14
+ blob = TextBlob(text)
15
+ polarity = blob.sentiment.polarity
16
+ subjectivity = blob.sentiment.subjectivity
17
+
18
+ if polarity > 0.1:
19
+ assessment = "positive"
20
+ elif polarity < -0.1:
21
+ assessment = "negative"
22
+ else:
23
+ assessment = "neutral"
24
+
25
+ return {
26
+ "polarity": polarity,
27
+ "subjectivity": subjectivity,
28
+ "assessment": assessment
29
+ }
30
+
31
+ iface = gr.Interface(
32
+ fn=sentiment_analysis,
33
+ inputs=gr.Textbox(lines=2, placeholder="Enter text for sentiment analysis..."),
34
+ outputs=gr.JSON(),
35
+ title="Sentiment Analysis Tool (MCP Enabled)",
36
+ description="Enter text to get its sentiment polarity, subjectivity, and a qualitative assessment. This server is MCP enabled."
37
+ )
38
+
39
+ if __name__ == "__main__":
40
+ # Launch the server with mcp_server=True to enable the MCP endpoint
41
+ iface.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob