This README provides instructions for running the FinRobot RAG API using Docker.
- Docker and Docker Compose installed
- OpenAI API key (create
OAI_CONFIG_LISTfile based on theOAI_CONFIG_LIST.localsample) - API keys for financial data sources (create
config_api_keysfile based on theconfig_api_keys.localsample) - Report PDF files (placed in the
reportdirectory)
Before building and running the Docker container, ensure you have:
OAI_CONFIG_LISTfile in the root directory with your OpenAI API key(s)- PDF files in the
reportdirectory:Microsoft_Annual_Report_2023.pdf2023-07-27_10-K_msft-20230630.htm.pdf
# Build docker (need to modify $IMAGE_NAME:$IMAGE_TAG for example finagents:latest)
docker image build \
--build-arg username=$USER \
--build-arg uid=$UID \
--build-arg gid=$GID \
--file Dockerfile \
--tag finagents:latest \
./
# Run container expose api (with coressponding $IMAGE_NAME:$IMAGE_TAG for example finagents:latest)
docker run -p 8888:8888 finagentsapi:latest
# View logs
docker-compose logs -f
# Stop the containers
docker-compose down
# Rebuild if you make changes
docker-compose up -d --buildMake sure you are in main directory
# creae conda environment
conda env create -f my_conda.yml
# activate conda environment
conda activate finrobot-test
pip install requirements.txt
Currently main_up.py and main.py is stable for running fastapi request, I still developing a python file which utilize agents power of this repo. Here is the following sample for run in local
# run main_up.py
uvicorn main_up:app
Once running, the following endpoints are available:
main_up.py
{base_url}/- Health check endpoint{base_url}/chat_rag_up- Main RAG API endpoint (POST)
main.py
{base_url}/- Health check endpoint{base_url}/chat_rag- Main RAG API endpoint (POST) for querying annual reports and 10-K filings
main_up.py (however this file have hardcord file uploaded so user can only question and answer that only file, which I need to develop a separate api endpoint but this is for testing the main endpoing)
curl -X POST "{base_url}/chat_rag" \
-H "Content-Type: application/json" \
-d '{"query": "What is the strategy of Nvidia for artificial intelligence?"}'main.py
curl -X POST "{base_url}/chat_rag_up" \
-H "Content-Type: application/json" \
-d '{"query": "What is the strategy of Nvidia for artificial intelligence?"}'The Docker setup includes persistent volumes for the vector databases:
finrobot-earnings-db- Earnings call databasefinrobot-sec-db- SEC filings databasefinrobot-sec-md-db- SEC markdown filings database
- Still have conflict in building docker process
- install too many requiremnts.txt due to no exact dependencies cost a lot of time
- still cannot expose api
In the running docker process if you found this bug:
ImportError: /home/zap/miniconda3/lib/python3.12/site-packages/sklearn/utils/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS block
you can just copy that path expose via ENV LD_PRELOAD (follow this link for more detail keras-team/keras-tuner#317 (comment))