Commit
·
4f4d8ef
1
Parent(s):
878c0f0
Actualizar la conexión SSE a localhost y modificar la función de chat para usar 'tab_id' en lugar de 'correlation_id'
Browse files
app.py
CHANGED
@@ -10,7 +10,8 @@ import gradio as gr
|
|
10 |
import re
|
11 |
|
12 |
async def initialize_agent():
|
13 |
-
connection = SSEConnection(url="https://javier-jimenez99-owlbear-mcp-server.hf.space/gradio_api/mcp/sse", transport="sse")
|
|
|
14 |
tools = await load_mcp_tools(session=None,connection=connection)
|
15 |
llm = ChatOllama(model="qwen3:8b")
|
16 |
agent = create_react_agent(llm, tools)
|
@@ -30,10 +31,10 @@ def initialize_agent_sync():
|
|
30 |
agent = initialize_agent_sync()
|
31 |
|
32 |
# Function for HTTP API
|
33 |
-
async def chat(message: str,
|
34 |
"""Function to handle direct HTTP requests"""
|
35 |
-
if
|
36 |
-
message = f"{message}
|
37 |
|
38 |
print(f"Received message: {message}")
|
39 |
|
@@ -50,7 +51,7 @@ async def chat(message: str, correlation_id: str = None):
|
|
50 |
# Create API interface
|
51 |
demo = gr.Interface(
|
52 |
fn=chat,
|
53 |
-
inputs="
|
54 |
outputs="text",
|
55 |
)
|
56 |
|
|
|
10 |
import re
|
11 |
|
12 |
async def initialize_agent():
|
13 |
+
#connection = SSEConnection(url="https://javier-jimenez99-owlbear-mcp-server.hf.space/gradio_api/mcp/sse", transport="sse")
|
14 |
+
connection = SSEConnection(url="http://localhost:7861/gradio_api/mcp/sse", transport="sse")
|
15 |
tools = await load_mcp_tools(session=None,connection=connection)
|
16 |
llm = ChatOllama(model="qwen3:8b")
|
17 |
agent = create_react_agent(llm, tools)
|
|
|
31 |
agent = initialize_agent_sync()
|
32 |
|
33 |
# Function for HTTP API
|
34 |
+
async def chat(message: str, tab_id: str):
|
35 |
"""Function to handle direct HTTP requests"""
|
36 |
+
if tab_id:
|
37 |
+
message = f"{message}\nThis is your correlation ID: {tab_id}"
|
38 |
|
39 |
print(f"Received message: {message}")
|
40 |
|
|
|
51 |
# Create API interface
|
52 |
demo = gr.Interface(
|
53 |
fn=chat,
|
54 |
+
inputs=[gr.Textbox(label="message"), gr.Textbox(label="tab_id")],
|
55 |
outputs="text",
|
56 |
)
|
57 |
|