A2aController
@RestController @RequestMapping("/a2a") public class A2aController
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:45–176A 2 a 控制器,支持智能体之间的发现、委派与协作。位于 io.agentscope.runtime.protocol.a2a.controller 包。核心成员包括 handleRequest、isStreamingRequest、handleStreamRequest、handleNonStreamRequest、A2aController。
A class in io.agentscope.runtime.protocol.a2a.controller that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.runtime.protocol.a2a.controller.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public A2aController(Runner runner, AgentCard agentCard, ObjectProvider<ProtocolConfig> protocolConfigs) | 初始化 `A2aController` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Object handleRequest(String body, HttpServletRequest httpRequest) | 处理请求。 Performs the handle request operation. |
protected boolean isStreamingRequest(String requestBody, ServerCallContext context) | 判断是否流式请求。 Returns whether the streaming request. |
protected Flux<ServerSentEvent<String>> handleStreamRequest(String body, ServerCallContext context) throws JsonProcessingException | 处理流请求。 Performs the handle stream request operation. |
protected JSONRPCResponse<?> handleNonStreamRequest(String body, ServerCallContext context) throws JsonProcessingException | 处理 `handleNonStreamRequest`。 Performs the handle non stream request operation. |
构造器详情Constructor Detail
A2aController
public A2aController(Runner runner, AgentCard agentCard, ObjectProvider<ProtocolConfig> protocolConfigs)
初始化 A2aController 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runner | Runner | 运行器(类型 `Runner`)。The runner. |
agentCard | AgentCard | 智能体卡片(类型 `AgentCard`)。The agent card. |
protocolConfigs | ObjectProvider<ProtocolConfig> | 协议 Configs(类型 `ObjectProvider`)。The protocol configs. |
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:53–55方法详情Method Detail
handleRequest
public Object handleRequest(String body, HttpServletRequest httpRequest)
处理请求。
Performs the handle request operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
body | String | 正文(类型 `String`)。The body. |
httpRequest | HttpServletRequest | HTTP 请求(类型 `HttpServletRequest`)。The http request. |
Object返回对象。Returns object.
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:57–78isStreamingRequest
protected boolean isStreamingRequest(String requestBody, ServerCallContext context)
判断是否流式请求。
Returns whether the streaming request.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
requestBody | String | 请求正文(类型 `String`)。The request body. |
context | ServerCallContext | 上下文(类型 `ServerCallContext`)。The context. |
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:80–95handleStreamRequest
protected Flux<ServerSentEvent<String>> handleStreamRequest(String body, ServerCallContext context) throws JsonProcessingException
处理流请求。
Performs the handle stream request operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
body | String | 正文(类型 `String`)。The body. |
context | ServerCallContext | 上下文(类型 `ServerCallContext`)。The context. |
Flux<ServerSentEvent<String>>返回Flux>。Returns flux.
JsonProcessingException可能抛出 `JsonProcessingException`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:97–111handleNonStreamRequest
protected JSONRPCResponse<?> handleNonStreamRequest(String body, ServerCallContext context) throws JsonProcessingException
处理 handleNonStreamRequest。
Performs the handle non stream request operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
body | String | 正文(类型 `String`)。The body. |
context | ServerCallContext | 上下文(类型 `ServerCallContext`)。The context. |
JSONRPCResponse<?>返回JSONRPCResponse。Returns JSON RPC response.
JsonProcessingException可能抛出 `JsonProcessingException`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/runtime/protocol/a2a/controller/A2aController.java:137–157