类 AnthropicChatModel
java.lang.Object
io.agentscope.core.model.ChatModelBase
io.agentscope.core.model.AnthropicChatModel
- 所有已实现的接口:
Model
Anthropic Chat Model implementation using the official Anthropic Java SDK.
This implementation provides complete integration with Anthropic's Messages API, including tool calling, streaming support, and extended thinking features.
Important notes:
- System messages are handled via the system parameter, not as messages
- Tool results must be in separate user messages
- Supports Claude models (claude-3-*, claude-sonnet-*, etc.)
-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明AnthropicChatModel(String baseUrl, String apiKey, String modelName, boolean streamEnabled, GenerateOptions defaultOptions, AnthropicBaseFormatter formatter) Creates a new Anthropic chat model instance. -
方法概要
修饰符和类型方法说明static AnthropicChatModel.Builderbuilder()Creates a builder for constructing AnthropicChatModel instances.protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from Anthropic's API.Gets the model name for logging and identification.从类继承的方法 io.agentscope.core.model.ChatModelBase
stream
-
构造器详细资料
-
AnthropicChatModel
public AnthropicChatModel(String baseUrl, String apiKey, String modelName, boolean streamEnabled, GenerateOptions defaultOptions, AnthropicBaseFormatter formatter) Creates a new Anthropic chat model instance.- 参数:
baseUrl- the base URL for Anthropic API (null for default)apiKey- the API key for authentication (null to load from ANTHROPIC_API_KEY env var)modelName- the model name to use (e.g., "claude-sonnet-4-5-20250929")streamEnabled- whether streaming should be enableddefaultOptions- default generation optionsformatter- the message formatter to use (null for default Anthropic formatter)
-
-
方法详细资料
-
doStream
protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from Anthropic's API.This method internally handles message formatting using the configured formatter. It supports both streaming and non-streaming modes based on the streamEnabled setting.
Supports timeout and retry configuration through GenerateOptions.
- 指定者:
doStream在类中ChatModelBase- 参数:
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
Gets the model name for logging and identification.- 返回:
- the model name
-
builder
Creates a builder for constructing AnthropicChatModel instances.- 返回:
- a new builder
-