sidkhuntia commited on
Commit
a653e13
·
unverified ·
0 Parent(s):

Signed-off-by: Siddhartha Khuntia <siddharthakhuntia@gmail.com>

Files changed (6) hide show
  1. .gitignore +10 -0
  2. .python-version +1 -0
  3. app.py +33 -0
  4. pyproject.toml +10 -0
  5. requirements.txt +2 -0
  6. uv.lock +0 -0
.gitignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ def analyze_sentiment(text: str) -> dict:
5
+ """
6
+ Analyze the sentiment of a text.
7
+
8
+ Args:
9
+ text (str): The text to analyze.
10
+
11
+ Returns:
12
+ dict: A dictionary containing the sentiment analysis results.
13
+ """
14
+
15
+ blob: TextBlob = TextBlob(text)
16
+ sentiment = blob.sentiment
17
+ return {
18
+ "polarity": sentiment.polarity,
19
+ "subjectivity": sentiment.subjectivity,
20
+ "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral",
21
+ }
22
+
23
+ demo: gr.Interface = gr.Interface(
24
+ fn=analyze_sentiment,
25
+ inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
26
+ outputs=gr.JSON(),
27
+ title="Sentiment Analysis",
28
+ description="Analyze the sentiment of a text.",
29
+ )
30
+
31
+
32
+ if __name__ == "__main__":
33
+ demo.launch(mcp_server=True)
pyproject.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "unit-2-mcp-course"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "gradio[mcp]>=5.31.0",
9
+ "textblob>=0.19.0",
10
+ ]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob
uv.lock ADDED
The diff for this file is too large to render. See raw diff