AguiEventEncoder
public class AguiEventEncoder
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:33–105AGUI 事件 Encoder,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.agui.encoder 包。核心成员包括 encode、encodeToJson、encodeComment、keepAlive、AguiEventEncoder。
Encoder for AG-UI events to Server-Sent Events (SSE) format.
This encoder serializes AG-UI events to the SSE wire format:
data: {"type":"EVENT_TYPE",...}\n\n
The encoder is thread-safe and can be shared across multiple requests.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public AguiEventEncoder() | 创建新的AguiEventEncoder。 Creates a new AguiEventEncoder. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String encode(AguiEvent event) | 设置该参数。 Encode an AG-UI event to SSE format. |
public String encodeToJson(AguiEvent event) | 执行到 JSON。 Encode an AG-UI event to JSON string only (without SSE wrapper). |
public String encodeComment(String comment) | 执行 `encodeComment`。 Encode a comment in SSE format. |
public String keepAlive() | 返回 `keepAlive` 结果。 Generate a keep-alive comment. |
构造器详情Constructor Detail
AguiEventEncoder
public AguiEventEncoder()
创建新的AguiEventEncoder。
Creates a new AguiEventEncoder.
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:38方法详情Method Detail
encode
public String encode(AguiEvent event)
设置该参数。
Encode an AG-UI event to SSE format.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | AguiEvent | 事件(类型 `AguiEvent`)。The event to encode |
String返回字符串结果。The SSE-formatted string
AguiException.EncodingException可能抛出 `AguiException.EncodingException`。if the event cannot be serialized
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:52–59encodeToJson
public String encodeToJson(AguiEvent event)
执行到 JSON。
Encode an AG-UI event to JSON string only (without SSE wrapper).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | AguiEvent | 事件(类型 `AguiEvent`)。The event to encode |
String返回字符串结果。The JSON string with leading space for SSE compatibility
AguiException.EncodingException可能抛出 `AguiException.EncodingException`。if the event cannot be serialized
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:73–80encodeComment
public String encodeComment(String comment)
执行 encodeComment。
Encode a comment in SSE format.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
comment | String | comment(类型 `String`)。The comment text |
String返回字符串结果。The SSE-formatted comment
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:93–95keepAlive
public String keepAlive()
返回 keepAlive 结果。
Generate a keep-alive comment.
String返回字符串结果。An SSE keep-alive comment
源码Source
io/agentscope/core/agui/encoder/AguiEventEncoder.java:102–104