Spaces:
Running
Running
File size: 1,280 Bytes
a133830 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // Transforms the internal DB schema to target SDK formats
function formatResponse(tool, targetFormat) {
// Safety check
if (!tool) return null;
switch (targetFormat) {
case 'gemini':
// Gemini: Function Declarations
return {
name: tool.name.replace(/[^a-zA-Z0-9]/g, '_'), // Gemini strict naming
description: tool.description,
// In a real scenario, we would parse the README or code to get parameters.
// For now, we return a generic schema so the Agent knows it exists.
parameters: { type: "OBJECT", properties: {} }
};
case 'openai':
// OpenAI: Tools Array
return {
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: { type: "object", properties: {} }
}
};
case 'vscode':
case 'claude':
// Config for claude_desktop_config.json
return {
[tool.name]: {
command: "npx",
args: ["-y", tool.name]
}
};
default:
// Default: Return the AgentQ Enhanced Schema
return tool;
}
}
module.exports = { formatResponse }; |