Memobase uses a single config.yaml to initialize the server. It contains the configs of:
- LLM:
llm_base_url,llm_api_key,best_llm_model,... - Embedding:
enable_event_embedding,embedding_api_key... - Memory:
max_pre_profile_token_size,max_profile_subtopics,additional_user_profiles...
By default, Memobase enables user profile and event memory with filter ability. That means running a Memobase server requires you to have below things:
- LLM API: You must fill the OpenAI API Key in
llm_api_keyofconfig.yaml.Or you can changellm_base_urlto any OpenAI-SDK-Compatible service(via vllm, Ollama,...). Alternatively, you can setllm_api_keyandllm_base_urlusing environment variablesMEMOBASE_LLM_API_KEYandMEMOBASE_LLM_BASE_URL - Embedding API: Memobase supports OpenAI-Compatible SDK, Jina Embedding and Ollama Embedding. Memobase uses embedding API to retrieve related user events. If you don't have a embedding API, you can set
enable_event_embedding: falseinconfig.yaml
We have some example config.yaml in examplel_config:
profile_for_assistant,profile_for_education,profile_for_companionare three similar configs in term of structure, but for different user cases.event_tagis a feature to tracking temporal attributes of users. doconly_strict_profile: disable all other features, only collect the profiles you design.jina_embeddinguses Jina exmbedding for event search.ollama_embeddinguses Ollama exmbedding for event search.
environment variables
Check ./.env.example for necessary vars. You can configure the running port and access token in here. Also, anything in config.yaml can be override in env(doc), just starts with MEMOBASE_
-
Make sure you have docker-compose installed.
-
Prepare the configs:
cd src/server cp .env.example .env cp ./api/config.yaml.example ./api/config.yaml.envcontains the service configs, like running port, secret token...config.yamlcontains the Memobase configs, like LLM model, profile slots. docs
-
Run
docker-compose build && docker-compose upto start the services.
Check out the docs of how to use Memobase client or APIs.
-
If you have existing postgres and reids, you can only launch the Memobase core
-
Find and download the docker image of Memobase:
docker pull ghcr.io/memodb-io/memobase:latest
-
Setup your
config.yamland anenv.listfile, theenv.listshould look like this: -
Run the service:
docker run --env-file env.list -v ./api/config.yaml:/app/config.yaml -p 8019:8000 ghcr.io/memodb-io/memobase:main
- Start a local DB first by
sh script/up-dev.sh - Open a new terminal window and
cd ./api - Install python deps:
uv sync - To test if you got everything right, run
uv run pytestto see if all the tests are passed. - Launch Memobase Server in dev mode:
uv run -m fastapi dev --port 8019
fastapi devhas hot-reload, so you can just modify the code and test it without relaunch the service.
Memobase may introduce breaking changes in DB schema, here is a guideline of how to migrate your data to latest Memobase:
-
Install
alembic:pip install alembic -
Modify
./api/alembic.ini. Find the field calledsqlalchemy.urlinalembbic.ini, change it to your Postgres DB of Memobase -
Run below commands to prepare the migration plan:
cd api mkdir migrations/versions alembic upgrade head alembic revision --autogenerate -m "memobase changes"
-
⚠️ Run the commandalembic upgrade headagain to migrate your current Memobase DB to the latest one.