mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
feat: update claude tools calling
This commit is contained in:
parent
59d06a5576
commit
6cb0eb4b39
@ -33,7 +33,7 @@ type ClaudeMessage struct {
|
|||||||
type Tool struct {
|
type Tool struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
InputSchema InputSchema `json:"input_schema"`
|
InputSchema map[string]interface{} `json:"input_schema"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputSchema struct {
|
type InputSchema struct {
|
||||||
|
@ -63,15 +63,21 @@ func RequestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR
|
|||||||
|
|
||||||
for _, tool := range textRequest.Tools {
|
for _, tool := range textRequest.Tools {
|
||||||
if params, ok := tool.Function.Parameters.(map[string]any); ok {
|
if params, ok := tool.Function.Parameters.(map[string]any); ok {
|
||||||
claudeTools = append(claudeTools, Tool{
|
claudeTool := Tool{
|
||||||
Name: tool.Function.Name,
|
Name: tool.Function.Name,
|
||||||
Description: tool.Function.Description,
|
Description: tool.Function.Description,
|
||||||
InputSchema: InputSchema{
|
}
|
||||||
Type: params["type"].(string),
|
claudeTool.InputSchema = make(map[string]interface{})
|
||||||
Properties: params["properties"],
|
claudeTool.InputSchema["type"] = params["type"].(string)
|
||||||
Required: params["required"],
|
claudeTool.InputSchema["properties"] = params["properties"]
|
||||||
},
|
claudeTool.InputSchema["required"] = params["required"]
|
||||||
})
|
for s, a := range params {
|
||||||
|
if s == "type" || s == "properties" || s == "required" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
claudeTool.InputSchema[s] = a
|
||||||
|
}
|
||||||
|
claudeTools = append(claudeTools, claudeTool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user