Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
-
from smolagents import InferenceClientModel, CodeAgent, MCPClient
|
| 4 |
-
|
| 5 |
from mcp import ClientSession
|
| 6 |
from mcp.client.sse import sse_client
|
|
|
|
| 7 |
import asyncio
|
| 8 |
|
|
|
|
| 9 |
async def run(date_input) -> str:
|
| 10 |
async with sse_client(url="https://sergeyo7-garden-magus-mcp.hf.space/gradio_api/mcp/sse") as streams:
|
| 11 |
async with ClientSession(*streams) as session:
|
|
@@ -25,25 +23,19 @@ async def run(date_input) -> str:
|
|
| 25 |
return result.content[0].text # pyright: ignore[reportAttributeAccessIssue]
|
| 26 |
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
description="This is a simple agent that uses MCP tools to answer questions.",
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
demo.launch()
|
| 46 |
-
|
| 47 |
-
mcp_client.disconnect()
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from mcp import ClientSession
|
| 2 |
from mcp.client.sse import sse_client
|
| 3 |
+
import gradio as gr
|
| 4 |
import asyncio
|
| 5 |
|
| 6 |
+
|
| 7 |
async def run(date_input) -> str:
|
| 8 |
async with sse_client(url="https://sergeyo7-garden-magus-mcp.hf.space/gradio_api/mcp/sse") as streams:
|
| 9 |
async with ClientSession(*streams) as session:
|
|
|
|
| 23 |
return result.content[0].text # pyright: ignore[reportAttributeAccessIssue]
|
| 24 |
|
| 25 |
|
| 26 |
+
demo = gr.Interface(
|
| 27 |
+
fn=run,
|
| 28 |
+
inputs=gr.DateTime(
|
| 29 |
+
label="Date and Time",
|
| 30 |
+
type="datetime", # Explicitly set to return datetime object
|
| 31 |
+
timezone="UTC"
|
| 32 |
+
),
|
| 33 |
+
outputs=gr.Textbox(),
|
| 34 |
+
title="Garden Magus",
|
| 35 |
+
description="Enter date and time to calculate Moon's position and phase, fertility and pruning indices."
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
# Launch the interface
|
| 39 |
+
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
| 40 |
demo.launch()
|
| 41 |
+
# asyncio.run(run())
|
|
|
|
|
|
|
|
|