This is a Node.js application built with Mastra. It demonstrates the creation and use of AI agents with specific functionalities, including conversational abilities and tool usage for external data interactions.
- Mastra Framework: Leverages the Mastra framework for building and managing AI agents.
- Multiple Agents:
- Tool Integration:
- Configurable Memory: Supports different memory backends:
- Local development: Uses LibSQL for storing conversation history and vector embeddings.
- Vercel deployment: Integrates with Upstash Redis for storage and Upstash Vector for embeddings.
- Vercel Deployment: Pre-configured for easy deployment to Vercel.
- Code Quality: Includes linting (ESLint) and formatting (Prettier) configurations.
.
├── .mastra/ # Mastra build and output files
├── .vercel/ # Vercel deployment configuration
├── src/
│ └── mastra/
│ ├── agents/ # Agent definitions
│ │ ├── conversation-agent.ts
│ │ ├── weather-agent.ts
│ │ ├── memory.ts # Memory configuration
│ │ └── index.ts # Exports agents
│ ├── tools/ # Tool definitions
│ │ └── index.ts # Defines weatherTool
│ └── index.ts # Main Mastra server configuration
├── .env.development # Example development environment variables
├── .gitignore
├── .prettierignore
├── .prettierrc.json
├── eslint.config.js
├── LICENSE
├── package.json
├── tsconfig.json
└── README.md # This file
- Node.js (version >=22.15.21, as specified in
package.json) - pnpm (or your preferred Node.js package manager)
-
Clone the repository:
git clone <repository-url> cd agents
-
Install dependencies:
pnpm install
-
(OPTIONAL) Set up environment variables for remote resources:
For local development against local resources, you don't need to do anything.
Create a
.envfile in the root directory by copying.env.developmentand fill in the necessary values.For Upstash/Vercel, you'll need to provide:
UPSTASH_REDIS_URLUPSTASH_REDIS_TOKENUPSTASH_VECTOR_URLUPSTASH_VECTOR_TOKENVERCEL_TOKEN(for deployment)VERCEL_TEAM_SLUG(for deployment)VERCEL_PROJECT_NAME(for deployment)DATABASE_URL(defaults tofile:local.dbif not set for local development)CORS_ALLOWED_ORIGINS(defaults tohttp://localhost:3000)
To start the development server:
pnpm run devThis will start the local Mastra server and expose the Mastra Playground at http://localhost:4111/agents
This repository is configured for a seamless Vercel deployment workflow:
- Preview Deployments: On every push to a branch that is not
main, Vercel automatically creates a preview deployment. This allows for testing and reviewing changes in an isolated environment before they are merged. - Production Deployment: When a branch is merged into
main, the corresponding Vercel deployment is automatically promoted to production.
You can manually deploy this application to Vercel by running the following command:
pnpm run vercelEnsure that you have set the required Vercel environment variables as described in the Deployment section further down.
pnpm run dev: Starts the Mastra development server.pnpm run build: Builds the project using Mastra.pnpm run lint: Lints the codebase using ESLint.pnpm run lint:fix: Lints and automatically fixes issues.pnpm run format: Formats the code using Prettier.
- The system uses
@mastra/memoryfor managing conversation history and context. - Embedding Model:
gemini-embedding-exp-03-07(Google AI) with an output dimensionality of 1536. - Local Development:
- Storage:
LibSQLStore(e.g.,file:local.db) - Vector Store:
LibSQLVector
- Storage:
- Vercel/Production:
- Storage:
UpstashStore(Upstash Redis) - Vector Store:
UpstashVector
- Storage:
- Configuration for memory (last N messages, semantic recall, thread title generation) is in
src/mastra/agents/memory.ts.
CORS (Cross-Origin Resource Sharing) is configured in src/mastra/index.ts. Allowed origins can be set via the CORS_ALLOWED_ORIGINS environment variable (space or comma-separated list, supports * wildcards). Defaults to http://localhost:3000.
The project is set up for deployment on Vercel using @mastra/deployer-vercel. Ensure the following environment variables are set in your Vercel project settings:
VERCEL_TOKENVERCEL_TEAM_SLUGVERCEL_PROJECT_NAME- And the necessary Upstash variables if using Upstash for memory.
- Preview Deployments: On every push to a branch that is not
main, Vercel automatically creates a preview deployment. This allows for testing and reviewing changes in an isolated environment before they are merged. - Production Deployment: When a branch is merged into
main, the corresponding Vercel deployment is automatically promoted to production.
This project is licensed under the ISC License. See the LICENSE file for details.
Contributions are welcome! Please read our Contributing Guidelines to get started.
We also expect everyone participating in our community to follow our Code of Conduct. Please make sure you are familiar with it.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This README was generated with assistance from an AI.