AS AgentScopeAPI 手册 / API Reference

AguiRestController

@RestController public class AguiRestController
源码Source io/agentscope/spring/boot/agui/mvc/AguiRestController.java:41–148

AGUI REST 控制器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.spring.boot.agui.mvc 包。核心成员包括 run、runWithAgentId、handleParseError、AguiRestController。

REST controller for AG-UI protocol endpoints.

This controller exposes the AG-UI run endpoints for Spring MVC applications. It delegates the actual processing to AguiMvcController.

构造器摘要Constructor Summary

构造器Constructor说明Description
public AguiRestController(AguiMvcController aguiMvcController, String pathPrefix, boolean enablePathRouting, AguiRequestBodyParser requestBodyParser)
创建新的AguiRestController。
Creates a new AguiRestController.

方法摘要Method Summary

方法Method说明Description
public SseEmitter run(String body, String agentIdHeader, HttpServletRequest request)
处理AG-UI 运行请求。
Handle an AG-UI run request.
public SseEmitter runWithAgentId(String agentId, String body, String agentIdHeader, HttpServletRequest request)
处理AG-UI 运行请求使用智能体标识,使用 URL 路径。
Handle an AG-UI run request with agent ID in the URL path.
public ResponseEntity<String> handleParseError(JsonException error)
处理解析错误。
Return HTTP 400 for AG-UI request body parsing failures.

构造器详情Constructor Detail

AguiRestController

public AguiRestController(AguiMvcController aguiMvcController, String pathPrefix, boolean enablePathRouting, AguiRequestBodyParser requestBodyParser)

创建新的AguiRestController。

Creates a new AguiRestController.

参数Parameters
名称Name类型Type说明Description
aguiMvcControllerAguiMvcControllerAG-UI MVC 控制器。The AG-UI MVC controller
pathPrefixString路径 Prefix(类型 `String`)。The path prefix for endpoints
enablePathRoutingboolean启用路径路由(类型 `boolean`)。Whether to enable path variable routing
requestBodyParserAguiRequestBodyParser请求正文解析器(类型 `AguiRequestBodyParser`)。The parser used to decode request bodies
源码Source io/agentscope/spring/boot/agui/mvc/AguiRestController.java:58–67

方法详情Method Detail

run

public SseEmitter run(String body, String agentIdHeader, HttpServletRequest request)

处理AG-UI 运行请求。

Handle an AG-UI run request.

参数Parameters
名称Name类型Type说明Description
bodyString原始运行智能体输入 JSON。The raw run agent input JSON
agentIdHeaderString智能体标识来自 HTTP 请求头(可选)。The agent ID from HTTP header (optional)
requestHttpServletRequest请求(类型 `HttpServletRequest`)。The request.
返回Returns SseEmitter
一种SseEmitter 用于流式 AG-UI 事件。An SseEmitter for streaming AG-UI events
源码Source io/agentscope/spring/boot/agui/mvc/AguiRestController.java:84–97

runWithAgentId

public SseEmitter runWithAgentId(String agentId, String body, String agentIdHeader, HttpServletRequest request)

处理AG-UI 运行请求使用智能体标识,使用 URL 路径。

Handle an AG-UI run request with agent ID in the URL path.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent ID from path variable
bodyString原始运行智能体输入 JSON。The raw run agent input JSON
agentIdHeaderString智能体标识来自 HTTP 请求头(可选)。The agent ID from HTTP header (optional)
requestHttpServletRequest请求(类型 `HttpServletRequest`)。The request.
返回Returns SseEmitter
一种SseEmitter 用于流式 AG-UI 事件。An SseEmitter for streaming AG-UI events
源码Source io/agentscope/spring/boot/agui/mvc/AguiRestController.java:109–123

handleParseError

public ResponseEntity<String> handleParseError(JsonException error)

处理解析错误。

Return HTTP 400 for AG-UI request body parsing failures.

参数Parameters
名称Name类型Type说明Description
errorJsonExceptionJSON 解析失败。the JSON parse failure
返回Returns ResponseEntity<String>
返回ResponseEntity。an SSE-compatible bad request response
源码Source io/agentscope/spring/boot/agui/mvc/AguiRestController.java:131–147
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.