AnthropicConfig.fromLLMConfig constructor
AnthropicConfig.fromLLMConfig(
- LLMConfig config
Create AnthropicConfig from unified LLMConfig
Implementation
factory AnthropicConfig.fromLLMConfig(LLMConfig config) {
// Handle web search configuration
List<Tool>? tools = config.tools;
// Check for webSearchEnabled flag
final webSearchEnabled = config.getExtension<bool>('webSearchEnabled');
if (webSearchEnabled == true) {
tools = _addWebSearchTool(tools, null);
}
// Check for webSearchConfig and convert to web_search tool
final webSearchConfig =
config.getExtension<WebSearchConfig>('webSearchConfig');
if (webSearchConfig != null) {
tools = _addWebSearchTool(tools, webSearchConfig);
}
return AnthropicConfig(
apiKey: config.apiKey!,
baseUrl: config.baseUrl,
model: config.model,
maxTokens: config.maxTokens,
temperature: config.temperature,
systemPrompt: config.systemPrompt,
timeout: config.timeout,
topP: config.topP,
topK: config.topK,
tools: tools,
toolChoice: config.toolChoice,
// Common parameters
stopSequences: config.stopSequences,
user: config.user,
serviceTier: config.serviceTier,
// Anthropic-specific extensions
reasoning: config.getExtension<bool>('reasoning') ?? false,
thinkingBudgetTokens: config.getExtension<int>('thinkingBudgetTokens'),
interleavedThinking:
config.getExtension<bool>('interleavedThinking') ?? false,
originalConfig: config,
);
}