Getting Started
Installation and basic setup for Trajectories.
Installation
pnpm add @tally-evals/trajectoriesPeer Dependencies
Trajectories requires the AI SDK and a language model to act as the "user".
pnpm add ai @ai-sdk/google # or another providerBasic Setup
To run a trajectory, you need three things:
- An Agent: Your LLM agent wrapped in a Trajectories wrapper.
- A User Model: An AI SDK
LanguageModelthat will play the role of the user. - A Trajectory Definition: A goal, a persona, and optionally a step graph.
Wrapping your Agent
Trajectories provides built-in wrappers for common frameworks:
import { withAISdkAgent, withMastraAgent } from '@tally-evals/trajectories';
// For AI SDK
const agent = withAISdkAgent(aiSdkAgent);
// For Mastra
const agent = withMastraAgent(mastraAgent);Running the Trajectory
The runTrajectory function handles the loop between the user model and your agent.
const result = await runTrajectory(trajectory, {
generateLogs: true, // See the conversation in the console
});