dionode commited on
Commit
cc909d9
·
1 Parent(s): c97311f

Init commit

Browse files
Files changed (6) hide show
  1. .gradio/flagged/dataset1.csv +2 -0
  2. .python-version +1 -0
  3. README.md +0 -13
  4. app.py +38 -0
  5. pyproject.toml +7 -0
  6. requirements.txt +69 -0
.gradio/flagged/dataset1.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ text,output,timestamp
2
+ ,,2025-09-12 13:55:45.995150
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.12
README.md CHANGED
@@ -1,13 +0,0 @@
1
- ---
2
- title: Mcp Sentiment
3
- emoji: 🔥
4
- colorFrom: purple
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 5.45.0
8
- app_file: app.py
9
- pinned: false
10
- short_description: Learning mcp
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+ from textblob import TextBlob
4
+
5
+ def sentiment_analysis(text: str) -> str:
6
+ """
7
+ Analyze the sentiment of the given text.
8
+
9
+ Args:
10
+ text (str): The text to analyze
11
+
12
+ Returns:
13
+ str: A JSON string containing polarity, subjectivity, and assessment
14
+ """
15
+ blob = TextBlob(text)
16
+ sentiment = blob.sentiment
17
+
18
+ result = {
19
+ "polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive)
20
+ "subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective)
21
+ "assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
22
+ }
23
+
24
+ return json.dumps(result)
25
+
26
+ # Create the Gradio interface
27
+ demo = gr.Interface(
28
+ fn=sentiment_analysis,
29
+ inputs=gr.Textbox(placeholder="Enter text to analyze..."),
30
+ outputs=gr.Textbox(), # Changed from gr.JSON() to gr.Textbox()
31
+ title="Text Sentiment Analysis",
32
+ description="Analyze the sentiment of text using TextBlob"
33
+ )
34
+
35
+ # Launch the interface and MCP server
36
+ # The server will be available at http://localhost:7860/gradio_api/mcp/sse
37
+ if __name__ == "__main__":
38
+ demo.launch(mcp_server=True)
pyproject.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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.12"
7
+ dependencies = []
requirements.txt ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==24.1.0
2
+ annotated-types==0.7.0
3
+ anyio==4.10.0
4
+ attrs==25.3.0
5
+ brotli==1.1.0
6
+ certifi==2025.8.3
7
+ charset-normalizer==3.4.3
8
+ click==8.2.1
9
+ fastapi==0.116.1
10
+ ffmpy==0.6.1
11
+ filelock==3.19.1
12
+ fsspec==2025.9.0
13
+ gradio==5.45.0
14
+ gradio-client==1.13.0
15
+ groovy==0.1.2
16
+ h11==0.16.0
17
+ hf-xet==1.1.9
18
+ httpcore==1.0.9
19
+ httpx==0.28.1
20
+ httpx-sse==0.4.1
21
+ huggingface-hub==0.34.4
22
+ idna==3.10
23
+ jinja2==3.1.6
24
+ joblib==1.5.2
25
+ jsonschema==4.25.1
26
+ jsonschema-specifications==2025.9.1
27
+ markdown-it-py==4.0.0
28
+ markupsafe==3.0.2
29
+ mcp==1.10.1
30
+ mdurl==0.1.2
31
+ nltk==3.9.1
32
+ numpy==2.3.3
33
+ orjson==3.11.3
34
+ packaging==25.0
35
+ pandas==2.3.2
36
+ pillow==11.3.0
37
+ pydantic==2.11.7
38
+ pydantic-core==2.33.2
39
+ pydantic-settings==2.10.1
40
+ pydub==0.25.1
41
+ pygments==2.19.2
42
+ python-dateutil==2.9.0.post0
43
+ python-dotenv==1.1.1
44
+ python-multipart==0.0.20
45
+ pytz==2025.2
46
+ pyyaml==6.0.2
47
+ referencing==0.36.2
48
+ regex==2025.9.1
49
+ requests==2.32.5
50
+ rich==14.1.0
51
+ rpds-py==0.27.1
52
+ ruff==0.13.0
53
+ safehttpx==0.1.6
54
+ semantic-version==2.10.0
55
+ shellingham==1.5.4
56
+ six==1.17.0
57
+ sniffio==1.3.1
58
+ sse-starlette==3.0.2
59
+ starlette==0.47.3
60
+ textblob==0.19.0
61
+ tomlkit==0.13.3
62
+ tqdm==4.67.1
63
+ typer==0.17.4
64
+ typing-extensions==4.15.0
65
+ typing-inspection==0.4.1
66
+ tzdata==2025.2
67
+ urllib3==2.5.0
68
+ uvicorn==0.35.0
69
+ websockets==15.0.1