类 ChatModelBase
- 所有已实现的接口:
Model
This class provides common functionality for model including basic model invocation and tracing.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected abstract reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Internal implementation for streaming chat completion responses.intReturns the model's context window size in tokens, or0if unknown.protected voidsetContextWindowSize(int contextWindowSize) protected voidsetNativeStructuredOutput(boolean nativeStructuredOutput) protected voidsetNativeStructuredOutputWithTools(boolean nativeStructuredOutputWithTools) final reactor.core.publisher.Flux<ChatResponse> stream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses.booleanWhether this model supports native structured output (response_formatwithjson_schema).booleanWhether this model correctly handles native structured output (response_formatwithjson_schema) when tools are also present in the request.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.model.Model
getModelName
-
构造器详细资料
-
ChatModelBase
public ChatModelBase()
-
-
方法详细资料
-
getContextWindowSize
public int getContextWindowSize()从接口复制的说明:ModelReturns 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.
- 指定者:
getContextWindowSize在接口中Model- 返回:
- context window size in tokens, or
0if not available
-
setContextWindowSize
protected void setContextWindowSize(int contextWindowSize) -
supportsNativeStructuredOutput
public boolean supportsNativeStructuredOutput()从接口复制的说明:ModelWhether 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.- 指定者:
supportsNativeStructuredOutput在接口中Model- 返回:
trueif the model supports native structured output- 另请参阅:
-
setNativeStructuredOutput
protected void setNativeStructuredOutput(boolean nativeStructuredOutput) -
supportsNativeStructuredOutputWithTools
public boolean supportsNativeStructuredOutputWithTools()从接口复制的说明:ModelWhether 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
Model.supportsNativeStructuredOutput().- 指定者:
supportsNativeStructuredOutputWithTools在接口中Model- 返回:
trueif the model handlesresponse_formatalongside tools correctly
-
setNativeStructuredOutputWithTools
protected void setNativeStructuredOutputWithTools(boolean nativeStructuredOutputWithTools) -
stream
public final 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.Tracing data will be captured once telemetry is enabled.
-
doStream
protected abstract reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Internal implementation for streaming chat completion responses. Subclasses must implement their specific logic here.- 参数:
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
-