接口 Model
- 所有已知实现类:
ChatModelBase
public interface Model
-
方法概要
修饰符和类型方法说明default intReturns the model's context window size in tokens, or0if unknown.Get model name for logging and identification.reactor.core.publisher.Flux<ChatResponse> stream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses.default booleanWhether this model supports native structured output (response_formatwithjson_schema).default booleanWhether this model correctly handles native structured output (response_formatwithjson_schema) when tools are also present in the request.
-
方法详细资料
-
stream
reactor.core.publisher.Flux<ChatResponse> stream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses. The model internally handles message formatting using its configured formatter.- 参数:
messages- AgentScope messages to send to the modeltools- Optional list of tool schemas (null or empty if no tools)options- Optional generation options (null to use defaults)- 返回:
- Flux stream of chat responses
-
getModelName
String getModelName()Get model name for logging and identification.- 返回:
- model name
-
supportsNativeStructuredOutput
default boolean supportsNativeStructuredOutput()Whether this model supports native structured output (response_formatwithjson_schema). Whentrue, the agent can pass the output schema directly to the model viaGenerateOptions.getResponseFormat()instead of injecting a syntheticgenerate_responsetool.- 返回:
trueif the model supports native structured output- 另请参阅:
-
supportsNativeStructuredOutputWithTools
default boolean supportsNativeStructuredOutputWithTools()Whether this model correctly handles native structured output (response_formatwithjson_schema) when tools are also present in the request.Some OpenAI-compatible providers prioritise the
response_formatconstraint over tool invocations, causing the model to produce the structured JSON directly and skip tool calling entirely. When this method returnsfalseand tools are present, the agent falls back to the syntheticgenerate_responsetool approach, which is fully compatible with the ReAct tool-calling loop.Defaults to
supportsNativeStructuredOutput().- 返回:
trueif the model handlesresponse_formatalongside tools correctly
-
getContextWindowSize
default int getContextWindowSize()Returns the model's context window size in tokens, or0if unknown.Used by the compaction middleware to dynamically compute when to trigger conversation summarization. Implementations should return the total context window (input + output) for the configured model.
- 返回:
- context window size in tokens, or
0if not available
-