letta

letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.

Stars: 13410

Visit
 screenshot

Letta is an open source framework for building stateful LLM applications. It allows users to build stateful agents with advanced reasoning capabilities and transparent long-term memory. The framework is white box and model-agnostic, enabling users to connect to various LLM API backends. Letta provides a graphical interface, the Letta ADE, for creating, deploying, interacting, and observing with agents. Users can access Letta via REST API, Python, Typescript SDKs, and the ADE. Letta supports persistence by storing agent data in a database, with PostgreSQL recommended for data migrations. Users can install Letta using Docker or pip, with Docker defaulting to PostgreSQL and pip defaulting to SQLite. Letta also offers a CLI tool for interacting with agents. The project is open source and welcomes contributions from the community.

README:

Letta logo

Letta (previously MemGPT)

☄️ New release: Letta Agent Development Environment (read more here) ☄️

Letta logo


Homepage // Documentation // ADE // Letta Cloud

👾 Letta is an open source framework for building stateful LLM applications. You can use Letta to build stateful agents with advanced reasoning capabilities and transparent long-term memory. The Letta framework is white box and model-agnostic.

Discord Twitter Follow arxiv 2310.08560

Apache 2.0 Release Docker GitHub

cpacker%2FMemGPT | Trendshift

[!IMPORTANT] Looking for MemGPT? You're in the right place!

The MemGPT package and Docker image have been renamed to letta to clarify the distinction between MemGPT agents and the Letta API server / runtime that runs LLM agents as services. Read more about the relationship between MemGPT and Letta here.


⚡ Quickstart

The recommended way to use Letta is to run use Docker. To install Docker, see Docker's installation guide. For issues with installing Docker, see Docker's troubleshooting guide. You can also install Letta using pip (see instructions below).

🌖 Run the Letta server

[!NOTE] Letta agents live inside the Letta server, which persists them to a database. You can interact with the Letta agents inside your Letta server via the REST API + Python / Typescript SDKs, and the Agent Development Environment (a graphical interface).

The Letta server can be connected to various LLM API backends (OpenAI, Anthropic, vLLM, Ollama, etc.). To enable access to these LLM API providers, set the appropriate environment variables when you use docker run:

# replace `~/.letta/.persist/pgdata` with wherever you want to store your agent data
docker run \
  -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
  -p 8283:8283 \
  -e OPENAI_API_KEY="your_openai_api_key" \
  letta/letta:latest

If you have many different LLM API keys, you can also set up a .env file instead and pass that to docker run:

# using a .env file instead of passing environment variables
docker run \
  -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
  -p 8283:8283 \
  --env-file .env \
  letta/letta:latest

