By default, Auto-GPT is going to use LocalCache instead of redis or Pinecone.
To switch to either, change the MEMORY_BACKEND
env variable to the value that you want:
local
(default) uses a local JSON cache filepinecone
uses the Pinecone.io account you configured in your ENV settingsredis
will use the redis cache that you configuredmilvus
will use the milvus cache that you configuredweaviate
will use the weaviate cache that you configured
Links to memory backends
- Pinecone
- Milvus – self-hosted, or managed with Zilliz Cloud
- Redis
- Weaviate
CAUTION
This is not intended to be publicly accessible and lacks security measures. Therefore, avoid exposing Redis to the internet without a password or at all
- Install docker (or Docker Desktop on Windows).
- Launch Redis container.
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
See https://hub.docker.com/r/redis/redis-stack-server for setting a password and additional configuration.
- Set the following settings in
.env
.Replace PASSWORD in angled brackets (<>)
MEMORY_BACKEND=redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=<PASSWORD>
You can optionally set `WIPE_REDIS_ON_START=False` to persist memory stored in Redis.
You can specify the memory index for redis using the following:
MEMORY_INDEX=<WHATEVER>
Pinecone lets you store vast amounts of vector-based memory, allowing the agent to load only relevant memories at any given time.
- Go to pinecone and make an account if you don't already have one.
- Choose the
Starter
plan to avoid being charged. - Find your API key and region under the default project in the left sidebar.
In the .env
file set:
PINECONE_API_KEY
PINECONE_ENV
(example: "us-east4-gcp")MEMORY_BACKEND=pinecone
Alternatively, you can set them from the command line (advanced):
For Windows Users:
setx PINECONE_API_KEY "<YOUR_PINECONE_API_KEY>"
setx PINECONE_ENV "<YOUR_PINECONE_REGION>" # e.g: "us-east4-gcp"
setx MEMORY_BACKEND "pinecone"
For macOS and Linux users:
export PINECONE_API_KEY="<YOUR_PINECONE_API_KEY>"
export PINECONE_ENV="<YOUR_PINECONE_REGION>" # e.g: "us-east4-gcp"
export MEMORY_BACKEND="pinecone"
Milvus is an open-source, highly scalable vector database to store huge amounts of vector-based memory and provide fast relevant search. And it can be quickly deployed by docker locally or as a cloud service provided by Zilliz Cloud.
-
Deploy your Milvus service, either locally using docker or with a managed Zilliz Cloud database.
-
Set up a managed Zilliz Cloud database (click to expand)
- Go to Zilliz Cloud and sign up if you don't already have account.
- In the Databases tab, create a new database.
- Remember your username and password
- Wait until the database status is changed to RUNNING.
- In the Database detail tab of the database you have created, the public cloud endpoint, such as:
https://xxx-xxxx.xxxx.xxxx.zillizcloud.com:443
.
-
Run
pip3 install pymilvus
to install the required client library. Make sure your PyMilvus version and Milvus version are compatible to avoid issues. See also the PyMilvus installation instructions. -
Update
.env
MEMORY_BACKEND=milvus
- One of:
MILVUS_ADDR=host:ip
(for local instance)MILVUS_ADDR=https://xxx-xxxx.xxxx.xxxx.zillizcloud.com:443
(for Zilliz Cloud)
The following settings are optional:
- Set
MILVUS_USERNAME='username-of-your-milvus-instance'
- Set
MILVUS_PASSWORD='password-of-your-milvus-instance'
- Set
MILVUS_SECURE=True
to use a secure connection. Only use if your Milvus instance has TLS enabled. SettingMILVUS_ADDR
to ahttps://
URL will override this setting. - Set
MILVUS_COLLECTION
if you want to change the collection name to use in Milvus. Defaults toautogpt
.
Weaviate is an open-source vector database. It allows to store data objects and vector embeddings from ML-models and scales seamlessly to billion of data objects. An instance of Weaviate can be created locally (using Docker), on Kubernetes or using Weaviate Cloud Services.
Although still experimental, Embedded Weaviate is supported which allows the Auto-GPT process itself to start a Weaviate instance. To enable it, set USE_WEAVIATE_EMBEDDED
to True
and make sure you pip install "weaviate-client>=3.15.4"
.
Install the Weaviate client before usage.
$ pip install weaviate-client
In your .env
file set the following:
MEMORY_BACKEND=weaviate
WEAVIATE_HOST="127.0.0.1" # the IP or domain of the running Weaviate instance
WEAVIATE_PORT="8080"
WEAVIATE_PROTOCOL="http"
WEAVIATE_USERNAME="your username"
WEAVIATE_PASSWORD="your password"
WEAVIATE_API_KEY="your weaviate API key if you have one"
WEAVIATE_EMBEDDED_PATH="/home/me/.local/share/weaviate" # this is optional and indicates where the data should be persisted when running an embedded instance
USE_WEAVIATE_EMBEDDED=False # set to True to run Embedded Weaviate
MEMORY_INDEX="Autogpt" # name of the index to create for the application
View memory usage by using the --debug
flag :)
Memory pre-seeding allows you to ingest files into memory and pre-seed it before running Auto-GPT.
# python data_ingestion.py -h
usage: data_ingestion.py [-h] (--file FILE | --dir DIR) [--init] [--overlap OVERLAP] [--max_length MAX_LENGTH]
Ingest a file or a directory with multiple files into memory. Make sure to set your .env before running this script.
options:
-h, --help show this help message and exit
--file FILE The file to ingest.
--dir DIR The directory containing the files to ingest.
--init Init the memory and wipe its content (default: False)
--overlap OVERLAP The overlap size between chunks when ingesting files (default: 200)
--max_length MAX_LENGTH The max_length of each chunk when ingesting files (default: 4000)
# python data_ingestion.py --dir DataFolder --init --overlap 100 --max_length 2000
In the example above, the script initializes the memory, ingests all files within the Auto-Gpt/autogpt/auto_gpt_workspace/DataFolder
directory into memory with an overlap between chunks of 100 and a maximum length of each chunk of 2000.
Note that you can also use the --file
argument to ingest a single file into memory and that data_ingestion.py will only ingest files within the /auto_gpt_workspace
directory.
The DIR path is relative to the auto_gpt_workspace directory, so python data_ingestion.py --dir . --init
will ingest everything in auto_gpt_workspace
directory.
You can adjust the max_length
and overlap
parameters to fine-tune the way the documents are presented to the AI when it "recall" that memory:
- Adjusting the overlap value allows the AI to access more contextual information from each chunk when recalling information, but will result in more chunks being created and therefore increase memory backend usage and OpenAI API requests.
- Reducing the
max_length
value will create more chunks, which can save prompt tokens by allowing for more message history in the context, but will also increase the number of chunks. - Increasing the
max_length
value will provide the AI with more contextual information from each chunk, reducing the number of chunks created and saving on OpenAI API requests. However, this may also use more prompt tokens and decrease the overall context available to the AI.
Memory pre-seeding is a technique for improving AI accuracy by ingesting relevant data into its memory. Chunks of data are split and added to memory, allowing the AI to access them quickly and generate more accurate responses. It's useful for large datasets or when specific information needs to be accessed quickly. Examples include ingesting API or GitHub documentation before running Auto-GPT.
WIPE_REDIS_ON_START=False
in your .env
file.
data_ingestion.py
script anytime during an Auto-GPT run.
Memories will be available to the AI immediately as they are ingested, even if ingested while Auto-GPT is running.