类 ChatModelBase

java.lang.Object
io.agentscope.core.model.ChatModelBase
所有已实现的接口:
Model

public abstract class ChatModelBase extends Object implements Model
Abstract base class for all models in the AgentScope framework.

This class provides common functionality for model including basic model invocation and tracing.

  • 构造器详细资料

    • ChatModelBase

      public ChatModelBase()
  • 方法详细资料

    • getContextWindowSize

      public int getContextWindowSize()
      从接口复制的说明: Model
      Returns the model's context window size in tokens, or 0 if 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 0 if not available
    • setContextWindowSize

      protected void setContextWindowSize(int contextWindowSize)
    • supportsNativeStructuredOutput

      public boolean supportsNativeStructuredOutput()
      从接口复制的说明: Model
      Whether this model supports native structured output (response_format with json_schema). When true, the agent can pass the output schema directly to the model via GenerateOptions.getResponseFormat() instead of injecting a synthetic generate_response tool.
      指定者:
      supportsNativeStructuredOutput 在接口中 Model
      返回:
      true if the model supports native structured output
      另请参阅:
    • setNativeStructuredOutput

      protected void setNativeStructuredOutput(boolean nativeStructuredOutput)
    • supportsNativeStructuredOutputWithTools

      public boolean supportsNativeStructuredOutputWithTools()
      从接口复制的说明: Model
      Whether this model correctly handles native structured output (response_format with json_schema) when tools are also present in the request.

      Some OpenAI-compatible providers prioritise the response_format constraint over tool invocations, causing the model to produce the structured JSON directly and skip tool calling entirely. When this method returns false and tools are present, the agent falls back to the synthetic generate_response tool approach, which is fully compatible with the ReAct tool-calling loop.

      Defaults to Model.supportsNativeStructuredOutput().

      指定者:
      supportsNativeStructuredOutputWithTools 在接口中 Model
      返回:
      true if the model handles response_format alongside 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.

      指定者:
      stream 在接口中 Model
      参数:
      messages - AgentScope messages to send to the model
      tools - Optional list of tool schemas (null or empty if no tools)
      options - Optional generation options (null to use defaults)
      返回:
      Flux stream of chat responses
    • 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 model
      tools - Optional list of tool schemas (null or empty if no tools)
      options - Optional generation options (null to use defaults)
      返回:
      Flux stream of chat responses