statelyai / agent

Create state-machine-powered LLM agents using XState
https://stately.ai/docs/agents
105 stars 6 forks source link

Simplify event choices #22

Closed davidkpiano closed 3 months ago

davidkpiano commented 3 months ago

The createSchemas(…) function has been removed. The defineEvents(…) function should be used instead, as it is a simpler way of defining events and event schemas using Zod:

import { defineEvents } from '@statelyai/agent';
import { z } from 'zod';
import { setup } from 'xstate';

const events = defineEvents({
  inc: z.object({
    by: z.number().describe('Increment amount'),
  }),
});

const machine = setup({
  types: {
    events: events.types,
  },
  schema: {
    events: events.schemas,
  },
}).createMachine({
  // ...
});