Skip to content

Commit 6cb0eb4

Browse files
committed
feat: update claude tools calling
1 parent 59d06a5 commit 6cb0eb4

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

relay/channel/claude/dto.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ type ClaudeMessage struct {
3131
}
3232

3333
type Tool struct {
34-
Name string `json:"name"`
35-
Description string `json:"description,omitempty"`
36-
InputSchema InputSchema `json:"input_schema"`
34+
Name string `json:"name"`
35+
Description string `json:"description,omitempty"`
36+
InputSchema map[string]interface{} `json:"input_schema"`
3737
}
3838

3939
type InputSchema struct {

relay/channel/claude/relay-claude.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,21 @@ func RequestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR
6363

6464
for _, tool := range textRequest.Tools {
6565
if params, ok := tool.Function.Parameters.(map[string]any); ok {
66-
claudeTools = append(claudeTools, Tool{
66+
claudeTool := Tool{
6767
Name: tool.Function.Name,
6868
Description: tool.Function.Description,
69-
InputSchema: InputSchema{
70-
Type: params["type"].(string),
71-
Properties: params["properties"],
72-
Required: params["required"],
73-
},
74-
})
69+
}
70+
claudeTool.InputSchema = make(map[string]interface{})
71+
claudeTool.InputSchema["type"] = params["type"].(string)
72+
claudeTool.InputSchema["properties"] = params["properties"]
73+
claudeTool.InputSchema["required"] = params["required"]
74+
for s, a := range params {
75+
if s == "type" || s == "properties" || s == "required" {
76+
continue
77+
}
78+
claudeTool.InputSchema[s] = a
79+
}
80+
claudeTools = append(claudeTools, claudeTool)
7581
}
7682
}
7783

0 commit comments

Comments
 (0)