fix: resolve golangci-lint errors in anthropic-messages provider
- add nolint comment for canonicalheader rule on X-API-Key header (Anthropic API requires exact casing) - fix golines formatting issues in provider_test.go (split long lines under 120 chars) - fix long comment line in factory_provider.go (split into two lines) Resolves CI linter failures for the anthropic-messages protocol implementation.
This commit is contained in:
parent
c748a86f1e
commit
4e52511704
3 changed files with 9 additions and 5 deletions
|
|
@ -107,7 +107,7 @@ func (p *Provider) Chat(
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("X-API-Key", p.apiKey)
|
req.Header.Set("X-API-Key", p.apiKey) //nolint:canonicalheader // Anthropic API requires exact header name
|
||||||
req.Header.Set("Anthropic-Version", defaultAPIVersion)
|
req.Header.Set("Anthropic-Version", defaultAPIVersion)
|
||||||
|
|
||||||
// Execute request
|
// Execute request
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,8 @@ func TestParseResponseBody(t *testing.T) {
|
||||||
t.Errorf("Usage.PromptTokens = %d, want %d", got.Usage.PromptTokens, tt.want.Usage.PromptTokens)
|
t.Errorf("Usage.PromptTokens = %d, want %d", got.Usage.PromptTokens, tt.want.Usage.PromptTokens)
|
||||||
}
|
}
|
||||||
if got.Usage.CompletionTokens != tt.want.Usage.CompletionTokens {
|
if got.Usage.CompletionTokens != tt.want.Usage.CompletionTokens {
|
||||||
t.Errorf("Usage.CompletionTokens = %d, want %d", got.Usage.CompletionTokens, tt.want.Usage.CompletionTokens)
|
t.Errorf("Usage.CompletionTokens = %d, want %d",
|
||||||
|
got.Usage.CompletionTokens, tt.want.Usage.CompletionTokens)
|
||||||
}
|
}
|
||||||
if got.Usage.TotalTokens != tt.want.Usage.TotalTokens {
|
if got.Usage.TotalTokens != tt.want.Usage.TotalTokens {
|
||||||
t.Errorf("Usage.TotalTokens = %d, want %d", got.Usage.TotalTokens, tt.want.Usage.TotalTokens)
|
t.Errorf("Usage.TotalTokens = %d, want %d", got.Usage.TotalTokens, tt.want.Usage.TotalTokens)
|
||||||
|
|
@ -339,10 +340,12 @@ func TestParseResponseBody(t *testing.T) {
|
||||||
} else {
|
} else {
|
||||||
for i := range got.ToolCalls {
|
for i := range got.ToolCalls {
|
||||||
if got.ToolCalls[i].ID != tt.want.ToolCalls[i].ID {
|
if got.ToolCalls[i].ID != tt.want.ToolCalls[i].ID {
|
||||||
t.Errorf("ToolCalls[%d].ID = %q, want %q", i, got.ToolCalls[i].ID, tt.want.ToolCalls[i].ID)
|
t.Errorf("ToolCalls[%d].ID = %q, want %q",
|
||||||
|
i, got.ToolCalls[i].ID, tt.want.ToolCalls[i].ID)
|
||||||
}
|
}
|
||||||
if got.ToolCalls[i].Name != tt.want.ToolCalls[i].Name {
|
if got.ToolCalls[i].Name != tt.want.ToolCalls[i].Name {
|
||||||
t.Errorf("ToolCalls[%d].Name = %q, want %q", i, got.ToolCalls[i].Name, tt.want.ToolCalls[i].Name)
|
t.Errorf("ToolCalls[%d].Name = %q, want %q",
|
||||||
|
i, got.ToolCalls[i].Name, tt.want.ToolCalls[i].Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ func ExtractProtocol(model string) (protocol, modelID string) {
|
||||||
|
|
||||||
// CreateProviderFromConfig creates a provider based on the ModelConfig.
|
// CreateProviderFromConfig creates a provider based on the ModelConfig.
|
||||||
// It uses the protocol prefix in the Model field to determine which provider to create.
|
// It uses the protocol prefix in the Model field to determine which provider to create.
|
||||||
// Supported protocols: openai, litellm, anthropic, anthropic-messages, antigravity, claude-cli, codex-cli, github-copilot
|
// Supported protocols: openai, litellm, anthropic, anthropic-messages, antigravity,
|
||||||
|
// claude-cli, codex-cli, github-copilot
|
||||||
// Returns the provider, the model ID (without protocol prefix), and any error.
|
// Returns the provider, the model ID (without protocol prefix), and any error.
|
||||||
func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, error) {
|
func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, error) {
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue