Files
Agentic-AI/scripts/t-llm.mjs
T

25 lines
971 B
JavaScript

import { getModel } from '../src/orchestration/llm.js';
import { tool } from '@langchain/core/tools';
import { z } from 'zod';
const ping = tool(async ({ n }) => `pong-${n * 2}`, {
name: 'double',
description: 'Doubles a number.',
schema: z.object({ n: z.number().describe('number to double') }),
});
for (const tier of ['agent', 'supervisor']) {
try {
const llm = getModel(tier, { maxTokens: 1024, effort: 'low' });
const r = await llm.invoke([{ role: 'user', content: 'Reply with exactly: OK' }]);
console.log(`[${tier}] text ->`, JSON.stringify(r.content).slice(0, 120));
const bound = getModel(tier, { maxTokens: 1024, effort: 'low' }).bindTools([ping]);
const t = await bound.invoke([{ role: 'user', content: 'Use the double tool on 21.' }]);
console.log(`[${tier}] toolCalls ->`, JSON.stringify(t.tool_calls));
} catch (e) {
console.error(`[${tier}] ERROR`, e.status || '', e.message?.slice(0, 300));
}
}
process.exit(0);