File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
cli/services/vefaas/template/src Expand file tree Collapse file tree 2 files changed +35
-3
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
2425
2526
2627class VeA2AServer :
@@ -48,8 +49,39 @@ def build(self) -> FastAPI:
4849 )
4950 app = app_application .build () # build routes
5051
51- # import uvicorn
52- # uvicorn.run(app, host="127.0.0.1", port=8000)
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+
5385 return app
5486
5587
Original file line number Diff line number Diff line change 7272 short_term_memory = short_term_memory ,
7373)
7474
75- mcp = FastMCP .from_fastapi (app = a2a_app , name = app_name )
75+ mcp = FastMCP .from_fastapi (app = a2a_app , name = app_name , include_tags = { "mcp" } )
7676
7777# Create MCP ASGI app
7878mcp_app = mcp .http_app (path = "/" )
You can’t perform that action at this time.
0 commit comments