( ctx context.Context, makeRequest func(context.Context, *http.Client) (*http.Response, error), timeout time.Duration, )
| 169 | "type": "function", |
| 170 | "function": map[string]any{ |
| 171 | "name": getString(tool, "name"), |
| 172 | "description": getString(tool, "description"), |
| 173 | "parameters": parameters, |
| 174 | }, |
| 175 | }) |
| 176 | } |
| 177 | |
| 178 | return openaiTools |
| 179 | } |
| 180 | |
| 181 | type LLMClientBase struct { |
| 182 | APIKey string |
| 183 | BaseURL string |
| 184 | Model string |
| 185 | ProviderName string |
| 186 | MaxTokens int |
| 187 | ThinkingBudgetTokens *int |
| 188 | RetryConfig RetryConfig |
| 189 | HTTPClient *http.Client |
| 190 | } |
| 191 | |
| 192 | func NewLLMClientBase( |
| 193 | apiKey string, |
| 194 | baseURL string, |
| 195 | model string, |
| 196 | maxTokens int, |
| 197 | thinkingBudgetTokens *int, |
| 198 | retryConfig *RetryConfig, |
| 199 | ) (LLMClientBase, error) { |
| 200 | if apiKey == "" { |
| 201 | return LLMClientBase{}, fmt.Errorf("API key must be configured explicitly") |
| 202 | } |
| 203 | if baseURL == "" { |
| 204 | return LLMClientBase{}, fmt.Errorf("API base URL must be configured explicitly") |
| 205 | } |
| 206 | if model == "" { |
| 207 | model = "claude-sonnet-4-6" |
| 208 | } |
| 209 | if maxTokens == 0 { |
| 210 | maxTokens = 16000 |
| 211 | } |
| 212 | |
| 213 | cfg := DefaultRetryConfig() |
| 214 | if retryConfig != nil { |
| 215 | cfg = *retryConfig |
| 216 | } |
| 217 | |
| 218 | return LLMClientBase{ |
| 219 | APIKey: apiKey, |
| 220 | BaseURL: strings.TrimRight(baseURL, "/"), |
| 221 | Model: model, |
| 222 | ProviderName: model, |
| 223 | MaxTokens: maxTokens, |
| 224 | ThinkingBudgetTokens: thinkingBudgetTokens, |
| 225 | RetryConfig: cfg, |
| 226 | HTTPClient: &http.Client{}, |
| 227 | }, nil |
| 228 | } |
no test coverage detected