akashVP commited on
Commit
c5b135f
·
1 Parent(s): 0706644

fix: update package version and intendation

Browse files
Files changed (2) hide show
  1. app.py +26 -17
  2. requirements.txt +213 -13
app.py CHANGED
@@ -2,35 +2,44 @@ 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)
 
2
  import gradio as gr
3
  from textblob import TextBlob
4
 
5
+
6
+ def sentiment_analysis(text: str) -> str:
7
+ """
8
+ Analyze the sentiment of the given text.
9
 
10
  Args:
11
+ text (str): The text to analyze
12
+
13
  Returns:
14
+ str: A JSON string containing polarity, subjectivity, and assessment
15
  """
 
16
  blob = TextBlob(text)
17
  sentiment = blob.sentiment
18
 
19
  result = {
20
+ "polarity": round(sentiment.polarity, 2),
21
+ "subjectivity": round(
22
+ sentiment.subjectivity, 2
23
+ ),
24
+ "assessment": (
25
+ "positive"
26
+ if sentiment.polarity > 0
27
+ else "negative" if sentiment.polarity < 0 else "neutral"
28
+ ),
29
  }
30
 
31
+ return json.dumps(result)
32
+
33
 
34
+ # Create the Gradio interface
35
  demo = gr.Interface(
36
+ fn=sentiment_analysis,
37
+ inputs=gr.Textbox(placeholder="Enter text to analyze..."),
38
+ outputs=gr.Textbox(), # Changed from gr.JSON() to gr.Textbox()
39
+ title="Text Sentiment Analysis",
40
+ description="Analyze the sentiment of text using TextBlob",
41
  )
42
 
43
+ # Launch the interface and MCP server
44
  if __name__ == "__main__":
45
+ demo.launch(mcp_server=True)
requirements.txt CHANGED
@@ -1,16 +1,216 @@
1
- gradio==4.44.0
2
- huggingface_hub==0.24.6
3
-
4
- fastapi==0.110.0
5
- uvicorn==0.29.0
6
-
7
- pydantic==2.6.4
8
- pydantic-settings==2.2.1
9
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  numpy==1.26.4
 
 
 
 
 
 
 
 
 
 
11
  pandas==2.2.2
12
-
13
- textblob==0.19.0
14
- nltk==3.9.1
15
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  python-dotenv==1.0.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile pyproject.toml -o requirements.txt
3
+ aiofiles==24.1.0
4
+ # via gradio
5
+ annotated-doc==0.0.4
6
+ # via fastapi
7
+ annotated-types==0.7.0
8
+ # via pydantic
9
+ anyio==4.12.0
10
+ # via
11
+ # gradio
12
+ # httpx
13
+ # mcp
14
+ # sse-starlette
15
+ # starlette
16
+ attrs==25.4.0
17
+ # via
18
+ # jsonschema
19
+ # referencing
20
+ brotli==1.2.0
21
+ # via gradio
22
+ certifi==2025.11.12
23
+ # via
24
+ # httpcore
25
+ # httpx
26
+ cffi==2.0.0
27
+ # via cryptography
28
+ click==8.3.1
29
+ # via
30
+ # nltk
31
+ # typer
32
+ # typer-slim
33
+ # uvicorn
34
+ cryptography==46.0.3
35
+ # via pyjwt
36
+ exceptiongroup==1.3.1
37
+ # via anyio
38
+ fastapi==0.127.0
39
+ # via gradio
40
+ ffmpy==1.0.0
41
+ # via gradio
42
+ filelock==3.20.1
43
+ # via huggingface-hub
44
+ fsspec==2025.12.0
45
+ # via
46
+ # gradio-client
47
+ # huggingface-hub
48
+ gradio==6.2.0
49
+ # via mcp-sentiment (pyproject.toml)
50
+ gradio-client==2.0.2
51
+ # via gradio
52
+ groovy==0.1.2
53
+ # via gradio
54
+ h11==0.16.0
55
+ # via
56
+ # httpcore
57
+ # uvicorn
58
+ hf-xet==1.2.0
59
+ # via huggingface-hub
60
+ httpcore==1.0.9
61
+ # via httpx
62
+ httpx==0.28.1
63
+ # via
64
+ # gradio
65
+ # gradio-client
66
+ # huggingface-hub
67
+ # mcp
68
+ # safehttpx
69
+ httpx-sse==0.4.3
70
+ # via mcp
71
+ huggingface-hub==1.2.3
72
+ # via
73
+ # gradio
74
+ # gradio-client
75
+ idna==3.11
76
+ # via
77
+ # anyio
78
+ # httpx
79
+ jinja2==3.1.6
80
+ # via gradio
81
+ joblib==1.5.3
82
+ # via nltk
83
+ jsonschema==4.25.1
84
+ # via mcp
85
+ jsonschema-specifications==2025.9.1
86
+ # via jsonschema
87
+ markdown-it-py==4.0.0
88
+ # via rich
89
+ markupsafe==3.0.3
90
+ # via
91
+ # gradio
92
+ # jinja2
93
+ mcp==1.25.0
94
+ # via gradio
95
+ mdurl==0.1.2
96
+ # via markdown-it-py
97
+ nltk==3.9.1
98
+ # via textblob
99
  numpy==1.26.4
