| 18 | } |
| 19 | |
| 20 | func toComment(tool *tools.Tool) string { |
| 21 | var comment strings.Builder |
| 22 | |
| 23 | inputSchema, _ := json.MarshalIndent(tool.Parameters, " * ", " ") |
| 24 | outputSchema, _ := json.MarshalIndent(tool.OutputSchema, " * ", " ") |
| 25 | |
| 26 | comment.WriteString("\n/**\n") |
| 27 | for line := range strings.SplitSeq(tool.Description, "\n") { |
| 28 | comment.WriteString(" * " + strings.TrimSpace(line) + "\n") |
| 29 | } |
| 30 | comment.WriteString(" * \n") |
| 31 | comment.WriteString(" * @param args - Input object containing the parameters.\n") |
| 32 | comment.WriteString(" * @returns Output - The result of the function execution.\n") |
| 33 | comment.WriteString(" *\n") |
| 34 | comment.WriteString(" * Where Input follows the following JSON schema:\n") |
| 35 | comment.WriteString(" * " + string(inputSchema) + "\n") |
| 36 | comment.WriteString(" *\n") |
| 37 | comment.WriteString(" * And Output follows the following JSON schema:\n") |
| 38 | comment.WriteString(" * " + string(outputSchema) + "\n") |
| 39 | comment.WriteString(" */\n") |
| 40 | |
| 41 | return comment.String() |
| 42 | } |