Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed). - CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels - New CheckinButton in both authenticated and public headers (Turnstile supported) - New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset - New /docs 12-section beginner guide with anchor navigation - New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi) - README: document custom features, live demo https://ai.88531.cn
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
|
|
}
|