Skip to content

letta-ai/letta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Letta logo

Letta (previously MemGPT)

β˜„οΈ New release: Letta Agent Development Environment (read more here) β˜„οΈ

Letta logo


πŸ‘Ύ 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.