UNPKG

@azowl/agentops-sdk

Version:

AgentOps REST client and local task execution SDK for Node.js

27 lines (23 loc) • 862 B
import { appendFile, mkdir, readFile } from 'node:fs/promises'; import { LocalAgent } from '@azowl/agentops-sdk/local'; const profileFile = new URL('./quickstart-profile.json', import.meta.url); const profile = JSON.parse(await readFile(profileFile, 'utf8')); const agent = new LocalAgent({ allowedTools: profile.allowedTools, tools: { 'order.total': ({ items }) => items.reduce( (total, item) => total + item.unitPrice * item.quantity, 0, ), }, }); const task = await agent.run('order.total', { items: [ { unitPrice: 1200, quantity: 2 }, { unitPrice: 600, quantity: 1 }, ], }); // Keep a copy of the task record after this example's process exits. const record = JSON.stringify(task); await mkdir('.azowl', { recursive: true }); await appendFile('.azowl/quickstart-history.jsonl', record + '\n', 'utf8'); console.log(record);