100
+ # via
101
+ # gradio
102
+ # pandas
103
+ orjson==3.11.5
104
+ # via gradio
105
+ packaging==25.0
106
+ # via
107
+ # gradio
108
+ # gradio-client
109
+ # huggingface-hub
110
  pandas==2.2.2
111
+ # via gradio
112
+ pillow==12.0.0
113
+ # via gradio
114
+ pycparser==2.23
115
+ # via cffi
116
+ pydantic==2.12.5
117
+ # via
118
+ # fastapi
119
+ # gradio
120
+ # mcp
121
+ # pydantic-settings
122
+ pydantic-core==2.41.5
123
+ # via pydantic
124
+ pydantic-settings==2.12.0
125
+ # via mcp
126
+ pydub==0.25.1
127
+ # via gradio
128
+ pygments==2.19.2
129
+ # via rich
130
+ pyjwt==2.10.1
131
+ # via mcp
132
+ python-dateutil==2.9.0.post0
133
+ # via pandas
134
  python-dotenv==1.0.1
135
+ # via pydantic-settings
136
+ python-multipart==0.0.21
137
+ # via
138
+ # gradio
139
+ # mcp
140
+ pytz==2025.2
141
+ # via pandas
142
+ pyyaml==6.0.3
143
+ # via
144
+ # gradio
145
+ # huggingface-hub
146
+ referencing==0.37.0
147
+ # via
148
+ # jsonschema
149
+ # jsonschema-specifications
150
+ regex==2025.11.3
151
+ # via nltk
152
+ rich==14.2.0
153
+ # via typer
154
+ rpds-py==0.30.0
155
+ # via
156
+ # jsonschema
157
+ # referencing
158
+ safehttpx==0.1.7
159
+ # via gradio
160
+ semantic-version==2.10.0
161
+ # via gradio
162
+ shellingham==1.5.4
163
+ # via
164
+ # huggingface-hub
165
+ # typer
166
+ six==1.17.0
167
+ # via python-dateutil
168
+ sse-starlette==3.0.4
169
+ # via mcp
170
+ starlette==0.50.0
171
+ # via
172
+ # fastapi
173
+ # gradio
174
+ # mcp
175
+ # sse-starlette
176
+ textblob==0.19.0
177
+ # via mcp-sentiment (pyproject.toml)
178
+ tomlkit==0.13.3
179
+ # via gradio
180
+ tqdm==4.67.1
181
+ # via
182
+ # huggingface-hub
183
+ # nltk
184
+ typer==0.21.0
185
+ # via gradio
186
+ typer-slim==0.21.0
187
+ # via huggingface-hub
188
+ typing-extensions==4.15.0
189
+ # via
190
+ # anyio
191
+ # cryptography
192
+ # exceptiongroup
193
+ # fastapi
194
+ # gradio
195
+ # gradio-client
196
+ # huggingface-hub
197
+ # mcp
198
+ # pydantic
199
+ # pydantic-core
200
+ # referencing
201
+ # starlette
202
+ # typer
203
+ # typer-slim
204
+ # typing-inspection
205
+ # uvicorn
206
+ typing-inspection==0.4.2
207
+ # via
208
+ # mcp
209
+ # pydantic
210
+ # pydantic-settings
211
+ tzdata==2025.3
212
+ # via pandas
213
+ uvicorn==0.40.0
214
+ # via
215
+ # gradio
216
+ # mcp