classifyParams splits tool call arguments into path replacements, query parameters, and body parameters based on the OpenAPI path template and "body_" prefix convention.
(params openAPICallArgs)
| 508 | // classifyParams splits tool call arguments into path replacements, query parameters, |
| 509 | // and body parameters based on the OpenAPI path template and "body_" prefix convention. |
| 510 | func (h *openAPIHandler) classifyParams(params openAPICallArgs) (string, url.Values, map[string]any) { |
| 511 | resolvedPath := h.path |
| 512 | queryParams := url.Values{} |
| 513 | bodyParams := map[string]any{} |
| 514 | |
| 515 | for key, value := range params { |
| 516 | // Path parameter? |
| 517 | placeholder := "{" + key + "}" |
| 518 | if strings.Contains(h.path, placeholder) { |
| 519 | resolvedPath = strings.ReplaceAll(resolvedPath, placeholder, url.PathEscape(fmt.Sprintf("%v", value))) |
| 520 | continue |
| 521 | } |
| 522 | |
| 523 | // Body parameter? (prefixed with "body_") |
| 524 | if after, ok := strings.CutPrefix(key, "body_"); ok { |
| 525 | bodyParams[after] = value |
| 526 | continue |
| 527 | } |
| 528 | |
| 529 | // Otherwise it's a query parameter. |
| 530 | queryParams.Set(key, fmt.Sprintf("%v", value)) |
| 531 | } |
| 532 | |
| 533 | return resolvedPath, queryParams, bodyParams |
| 534 | } |