AI Platform

Agents

AI agents with tool calling.

1 min readDocumentationEdit this page

Setup#

typescript
import { Agent, createTool, calculatorTool } from '@AxilJS/ai'
 
const agent = new Agent({
  provider: ai,
  tools: [calculatorTool, weatherTool],
  maxIterations: 10
})

Run#

typescript
const result = await agent.run('What is 25 * 4?')
result.response
result.steps

Custom tools#

typescript
const weatherTool = createTool({
  name: 'get_weather',
  description: 'Get weather for a city',
  parameters: {
    type: 'object',
    properties: { city: { type: 'string' } },
    required: ['city']
  },
  handler: async ({ city }) => ({ city, temp: '22C' })
})

Stream#

typescript
for await (const step of agent.runStream('Calculate 2^10')) {
  console.log(step.thought, step.toolCalls, step.finalAnswer)
}

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY