TrinityModelAdapter
public class TrinityModelAdapter extends ChatModelBase
io/agentscope/core/training/backend/TrinityModelAdapter.java:52–185Trinity 模型适配器,对智能体行为进行评测、追踪与可观测性分析。位于 io.agentscope.core.training.backend 包,继承自 ChatModelBase。核心成员包括 doStream、getModelName、getExecutionContext、builder。
Trinity Model Adapter
Lightweight adapter using composition pattern to wrap OpenAIChatModel for:
-
Routing model calls to Trinity Chat API
-
Automatically collecting msg_ids and associating them with RunExecutionContext
Trinity's Chat API is fully compatible with OpenAI format, so OpenAIChatModel can be used directly. This adapter simply intercepts responses and collects msg_id (response.id) for subsequent feedback.
Automated design:
-
Internal component, created and managed by TrainingRouter
-
Automatically collects msg_ids to RunExecutionContext
-
Completely transparent to users
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | TrinityModelAdapter的构建器。 Builder for TrinityModelAdapter |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
protected Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) | 以流式方式执行并返回结果。 Performs the do stream operation. |
public String getModelName() | 获取模型名称。 Returns the model name. |
public RunExecutionContext getExecutionContext() | 获取任务执行上下文。 Get task execution context |
public static Builder builder()static | 创建构建器。 Create Builder |
方法详情Method Detail
doStream
protected Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options)
以流式方式执行并返回结果。
Performs the do stream operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
tools | List<ToolSchema> | 工具列表(类型 `List`)。The tools. |
options | GenerateOptions | 选项(类型 `GenerateOptions`)。The options. |
Flux<ChatResponse>io/agentscope/core/training/backend/TrinityModelAdapter.java:73–99getModelName
public String getModelName()
获取模型名称。
Returns the model name.
Stringio/agentscope/core/training/backend/TrinityModelAdapter.java:101–104getExecutionContext
public RunExecutionContext getExecutionContext()
获取任务执行上下文。
Get task execution context
RunExecutionContextio/agentscope/core/training/backend/TrinityModelAdapter.java:111–113builder
public static Builder builder()
创建构建器。
Create Builder
Builderio/agentscope/core/training/backend/TrinityModelAdapter.java:118–120嵌套类详情Nested Class Detail
Builder
public static class BuilderTrinityModelAdapter的构建器。位于 io.agentscope.core.training.backend 包。核心成员包括 baseUrl、modelName、apiKey、executionContext、build。
Builder for TrinityModelAdapter