| 1 | package anthropic |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | |
| 6 | "reasonix/internal/provider" |
| 7 | ) |
| 8 | |
| 9 | func encodeAnthTools(c *client, req provider.Request) []anthTool { |
| 10 | var tools []anthTool |
| 11 | if c.search.NativeEnabled && !c.search.ClientEnabled { |
| 12 | tools = append(tools, anthTool{Type: "web_search_20250305", Name: "web_search"}) |
| 13 | } |
| 14 | for _, t := range req.Tools { |
| 15 | schema := t.Parameters |
| 16 | if len(schema) == 0 { |
| 17 | schema = json.RawMessage(`{"type":"object","properties":{}}`) |
| 18 | } |
| 19 | if c.mimo { |
| 20 | schema = provider.NormalizeLegacyTupleItemsForDraft202012(schema) |
| 21 | } |
| 22 | item := anthTool{Name: t.Name, Description: t.Description, InputSchema: schema} |
| 23 | if !c.deepseek && provider.IsFirstPartyAnthropic(c.baseURL) { |
| 24 | item.Strict = t.Strict |
| 25 | item.DeferLoading = t.Deferred |
| 26 | } |
| 27 | tools = append(tools, item) |
| 28 | } |
| 29 | return tools |
| 30 | } |
| 31 |