Once the Letta server is running, you can access it via port 8283 (e.g. sending REST API requests to http://localhost:8283/v1). You can also connect your server to the Letta ADE to access and manage your agents in a web interface.

[!NOTE] The Letta ADE is a graphical user interface for creating, deploying, interacting and observing with your Letta agents.

For example, if you're running a Letta server to power an end-user application (such as a customer support chatbot), you can use the ADE to test, debug, and observe the agents in your server. You can also use the ADE as a general chat interface to interact with your Letta agents.

ADE screenshot

The ADE can connect to self-hosted Letta servers (e.g. a Letta server running on your laptop), as well as the Letta Cloud service. When connected to a self-hosted / private server, the ADE uses the Letta REST API to communicate with your server.

🖥️ Connecting the ADE to your local Letta server

To connect the ADE with your local Letta server, simply:

  1. Start your Letta server (docker run ...)
  2. Visit https://app.letta.com and you will see "Local server" as an option in the left panel

Letta logo

🔐 To password protect your server, include SECURE=true and LETTA_SERVER_PASSWORD=yourpassword in your docker run command:

# If LETTA_SERVER_PASSWORD isn't set, the server will autogenerate a password
docker run \
  -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
  -p 8283:8283 \
  --env-file .env \
  -e SECURE=true \
  -e LETTA_SERVER_PASSWORD=yourpassword \
  letta/letta:latest

🌐 Connecting the ADE to an external (self-hosted) Letta server

If your Letta server isn't running on localhost (for example, you deployed it on an external service like EC2):

  1. Click "Add remote server"
  2. Enter your desired server name, the IP address of the server, and the server password (if set)

🧑‍🚀 Frequently asked questions (FAQ)

"Do I need to install Docker to use Letta?"

No, you can install Letta using pip (via pip install -U letta), as well as from source (via poetry install). See instructions below.

"What's the difference between installing with pip vs Docker?"

Letta gives your agents persistence (they live indefinitely) by storing all your agent data in a database. Letta is designed to be used with a PostgreSQL (the world's most popular database), however, it is not possible to install PostgreSQL via pip, so the pip install of Letta defaults to using SQLite. If you have a PostgreSQL instance running on your own computer, you can still connect Letta (installed via pip) to PostgreSQL by setting the environment variable LETTA_PG_URI.

Database migrations are not officially supported for Letta when using SQLite, so if you would like to ensure that you're able to upgrade to the latest Letta version and migrate your Letta agents data, make sure that you're using PostgreSQL as your Letta database backend. Full compatability table below:

Installation method Start server command Database backend Data migrations supported?
pip install letta letta server SQLite
pip install letta export LETTA_PG_URI=... + letta server PostgreSQL
Install Docker docker run ... (full command) PostgreSQL

"How do I use the ADE locally?"

To connect the ADE to your local Letta server, simply run your Letta server (make sure you can access localhost:8283) and go to https://app.letta.com. If you would like to use the old version of the ADE (that runs on localhost), downgrade to Letta version <=0.5.0.

"If I connect the ADE to my local server, does my agent data get uploaded to letta.com?"

No, the data in your Letta server database stays on your machine. The Letta ADE web application simply connects to your local Letta server (via the REST API) and provides a graphical interface on top of it to visualize your local Letta data in your browser's local state.

"Do I have to use your ADE? Can I build my own?"

The ADE is built on top of the (fully open source) Letta server and Letta Agents API. You can build your own application like the ADE on top of the REST API (view the documention here).

"Can I interact with Letta agents via the CLI?"

The recommended way to use Letta is via the REST API and ADE, however you can also access your agents via the CLI.

View instructions for running the Letta CLI

You can chat with your agents via the Letta CLI tool (letta run). If you have a Letta Docker container running, you can use docker exec to run the Letta CLI inside the container:

# replace `<letta_container_id>` with the ID of your Letta container, found via `docker ps`
docker exec -it <letta_container_id> letta run

You can also use docker ps within the command to automatically find the ID of your Letta container:

docker exec -it $(docker ps -q -f ancestor=letta/letta) letta run

In the CLI tool, you'll be able to create new agents, or load existing agents:

🧬 Creating new agent...
? Select LLM model: letta-free [type=openai] [ip=https://inference.memgpt.ai]
? Select embedding model: letta-free [type=hugging-face] [ip=https://embeddings.memgpt.ai]
->  🤖 Using persona profile: 'sam_pov'
->  🧑 Using human profile: 'basic'
->  🛠️  8 tools: send_message, pause_heartbeats, conversation_search, conversation_search_date, archival_memory_insert, archival_memory_search, core_memory_append, core_memory_replace

🎉 Created new agent 'InspiringSpinach'

Hit enter to begin (will request first Letta message)

💭 User engaged. Recognize as Chad. Acknowledge presence and establish connection. Explore interests and engage in meaningful discourse.
🤖 Hello, Chad. It's nice to meet you. I am keen on learning and exploring new ideas and concepts. Is there a specific topic you'd like to discuss today?

> Enter your message: my name is Brad, not Chad...

💭 A discrepancy in identity. Reflect this change in core memory. Apologize for the oversight, and rectify the error.
⚡🧠 [function] updating memory with core_memory_replace
         First name: Chad
        → First name: Brad
💭 Apologize for the mistake in recognizing his name, and begin the conversation anew, addressing him by the correct name this time.
🤖 I apologize for the oversight, Brad. Let's restart. It's a pleasure to meet you, Brad. Is there a specific topic you'd like to discuss today?

> Enter your message:

⚡ Quickstart (pip)

[!WARNING] Database migrations are not officially supported with SQLite

When you install Letta with pip, the default database backend is SQLite (you can still use an external postgres service with your pip install of Letta by setting LETTA_PG_URI).

We do not officially support migrations between Letta versions with SQLite backends, only postgres. If you would like to keep your agent data across multiple Letta versions we highly recommend using the Docker install method which is the easiest way to use postgres with Letta.

View instructions for installing with pip

You can also install Letta with pip, which will default to using SQLite for the database backends (whereas Docker will default to using postgres).

Step 1 - Install Letta using pip

pip install -U letta

Step 2 - Set your environment variables for your chosen LLM / embedding providers

export OPENAI_API_KEY=sk-...

For Ollama (see our full documentation for examples of how to set up various providers):

export OLLAMA_BASE_URL=http://localhost:11434

Step 3 - Run the Letta CLI

You can create agents and chat with them via the Letta CLI tool (letta run):

letta run
🧬 Creating new agent...
? Select LLM model: letta-free [type=openai] [ip=https://inference.memgpt.ai]
? Select embedding model: letta-free [type=hugging-face] [ip=https://embeddings.memgpt.ai]
->  🤖 Using persona profile: 'sam_pov'
->  🧑 Using human profile: 'basic'
->  🛠️  8 tools: send_message, pause_heartbeats, conversation_search, conversation_search_date, archival_memory_insert, archival_memory_search, core_memory_append, core_memory_replace

🎉 Created new agent 'InspiringSpinach'

Hit enter to begin (will request first Letta message)

💭 User engaged. Recognize as Chad. Acknowledge presence and establish connection. Explore interests and engage in meaningful discourse.
🤖 Hello, Chad. It's nice to meet you. I am keen on learning and exploring new ideas and concepts. Is there a specific topic you'd like to discuss today?

> Enter your message: my name is Brad, not Chad...

💭 A discrepancy in identity. Reflect this change in core memory. Apologize for the oversight, and rectify the error.
⚡🧠 [function] updating memory with core_memory_replace
         First name: Chad
        → First name: Brad
💭 Apologize for the mistake in recognizing his name, and begin the conversation anew, addressing him by the correct name this time.
🤖 I apologize for the oversight, Brad. Let's restart. It's a pleasure to meet you, Brad. Is there a specific topic you'd like to discuss today?

> Enter your message:

Step 4 - Run the Letta server

You can start the Letta API server with letta server (see the full API reference here):

letta server
Initializing database...
Running: uvicorn server:app --host localhost --port 8283
INFO:     Started server process [47750]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://localhost:8283 (Press CTRL+C to quit)

🤗 How to contribute

Letta is an open source project built by over a hundred contributors. There are many ways to get involved in the Letta OSS project!

  • Contribute to the project: Interested in contributing? Start by reading our Contribution Guidelines.
  • Ask a question: Join our community on Discord and direct your questions to the #support channel.
  • Report issues or suggest features: Have an issue or a feature request? Please submit them through our GitHub Issues page.
  • Explore the roadmap: Curious about future developments? View and comment on our project roadmap.
  • Join community events: Stay updated with the event calendar or follow our Twitter account.

Legal notices: By using Letta and related Letta services (such as the Letta endpoint or hosted service), you are agreeing to our privacy policy and terms of service.

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for letta

Similar Open Source Tools

For similar tasks

For similar jobs