Skip to content

An example chatbot application built on the Letta API, which makes each chatbot a stateful agent (agent with memory) under the hood.

License

Notifications You must be signed in to change notification settings

letta-ai/letta-chatbot-example

Repository files navigation

Stateful AI agent chatbot template built with Letta and Next.js.

Deploy your own AI chatbot using Letta to create agents that can learn over time.

One-click deploy with Vercel

Deploy with Vercel

Note

You must have a Letta server running to use this template. Follow this quickstart guide to run your local Letta server.

📺 Video overview (watch on YouTube)

Build your own ChatGPT with memory using Letta

✨ Features

  • Letta

    • Formerly known as MemGPT, Letta is an open-source framework designed for building stateful LLM applications. Our chatbot webapp template showcases powerful core features of Letta.
  • Static defined agent state

    • Define your agent state in the default-agents.json file. This file contains the initial state of your agents, including the LLM model, user profile, agent persona, and other configurations.
  • Cookie-based sessions

    • Includes an implementation of cookie-based sessions to emulate users.
    • Can be disabled by setting USE_COOKIE_BASED_AUTHENTICATION=false to view all your agents from the ADE.
    • Different chat histories for different browsers. Tracks anonymous users across requests without requiring authentication.

📦 What's included

  • Letta TypeScript SDK

    • The Letta TypeScript library provides convenient access to the Letta API.
  • Next.js 15+

    • We leverage Next.js for its server-side rendering (SSR) and other performance optimizations, ensuring a fast and seamless user experience.
  • React

    • React provides a component-based architecture, enabling us to build interactive and dynamic UIs with reusable elements.
  • TypeScript

    • TypeScript enhances our codebase with static typing, improved maintainability, and better developer tooling, reducing potential runtime errors.
  • Shadcn UI

    • Shadcn UI, built on Tailwind CSS, offers a collection of modern, accessible UI components, ensuring a cohesive and polished design.
  • React Markdown

    • React Markdown allows us to render Markdown content seamlessly, making it easier to display formatted text within our application.

⚡️ Quickstart

📋 What you need before starting

🚀 Running the app locally

🔸 Set up your local Letta server

Follow the quickstart guide to run your local Letta server. You can run your own Letta server using Letta Desktop or Docker. By default, the Letta server will run on http://localhost:8283.

🔸 Setup and run the app

1️⃣ Clone the repository and install dependencies:

# Clone the repository
git clone [email protected]:letta-ai/letta-chatbot-template.git

# Navigate to the project directory
cd letta-chatbot-template

# Install dependencies
npm install

# Set environment variables
cp .env.template .env

2️⃣ Update the .env file with your Letta server URL

3️⃣ Update the default agents in the default-agents.json file

4️⃣ Run the app

npm run dev

Environment variables

Environment variables can be controlled by setting them in your .env file or by setting them in your deployment environment.

  • LETTA_ACCESS_TOKEN - Your Letta access token, if not using cloud this is usually optiona.
  • LETTA_SERVER_URL - The URL of your Letta server. Default is http://localhost:8283.
  • NEXT_PUBLIC_CREATE_AGENTS_FROM_UI - If set to true will show a + button in the sidebar to create new agents from the default-agents.json file. Default is true.
  • USE_COOKIE_BASED_AUTHENTICATION - If set to true will use cookie-based sessions to emulate users. Default is true.

🔸 See the app in action

Once the app is running, open your web browser and navigate to http://localhost:3000.

☁️ Running the app with Letta Cloud

👾 TBA. Stayed tuned! Follow us on Discord for updates.

About

An example chatbot application built on the Letta API, which makes each chatbot a stateful agent (agent with memory) under the hood.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •