ConfigUtils class

Utility class for common configuration transformations

This class provides helper methods for converting between unified LLMConfig and provider-specific configurations, reducing code duplication across providers.

Constructors

ConfigUtils.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

addToolsToRequest(Map<String, dynamic> requestBody, List<Tool>? tools, ToolChoice? toolChoice) → void
Add tools to request body if provided
buildAnthropicHeaders(String apiKey) Map<String, String>
Build Anthropic-compatible headers
buildCommonParams(LLMConfig config) Map<String, dynamic>
Extract common request parameters from LLMConfig
buildHeaders({required String apiKey, required String authHeaderName, String? authPrefix, Map<String, String>? additionalHeaders}) Map<String, String>
Extract common HTTP headers from config
buildOpenAIHeaders(String apiKey) Map<String, String>
Build OpenAI-compatible headers
convertMessagesToAnthropic(List<ChatMessage> messages) List<Map<String, dynamic>>
Convert ChatMessage list to Anthropic format
convertMessagesToOpenAI(List<ChatMessage> messages, String? systemPrompt) List<Map<String, dynamic>>
Convert ChatMessage list to OpenAI format
extractSystemPrompt(List<ChatMessage> messages, String? configSystemPrompt) String?
Extract system prompt from messages or config
getExtensionOrDefault<T>(LLMConfig config, String key, T defaultValue) → T
Get extension value with type safety and default
getRequestTimeout(LLMConfig config) Duration
Build request timeout from config
normalizeBaseUrl(String baseUrl) String
Normalize base URL to ensure it ends with a slash
validateRequiredFields(LLMConfig config, List<String> requiredFields) → void
Validate required configuration fields