- You need an openai API key for ingesting data, set
OPENAI_API_KEYin your environment variables. If you don't have one, you can use the other method. - Generate and set a JWT secret key:
export SECRET_KEY=$(openssl rand -base64 32), and save it. You can rerun the command above to generate a new secret key when needed, especially when the old one is compromised. Note that changing the JWT token will log out all users. Optionally, you can also setEXPIRE_MINUTESto change the expiration time of the JWT token. The default is 7 days (10080 minutes). - Your data must have two text columns, Mercury supports ingesting data from CSV, JSON, and JSONL files.
- Install Python dependencies:
pip3 install -r requirements.txt && python3 -m spacy download en_core_web_sm. - Now ingest your data:
python3 ingester.py --embedding_model_id=<embedding_model_id> --embedding_dimension=512 <path_to_your_data>.embedding_model_idis the ID of the embedding model to use. Currently supportsall-mpnet-base-v2,multi-qa-mpnet-base-dot-v1,bge-small-en-v1.5,openai/{text-embedding-3-small, text-embedding-3-large}, anddummy(random numbers).embedding_dimensionis the dimension of the embeddings. Only effective to OpenAI embedders.path_to_your_datais the path to your data.- If you want to overwrite the existing data, add
--overwrite_datato the command. - If your two text columns names are not
sourceandsummary, use theingest_column_1(for Source) andingest_column_2(for Summary) options, for example:python ingester.py --embedding_model_id="openai/text-embedding-3-small" --embedding_dimension=512 --ingest_column_1="原文" --ingest_column_2="翻译" ./test.csv
- You need to set up the account:
python3 user_admin.py new -n "Test User" -e "test@example.com"
Now that the backend is ready, there are two ways to start Mecury, so choose the one that best suits your needs.
Note
You may encounter issues with not being able to write to the database because of the permission issue, if so try using manual mode.
Install Docker Desktop and Docker Compose. See Install for more information.
- Make
secretsdirectory:mkdir secrets - Copy the
SECRET_KEYenv tosecrets/secret_key, and copy theOPENAI_API_KEYenv tosecrets/openai_api_key. - Run:
docker compose up
- Install Node.js and pnpm first, depending on your operating system, you can go to the official Node.js and pnpm websites for further details:
- Install the dependencies:
pnpm install - Build the frontend:
pnpm build - Run the server:
python3 server.py
After the server is running, you can access the Mercury at http://localhost:8000.
WIP