接口 Model

所有已知实现类:
ChatModelBase

public interface Model
  • 方法详细资料

    • 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 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
    • getModelName

      String getModelName()
      Get model name for logging and identification.
      返回:
      model name
    • supportsNativeStructuredOutput

      default boolean supportsNativeStructuredOutput()
      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.
      返回:
      true if the model supports native structured output
      另请参阅:
    • supportsNativeStructuredOutputWithTools

      default boolean supportsNativeStructuredOutputWithTools()
      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 supportsNativeStructuredOutput().

      返回:
      true if the model handles response_format alongside tools correctly
    • getContextWindowSize

      default int getContextWindowSize()
      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.

      返回:
      context window size in tokens, or 0 if not available