JevModelRouterMiddleware
public final class JevModelRouterMiddleware implements MiddlewareBase
io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:52–272Jev 模型路由器中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.extensions.judge.jev.example 包,实现 MiddlewareBase。核心成员包括 builder、order、onAgent、onModelCall、decision。
Selects one of the configured models with Jev before the agent's model call.
Routing happens in two hooks: #onAgent asks Jev once per agent invocation (using the
latest user message) and stores the result in RuntimeContext; #onModelCall
replaces ModelCallInput.model on every subsequent model call in that invocation. This
means an intermediate tool result cannot cause the agent to switch models mid-run. When the
decision is unusable (no user text, confidence below threshold, Jev failure while
failOpen is set, or an unrecognized answer), the model configured on the agent is used
as the fallback.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
ModelChoice | 记录record | 承载模型选项数据的记录类型。 A model candidate and the routing criteria sent to Jev. |
RoutingDecision | 记录record | 承载路由决策数据的记录类型。 The selected model and the calibrated values returned by Jev. |
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.extensions.judge.jev.example that evaluates agent behaviour and records tracing and telemetry data. |
方法摘要Method Summary
方法详情Method Detail
builder
public static Builder builder(JevClient client)
返回构建器实例。
Performs the builder operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | JevClient | 客户端(类型 `JevClient`)。The client. |
Builderio/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:71–74order
public int order()
返回顺序。
Returns the order.
intio/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:80–83onAgent
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Performs the on agent operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | AgentInput | 输入消息(类型 `AgentInput`)。The input. |
next | Function<AgentInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:85–110onModelCall
public Flux<AgentEvent> onModelCall(Agent agent, RuntimeContext ctx, ModelCallInput input, Function<ModelCallInput, Flux<AgentEvent>> next)
处理模型调用事件。
Performs the on model call operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | ModelCallInput | 输入消息(类型 `ModelCallInput`)。The input. |
next | Function<ModelCallInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:112–125decision
public static RoutingDecision decision(RuntimeContext ctx)
设置决策。
Returns the most recent routing decision for the runtime context.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ctx | RuntimeContext | 运行时上下文,可能为`null`。the runtime context, may be `null` |
RoutingDecisionio/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:133–135嵌套类详情Nested Class Detail
ModelChoice
public record ModelChoice(Model model, String criteria)承载模型选项数据的记录类型。位于 io.agentscope.extensions.judge.jev.example 包。核心成员包括 model、criteria、ModelChoice。
A model candidate and the routing criteria sent to Jev.
RoutingDecision
public record RoutingDecision( Model model, Map<String, Double> probabilities, Double confidence)承载路由决策数据的记录类型。位于 io.agentscope.extensions.judge.jev.example 包。核心成员包括 model、probabilities、confidence、RoutingDecision。
The selected model and the calibrated values returned by Jev.
Builder
public static final class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.judge.jev.example 包。核心成员包括 choice、choices、instructions、confidenceThreshold、failOpen、build。
A class in io.agentscope.extensions.judge.jev.example that evaluates agent behaviour and records tracing and telemetry data. Declared in io.agentscope.extensions.judge.jev.example.