File tree Expand file tree Collapse file tree 3 files changed +38
-35
lines changed
cli/services/vefaas/template Expand file tree Collapse file tree 3 files changed +38
-35
lines changed Original file line number Diff line number Diff line change 2121from veadk .a2a .agent_card import get_agent_card
2222from veadk .a2a .ve_agent_executor import VeAgentExecutor
2323from veadk .memory .short_term_memory import ShortTermMemory
24- from veadk .runner import Runner
2524
2625
2726class VeA2AServer :
@@ -49,39 +48,6 @@ def build(self) -> FastAPI:
4948 )
5049 app = app_application .build () # build routes
5150
52- runner = Runner (
53- agent = self .agent_executor .agent ,
54- short_term_memory = self .agent_executor .short_term_memory ,
55- app_name = self .agent_executor .app_name ,
56- user_id = "" ,
57- )
58-
59- @app .post ("/run_agent" , operation_id = "run_agent" , tags = ["mcp" ])
60- async def run_agent (
61- user_input : str ,
62- user_id : str = "unknown_user" ,
63- session_id : str = "unknown_session" ,
64- ) -> str :
65- """
66- Execute agent with user input and return final output
67- Args:
68- user_input: User's input message
69- user_id: User identifier
70- session_id: Session identifier
71- Returns:
72- Final agent response
73- """
74- # Set user_id for runner
75- runner .user_id = user_id
76-
77- # Running agent and get final output
78- final_output = await runner .run (
79- messages = user_input ,
80- session_id = session_id ,
81- )
82-
83- return final_output
84-
8551 return app
8652
8753
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ async def main():
6363 async with client :
6464 # List available tools
6565 tools = await client .list_tools ()
66- print (f"tool_0 : { tools [ 0 ]. __dict__ } \n " )
66+ print (f"tools : { tools } \n " )
6767
6868 # Call run_agent tool, pass user input and session information
6969 res = await client .call_tool (
Original file line number Diff line number Diff line change 1717from veadk .a2a .ve_a2a_server import init_app
1818from veadk .tracing .base_tracer import BaseTracer
1919from veadk .tracing .telemetry .opentelemetry_tracer import OpentelemetryTracer
20+ from veadk .runner import Runner
2021from contextlib import asynccontextmanager
2122from fastmcp import FastMCP
2223from fastapi import FastAPI
7273 short_term_memory = short_term_memory ,
7374)
7475
76+ # Add a2a app to fastmcp
77+ runner = Runner (
78+ agent = agent ,
79+ short_term_memory = short_term_memory ,
80+ app_name = app_name ,
81+ user_id = "" ,
82+ )
83+
84+
85+ # mcp server
86+ @a2a_app .post ("/run_agent" , operation_id = "run_agent" , tags = ["mcp" ])
87+ async def run_agent (
88+ user_input : str ,
89+ user_id : str = "unknown_user" ,
90+ session_id : str = "unknown_session" ,
91+ ) -> str :
92+ """
93+ Execute agent with user input and return final output
94+ Args:
95+ user_input: User's input message
96+ user_id: User identifier
97+ session_id: Session identifier
98+ Returns:
99+ Final agent response
100+ """
101+ # Set user_id for runner
102+ runner .user_id = user_id
103+
104+ # Running agent and get final output
105+ final_output = await runner .run (
106+ messages = user_input ,
107+ session_id = session_id ,
108+ )
109+ return final_output
110+
111+
75112mcp = FastMCP .from_fastapi (app = a2a_app , name = app_name , include_tags = {"mcp" })
76113
77114# Create MCP ASGI app
You can’t perform that action at this time.
0 commit comments