AS AgentScopeAPI 手册 / API Reference

JevModelRouterMiddleware

public final class JevModelRouterMiddleware implements MiddlewareBase
源码Source io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:52–272

Jev 模型路由器中间件,在智能体执行流程中提供横切扩展。位于 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说明Description
public static Builder builder(JevClient client)
static
返回构建器实例。
Performs the builder operation.
public int order()
返回顺序。
Returns the order.
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Performs the on agent operation.
public Flux<AgentEvent> onModelCall(Agent agent, RuntimeContext ctx, ModelCallInput input, Function<ModelCallInput, Flux<AgentEvent>> next)
处理模型调用事件。
Performs the on model call operation.
public static RoutingDecision decision(RuntimeContext ctx)
static
设置决策。
Returns the most recent routing decision for the runtime context.

方法详情Method Detail

builder

public static Builder builder(JevClient client)
static

返回构建器实例。

Performs the builder operation.

参数Parameters
名称Name类型Type说明Description
clientJevClient客户端(类型 `JevClient`)。The client.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:71–74

order

public int order()

返回顺序。

Returns the order.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:80–83

onAgent

public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)

处理智能体事件。

Performs the on agent operation.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
inputAgentInput输入消息(类型 `AgentInput`)。The input.
nextFunction<AgentInput, Flux<AgentEvent>>下一个(类型 `Function >`)。The next.
返回Returns Flux<AgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:85–110

onModelCall

public Flux<AgentEvent> onModelCall(Agent agent, RuntimeContext ctx, ModelCallInput input, Function<ModelCallInput, Flux<AgentEvent>> next)

处理模型调用事件。

Performs the on model call operation.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
inputModelCallInput输入消息(类型 `ModelCallInput`)。The input.
nextFunction<ModelCallInput, Flux<AgentEvent>>下一个(类型 `Function >`)。The next.
返回Returns Flux<AgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/extensions/judge/jev/example/JevModelRouterMiddleware.java:112–125

decision

public static RoutingDecision decision(RuntimeContext ctx)
static

设置决策。

Returns the most recent routing decision for the runtime context.

参数Parameters
名称Name类型Type说明Description
ctxRuntimeContext运行时上下文,可能为`null`。the runtime context, may be `null`
返回Returns RoutingDecision
返回RoutingDecision。the decision, or `null` when the router has not run
源码Source io/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.

继承成员Inherited Members

继承自Methods inherited from MiddlewareBase
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.