An open API service indexing awesome lists of open source software.

https://github.com/blaxel-templates/template-mastra-ts

A production-ready TypeScript template for building AI agents using Mastra in Blaxel.
https://github.com/blaxel-templates/template-mastra-ts

agent blaxel mastra typescript

Last synced: 2 months ago
JSON representation

A production-ready TypeScript template for building AI agents using Mastra in Blaxel.

Awesome Lists containing this project

README

          

# Blaxel Mastra Agent


Blaxel

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js 18+](https://img.shields.io/badge/node-18+-blue.svg)](https://nodejs.org/downloads/)
[![Mastra](https://img.shields.io/badge/Mastra-powered-brightgreen.svg)](https://mastra.ai/)
[![TypeScript](https://img.shields.io/badge/TypeScript-enabled-blue.svg)](https://www.typescriptlang.org/)

A template implementation of a conversational agent using Mastra framework and GPT-4. This agent demonstrates the power of Mastra for building sophisticated AI workflows with tool integration, workflow orchestration, and advanced conversation management capabilities.

## 📑 Table of Contents

- [Features](#features)
- [Quick Start](#quick-start)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Running Locally](#running-the-server-locally)
- [Testing](#testing-your-agent)
- [Deployment](#deploying-to-blaxel)
- [Project Structure](#project-structure)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [Support](#support)
- [License](#license)

## ✨ Features

- Interactive conversational interface with workflow orchestration
- Advanced tool integration and workflow management
- Streaming responses for real-time interaction
- Built on Mastra for sophisticated AI workflow automation
- TypeScript support with full type safety
- Integration with multiple AI providers and services
- Easy deployment and integration with Blaxel platform

## 🚀 Quick Start

For those who want to get up and running quickly:

```bash
# Clone the repository
git clone https://github.com/blaxel-ai/template-mastra-ts.git

# Navigate to the project directory
cd template-mastra-ts

# Install dependencies
npm install

# Start the server
bl serve --hotreload

# In another terminal, test the agent
bl chat --local blaxel-agent
```

## 📋 Prerequisites

- **Node.js:** 18.0 or later
- **[NPM](https://www.npmjs.com/):** Node package manager
- **Blaxel Platform Setup:** Complete Blaxel setup by following the [quickstart guide](https://docs.blaxel.ai/Get-started#quickstart)
- **[Blaxel CLI](https://docs.blaxel.ai/Get-started):** Ensure you have the Blaxel CLI installed. If not, install it globally:
```bash
curl -fsSL https://raw.githubusercontent.com/blaxel-ai/toolkit/main/install.sh | BINDIR=/usr/local/bin sudo -E sh
```
- **Blaxel login:** Login to Blaxel platform
```bash
bl login YOUR-WORKSPACE
```

## 💻 Installation

**Clone the repository and install dependencies:**

```bash
git clone https://github.com/blaxel-ai/template-mastra-ts.git
cd template-mastra-ts
npm install
```

## 🔧 Usage

### Running the Server Locally

Start the development server with hot reloading:

```bash
bl serve --hotreload
```

_Note:_ This command starts the server and enables hot reload so that changes to the source code are automatically reflected.

### Testing your agent

You can test your agent using the chat interface:

```bash
bl chat --local blaxel-agent
```

Or run it directly with specific input:

```bash
bl run agent blaxel-agent --local --data '{"input": "Create a workflow to analyze customer feedback"}'
```

### Deploying to Blaxel

When you are ready to deploy your application:

```bash
bl deploy
```

This command uses your code and the configuration files under the `.blaxel` directory to deploy your application.

## 📁 Project Structure

- **src/index.ts** - Application entry point
- **src/agent.ts** - Core agent implementation with Mastra integration
- **src/workflows/** - Workflow definitions and orchestration
- **src/tools/** - Custom tools and integrations
- **src/types/** - TypeScript type definitions
- **package.json** - Node.js package configuration
- **tsconfig.json** - TypeScript configuration
- **blaxel.toml** - Blaxel deployment configuration

## ❓ Troubleshooting

### Common Issues

1. **Blaxel Platform Issues**:
- Ensure you're logged in to your workspace: `bl login MY-WORKSPACE`
- Verify models are available: `bl get models`
- Check that functions exist: `bl get functions`

2. **Node.js Version Issues**:
- Make sure you have Node.js 18+
- Try `node --version` to check your version
- Update Node.js if needed

3. **Workflow Execution Problems**:
- Check workflow step dependencies
- Verify tool configurations and permissions
- Monitor workflow execution logs

4. **Integration Failures**:
- Verify service configurations in Blaxel platform
- Check rate limits and quotas
- Review endpoint configurations

5. **TypeScript Compilation Errors**:
- Run `npx tsc --noEmit` to check for type errors
- Ensure all dependencies have proper type definitions
- Check tsconfig.json configuration

For more help, please [submit an issue](https://github.com/blaxel-templates/template-mastra-ts/issues) on GitHub.

## 👥 Contributing

Contributions are welcome! Here's how you can contribute:

1. **Fork** the repository
2. **Create** a feature branch:
```bash
git checkout -b feature/amazing-feature
```
3. **Commit** your changes:
```bash
git commit -m 'Add amazing feature'
```
4. **Push** to the branch:
```bash
git push origin feature/amazing-feature
```
5. **Submit** a Pull Request

Please make sure to update tests as appropriate and follow the TypeScript code style of the project.

## 🆘 Support

If you need help with this template:

- [Submit an issue](https://github.com/blaxel-templates/template-mastra-ts/issues) for bug reports or feature requests
- Visit the [Blaxel Documentation](https://docs.blaxel.ai) for platform guidance
- Check the [Mastra Documentation](https://mastra.ai/en/docs) for framework-specific help
- Join our [Discord Community](https://discord.gg/G3NqzUPcHP) for real-time assistance

## 📄 License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.