Spaces:
Sleeping
Sleeping
Commit
·
e3872f1
1
Parent(s):
bd8e0d7
wip
Browse files
app.py
CHANGED
@@ -1,10 +1,5 @@
|
|
1 |
-
from textblob import TextBlob
|
2 |
-
|
3 |
import gradio as gr
|
4 |
-
|
5 |
-
from mcp.client.stdio import StdioServerParameters
|
6 |
-
from smolagents import InferenceClientModel, CodeAgent, ToolCollection
|
7 |
-
from smolagents.mcp_client import MCPClient
|
8 |
|
9 |
def sentiment_analysis(text: str) -> dict:
|
10 |
"""
|
@@ -25,26 +20,14 @@ def sentiment_analysis(text: str) -> dict:
|
|
25 |
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
26 |
}
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
)
|
33 |
-
tools = mcp_client.get_tools()
|
34 |
-
|
35 |
-
model = InferenceClientModel()
|
36 |
-
agent = CodeAgent(tools=[*tools], model=model)
|
37 |
-
|
38 |
-
|
39 |
-
demo = gr.ChatInterface(
|
40 |
-
fn=lambda message, history: str(agent.run(message)),
|
41 |
-
type="messages",
|
42 |
-
examples=["Prime factorization of 68"],
|
43 |
-
title="Agent with MCP Tools",
|
44 |
-
description="This is a simple agent that uses MCP tools to answer questions.",
|
45 |
-
messages=[],
|
46 |
-
)
|
47 |
-
|
48 |
|
49 |
# Launch the interface and MCP server
|
50 |
if __name__ == "__main__":
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from textblob import TextBlob
|
|
|
|
|
|
|
3 |
|
4 |
def sentiment_analysis(text: str) -> dict:
|
5 |
"""
|
|
|
20 |
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
21 |
}
|
22 |
|
23 |
+
# Create the Gradio interface
|
24 |
+
demo = gr.Interface(
|
25 |
+
fn=sentiment_analysis,
|
26 |
+
inputs=gr.Textbox(placeholder="Enter text to analyze..."),
|
27 |
+
outputs=gr.JSON(),
|
28 |
+
title="Text Sentiment Analysis",
|
29 |
+
description="Analyze the sentiment of text using TextBlob"
|
30 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Launch the interface and MCP server
|
33 |
if __name__ == "__main__":
|