| 1 | package openai |
| 2 | |
| 3 | import "reasonix/internal/provider" |
| 4 | |
| 5 | func encodeChatTools(req provider.Request, mimo bool) []chatTool { |
| 6 | var tools []chatTool |
| 7 | for _, t := range req.Tools { |
| 8 | parameters := t.Parameters |
| 9 | if len(parameters) == 0 { |
| 10 | parameters = provider.CanonicalizeSchema(nil) |
| 11 | } |
| 12 | if mimo { |
| 13 | parameters = provider.NormalizeLegacyTupleItemsForDraft202012(parameters) |
| 14 | } |
| 15 | item := chatTool{Type: "function", Function: chatFunction{Name: t.Name, Description: t.Description, Parameters: parameters, Strict: t.Strict}} |
| 16 | item.DeferLoading = t.Deferred |
| 17 | tools = append(tools, item) |
| 18 | } |
| 19 | return tools |
| 20 | } |
| 21 |