AnthropicResponseParser
public class AnthropicResponseParser
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicResponseParser.java:42–285Anthropic 响应解析器,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.anthropic.formatter 包。核心成员包括 parseMessage、parseStreamEvents。
Parses Anthropic API responses (both streaming and non-streaming) into AgentScope ChatResponse objects.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static ChatResponse parseMessage(Message message, Instant startTime)static | 解析消息。 Parse non-streaming Anthropic Message to ChatResponse. |
public static Flux<ChatResponse> parseStreamEvents(Flux<RawMessageStreamEvent> eventFlux, Instant startTime)static | 解析流事件。 Parse streaming Anthropic events to ChatResponse Flux. |
方法详情Method Detail
parseMessage
public static ChatResponse parseMessage(Message message, Instant startTime)
static
解析消息。
Parse non-streaming Anthropic Message to ChatResponse.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Message | 消息(类型 `Message`)。The message. |
startTime | Instant | 启动时间(类型 `Instant`)。The start time. |
ChatResponse返回ChatResponse。Returns chat response.
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicResponseParser.java:49–109parseStreamEvents
public static Flux<ChatResponse> parseStreamEvents(Flux<RawMessageStreamEvent> eventFlux, Instant startTime)
static
解析流事件。
Parse streaming Anthropic events to ChatResponse Flux.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
eventFlux | Flux<RawMessageStreamEvent> | 事件 Flux(类型 `Flux`)。The event flux. |
startTime | Instant | 启动时间(类型 `Instant`)。The start time. |
Flux<ChatResponse>返回Flux。Returns flux.
源码Source
io/agentscope/extensions/model/anthropic/formatter/AnthropicResponseParser.java:124–148