fix(*): Handle tools correctly

This commit is contained in:
Josh Creek
2025-04-22 18:21:23 +01:00
parent b707fc7370
commit 96b212b63c
+13 -7
View File
@@ -23,10 +23,10 @@ export const client = AIProjectsClient.fromConnectionString(
new DefaultAzureCredential() new DefaultAzureCredential()
); );
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]); // const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]);
const allTools = [ const allTools = [
codeInterpreterTool, // codeInterpreterTool,
rubricMatcherTool, rubricMatcherTool,
essayAnalyzerTool, essayAnalyzerTool,
conceptVerifierTool, conceptVerifierTool,
@@ -51,12 +51,18 @@ Whenever you need to:
• check spelling & grammar → call "${spellingAndGrammarCheckerTool.definition.name}" • check spelling & grammar → call "${spellingAndGrammarCheckerTool.definition.name}"
`; `;
const toolResources = allTools.reduce<Record<string, any>>((map, t) => { export const toolResources = allTools.reduce<Record<string, any>>((map, t) => {
if (typeof t === 'function') { // Try all plausible locations for the tool name
map[t.definition.name] = t; const name =
} else { t.definition.name ||
map[t.definition.name] = t.resources; t.definition.function?.name ||
Object.keys(t.resources ?? {})[0];
if (!name) {
console.warn('Tool missing name:', t);
return map;
} }
map[name] = t;
return map; return map;
}, {}); }, {});