(tool: Tool)
| 369 | } |
| 370 | |
| 371 | function convertToToolCommandString(tool: Tool): string { |
| 372 | // convert a tool into a schema which is compatible ti toolCommandChat |
| 373 | const args: YamlRepresentation = {}; |
| 374 | |
| 375 | const requiredProperties = new Set(tool.parameters.required || []); |
| 376 | |
| 377 | // Loop over each property in the tool's parameters |
| 378 | for (const key in tool.parameters.properties) { |
| 379 | const param = tool.parameters.properties[key]; |
| 380 | // Check if the key is in the list of required properties |
| 381 | const isRequired = requiredProperties.has(key); |
| 382 | // If the property is required, use the key as is, otherwise add a "?" to the key |
| 383 | if (param.description) { |
| 384 | const descriptionKey = `# ${key} description`; |
| 385 | args[descriptionKey] = param.description.replace(/\n/g, ' '); |
| 386 | } |
| 387 | const argKey = isRequired ? key : `${key}?`; |
| 388 | args[argKey] = param.type; |
| 389 | } |
| 390 | |
| 391 | const objrepr: YamlRepresentation = { |
| 392 | '# description': tool.description.replace(/\n/g, ' '), |
| 393 | name: tool.name, |
| 394 | args, |
| 395 | }; |
| 396 | const yamlSchema = convertToYamlWComments(dump(objrepr)); |
| 397 | return yamlSchema; |
| 398 | } |
| 399 | |
| 400 | export function summarizeTools(toolIDs: string[]) { |
| 401 | const toolStr = toolIDs |
no test coverage detected