fixed random import bug in app and changed url for mcp client to my HF space
Browse files- app.py +3 -21
- mcp_client.py +2 -1
app.py
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def sentiment_analysis(text: str) -> dict:
|
| 4 |
-
"""
|
| 5 |
-
Analyze the sentiment of the given text.
|
| 6 |
-
|
| 7 |
-
Args:
|
| 8 |
-
text (str): The text to analyze
|
| 9 |
-
|
| 10 |
-
Returns:
|
| 11 |
-
dict: A dictionary containing polarity, subjectivity, and assessment
|
| 12 |
-
"""
|
| 13 |
-
blob = TextBlob(text)
|
| 14 |
-
sentiment = blob.sentiment
|
| 15 |
-
|
| 16 |
-
return {
|
| 17 |
-
"polarity": round(sentiment.polarity, 2), # -1 (negative) to 1 (positive)
|
| 18 |
-
"subjectivity": round(sentiment.subjectivity, 2), # 0 (objective) to 1 (subjective)
|
| 19 |
-
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
def driver_championship_score(driver_name: str) -> str:
|
| 23 |
"""
|
| 24 |
Get the championship score for the given driver.
|
|
@@ -51,14 +33,14 @@ iface1 = gr.Interface(
|
|
| 51 |
fn=driver_championship_score,
|
| 52 |
inputs="text",
|
| 53 |
outputs="text",
|
| 54 |
-
title="Driver Championship Score"
|
| 55 |
)
|
| 56 |
|
| 57 |
iface2 = gr.Interface(
|
| 58 |
fn=driver_position,
|
| 59 |
inputs="text",
|
| 60 |
outputs="text",
|
| 61 |
-
title="Driver Position"
|
| 62 |
)
|
| 63 |
|
| 64 |
# Combine into tabs into server
|
|
|
|
| 1 |
+
import random
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
def driver_championship_score(driver_name: str) -> str:
|
| 5 |
"""
|
| 6 |
Get the championship score for the given driver.
|
|
|
|
| 33 |
fn=driver_championship_score,
|
| 34 |
inputs="text",
|
| 35 |
outputs="text",
|
| 36 |
+
title="[Dummy] Driver Championship Score"
|
| 37 |
)
|
| 38 |
|
| 39 |
iface2 = gr.Interface(
|
| 40 |
fn=driver_position,
|
| 41 |
inputs="text",
|
| 42 |
outputs="text",
|
| 43 |
+
title="[Dummy] Driver Position"
|
| 44 |
)
|
| 45 |
|
| 46 |
# Combine into tabs into server
|
mcp_client.py
CHANGED
|
@@ -8,9 +8,10 @@ if __name__ == "__main__":
|
|
| 8 |
|
| 9 |
try:
|
| 10 |
mcp_client = MCPClient(
|
| 11 |
-
{"url": "https://
|
| 12 |
tools = mcp_client.get_tools()
|
| 13 |
|
|
|
|
| 14 |
print("\n".join(f"{t.name}: {t.description}" for t in tools))
|
| 15 |
|
| 16 |
# Define model
|
|
|
|
| 8 |
|
| 9 |
try:
|
| 10 |
mcp_client = MCPClient(
|
| 11 |
+
{"url": "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse", "transport": "sse"})
|
| 12 |
tools = mcp_client.get_tools()
|
| 13 |
|
| 14 |
+
print("### MCP tools ### ")
|
| 15 |
print("\n".join(f"{t.name}: {t.description}" for t in tools))
|
| 16 |
|
| 17 |
# Define model
|