fix: aws
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
package aws
|
package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/QuantumNous/new-api/common"
|
"github.com/QuantumNous/new-api/common"
|
||||||
"github.com/QuantumNous/new-api/dto"
|
"github.com/QuantumNous/new-api/dto"
|
||||||
|
"github.com/QuantumNous/new-api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AwsClaudeRequest struct {
|
type AwsClaudeRequest struct {
|
||||||
@@ -34,17 +37,19 @@ func formatRequest(requestBody io.Reader, requestHeader http.Header) (*AwsClaude
|
|||||||
awsClaudeRequest.AnthropicVersion = "bedrock-2023-05-31"
|
awsClaudeRequest.AnthropicVersion = "bedrock-2023-05-31"
|
||||||
|
|
||||||
// check header anthropic-beta
|
// check header anthropic-beta
|
||||||
anthropicBetaValues := requestHeader.Values("anthropic-beta")
|
anthropicBetaValues := requestHeader.Get("anthropic-beta")
|
||||||
if len(anthropicBetaValues) > 0 {
|
if len(anthropicBetaValues) > 0 {
|
||||||
betaJson, err := json.Marshal(anthropicBetaValues)
|
var tempArray []string
|
||||||
|
tempArray = strings.Split(anthropicBetaValues, ",")
|
||||||
|
if len(tempArray) > 0 {
|
||||||
|
betaJson, err := json.Marshal(tempArray)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var tempArray []string
|
awsClaudeRequest.AnthropicBeta = betaJson
|
||||||
if err := json.Unmarshal(betaJson, &tempArray); err == nil && len(tempArray) != 0 && len(betaJson) > 0 {
|
|
||||||
awsClaudeRequest.AnthropicBeta = json.RawMessage(betaJson)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.LogJson(context.Background(), "json", awsClaudeRequest)
|
||||||
return &awsClaudeRequest, nil
|
return &awsClaudeRequest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user