akashVP commited on
Commit
991dcf7
·
1 Parent(s): 1866a72

initial commit

Browse files
Files changed (6) hide show
  1. .python-version +1 -0
  2. README.md +0 -12
  3. main.py +36 -0
  4. pyproject.toml +10 -0
  5. requirements.txt +70 -0
  6. uv.lock +0 -0
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.10
README.md CHANGED
@@ -1,12 +0,0 @@
1
- ---
2
- title: Mcp Sentiment
3
- emoji: 🔥
4
- colorFrom: indigo
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 6.2.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+ from textblob import TextBlob
4
+
5
+ def sentiment_analysis(text:str) ->str:
6
+ """Analyze the sentiment of the given text
7
+
8
+ Args:
9
+ text: text to analyze sentiment
10
+
11
+ Returns:
12
+ str: a json string containse polarity,subjectivity and assessment
13
+ """
14
+
15
+ blob = TextBlob(text)
16
+ sentiment = blob.sentiment
17
+
18
+ result = {
19
+ "polarity":round(sentiment.polarity,2),
20
+ "subjectivity": round(sentiment.subjectivity,2),
21
+ "assessment":"positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
22
+ }
23
+
24
+ return result
25
+
26
+ demo = gr.Interface(
27
+ fn = sentiment_analysis,
28
+ inputs = gr.Textbox(placeholder="enter text to analyze.."),
29
+ outputs=gr.Textbox(),
30
+ title="Text sentimetn analysis",
31
+ description="Analyze the sentiment of text using textblob"
32
+ )
33
+
34
+
35
+ if __name__ == "__main__":
36
+ demo.launch(mcp_server=True)
pyproject.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "mcp-sentiment"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "gradio[mcp]>=6.2.0",
9
+ "textblob>=0.19.0",
10
+ ]
requirements.txt ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==24.1.0
2
+ annotated-doc==0.0.4
3
+ annotated-types==0.7.0
4
+ anyio==4.12.0
5
+ attrs==25.4.0
6
+ brotli==1.2.0
7
+ certifi==2025.11.12
8
+ cffi==2.0.0
9
+ click==8.3.1
10
+ cryptography==46.0.3
11
+ exceptiongroup==1.3.1
12
+ fastapi==0.127.0
13
+ ffmpy==1.0.0
14
+ filelock==3.20.1
15
+ fsspec==2025.12.0
16
+ gradio==6.2.0
17
+ gradio-client==2.0.2
18
+ groovy==0.1.2
19
+ h11==0.16.0
20
+ hf-xet==1.2.0
21
+ httpcore==1.0.9
22
+ httpx==0.28.1
23
+ httpx-sse==0.4.3
24
+ huggingface-hub==1.2.3
25
+ idna==3.11
26
+ jinja2==3.1.6
27
+ joblib==1.5.3
28
+ jsonschema==4.25.1
29
+ jsonschema-specifications==2025.9.1
30
+ markdown-it-py==4.0.0
31
+ markupsafe==3.0.3
32
+ mcp==1.25.0
33
+ mdurl==0.1.2
34
+ nltk==3.9.2
35
+ numpy==2.2.6
36
+ orjson==3.11.5
37
+ packaging==25.0
38
+ pandas==2.3.3
39
+ pillow==12.0.0
40
+ pycparser==2.23
41
+ pydantic==2.12.5
42
+ pydantic-core==2.41.5
43
+ pydantic-settings==2.12.0
44
+ pydub==0.25.1
45
+ pygments==2.19.2
46
+ pyjwt==2.10.1
47
+ python-dateutil==2.9.0.post0
48
+ python-dotenv==1.2.1
49
+ python-multipart==0.0.21
50
+ pytz==2025.2
51
+ pyyaml==6.0.3
52
+ referencing==0.37.0
53
+ regex==2025.11.3
54
+ rich==14.2.0
55
+ rpds-py==0.30.0
56
+ safehttpx==0.1.7
57
+ semantic-version==2.10.0
58
+ shellingham==1.5.4
59
+ six==1.17.0
60
+ sse-starlette==3.0.4
61
+ starlette==0.50.0
62
+ textblob==0.19.0
63
+ tomlkit==0.13.3
64
+ tqdm==4.67.1
65
+ typer==0.20.1
66
+ typer-slim==0.20.1
67
+ typing-extensions==4.15.0
68
+ typing-inspection==0.4.2
69
+ tzdata==2025.3
70
+ uvicorn==0.40.0
uv.lock ADDED
The diff for this file is too large to render. See raw diff