Merge pull request #2226 from QuantumNous/omit-anthropic_beta-empty
Some checks failed
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (amd64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (arm64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Create multi-arch manifests (Docker Hub) (push) Has been cancelled
Build Electron App / build (windows-latest) (push) Has been cancelled
Build Electron App / release (push) Has been cancelled
Release (Linux, macOS, Windows) / Linux Release (push) Has been cancelled
Release (Linux, macOS, Windows) / macOS Release (push) Has been cancelled
Release (Linux, macOS, Windows) / Windows Release (push) Has been cancelled

fix(relay/channel/aws): 修复AnthropicBeta字段的omitempty处理
This commit is contained in:
Seefs 2025-11-14 16:55:20 +08:00 committed by GitHub
commit f8a69ec8f3

View File

@ -12,7 +12,7 @@ import (
type AwsClaudeRequest struct {
// AnthropicVersion should be "bedrock-2023-05-31"
AnthropicVersion string `json:"anthropic_version"`
AnthropicBeta json.RawMessage `json:"anthropic_beta"`
AnthropicBeta json.RawMessage `json:"anthropic_beta,omitempty"`
System any `json:"system,omitempty"`
Messages []dto.ClaudeMessage `json:"messages"`
MaxTokens uint `json:"max_tokens,omitempty"`
@ -40,7 +40,10 @@ func formatRequest(requestBody io.Reader, requestHeader http.Header) (*AwsClaude
if err != nil {
return nil, err
}
awsClaudeRequest.AnthropicBeta = json.RawMessage(betaJson)
var tempArray []string
if err := json.Unmarshal(betaJson, &tempArray); err == nil && len(tempArray) != 0 && len(betaJson) > 0 {
awsClaudeRequest.AnthropicBeta = json.RawMessage(betaJson)
}
}
return &awsClaudeRequest, nil
}