Daydreams Logo
Extra reading

dreams.ts

This file provides the createDreams function, which is the main entry point for building your Daydreams agent. Think of it as the constructor or blueprint for your AI assistant. It takes all your configurations (like which AI model to use, what tools it has, how it remembers things) and assembles them into a ready-to-run agent.

How to Use

You'll call createDreams({...}) once in your project setup, passing it a configuration object. This object specifies:

  • model: Which language model (like OpenAI's GPT or Anthropic's Claude) the agent should use for thinking (using providers from the Vercel AI SDK).
  • extensions: Pre-built packages of functionality (like Discord integration or file system access) you want your agent to have.
  • contexts: Custom definitions for different tasks or conversations your agent needs to manage.
  • actions: Custom tools or abilities you define for your agent.
  • memory: How the agent should store and recall information (e.g., using in-memory storage or a database like MongoDB).
  • (and other optional configurations)

The function returns an agent object. You'll then typically call await agent.start() to initialize it and agent.send(...) or agent.run(...) to give it tasks or information to process.

Benefit

It provides a single, organized way to configure and initialize your entire agent. Instead of manually wiring up all the different parts (model, memory, tools), createDreams handles the setup and dependencies, letting you focus on defining your agent's capabilities and behavior.

Anticipated Questions

  • "Do I need to provide all configuration options?" No, many options have sensible defaults (like basic memory storage). You typically only need to provide the model and any extensions or custom actions/contexts you want to use.
  • "What's the difference between agent.send() and agent.run()?" agent.send() is typically used when an external event happens (like a user sending a message), providing the input data. agent.run() is the underlying method that processes information, reasons, and takes action; send usually calls run internally.
  • "Where do I define things like actions and contexts?" You usually define them in separate files and import them into your main setup file where you call createDreams.

On this page