Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package claude
|
|
|
|
import "github.com/QuantumNous/new-api/relaykit/dto"
|
|
|
|
func MapOpenAIToolChoice(toolChoice any, parallelToolCalls *bool) *dto.ClaudeToolChoice {
|
|
var claudeToolChoice *dto.ClaudeToolChoice
|
|
|
|
if toolChoiceStr, ok := toolChoice.(string); ok {
|
|
switch toolChoiceStr {
|
|
case "auto":
|
|
claudeToolChoice = &dto.ClaudeToolChoice{
|
|
Type: "auto",
|
|
}
|
|
case "required":
|
|
claudeToolChoice = &dto.ClaudeToolChoice{
|
|
Type: "any",
|
|
}
|
|
case "none":
|
|
claudeToolChoice = &dto.ClaudeToolChoice{
|
|
Type: "none",
|
|
}
|
|
}
|
|
} else if toolChoiceMap, ok := toolChoice.(map[string]interface{}); ok {
|
|
if function, ok := toolChoiceMap["function"].(map[string]interface{}); ok {
|
|
if toolName, ok := function["name"].(string); ok {
|
|
claudeToolChoice = &dto.ClaudeToolChoice{
|
|
Type: "tool",
|
|
Name: toolName,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if parallelToolCalls != nil {
|
|
if claudeToolChoice == nil {
|
|
claudeToolChoice = &dto.ClaudeToolChoice{
|
|
Type: "auto",
|
|
}
|
|
}
|
|
if claudeToolChoice.Type != "none" {
|
|
claudeToolChoice.DisableParallelToolUse = !*parallelToolCalls
|
|
}
|
|
}
|
|
|
|
return claudeToolChoice
|
|
}
|