- Multi-agentic researcher researches the query/topic from documents fetched from Tavily Search Engine.
- The output is the report about the query/topic based on the retrieved documents.
- The graph ends when the hallucination point is 1, or else the graph restarts from collecting documents from Tavily for generated queries to retrieve related info.
- To improve performance and avoid reaching limit of free tier of Google Generative AI, I limited the length of the response/report to be min 200 words.
- INTERNAL DOCUMENTATION
- Access to documents to reliable sources for academic sources (sciencedirect, elsevier, springer, ...)
- Construct more detail report (e.g Write report for each query)
- Human input (e.g research plan, sources to fetch documents for queries)
Customize LLMs, retrievers and report length in config.yaml
-
Install Python 3.12 or later. Guide.
-
Clone the project and navigate to the directory:
git clone https://github.com/maihoangbichtram/multi_agentic_rag cd multi_agentic_rag
-
Set up API keys by exporting them or storing them in a
.env
file.Copy .env.example to .env
-
Create and Activate virtual environment
4.1 In terminal: Create a virtual environment
python3 -m venv .venv
Activate the virtual environment
. .venv/bin/activate
4.2 Poetry
poetry shell
-
Install dependencies and start the server:
5.1 In terminal:
pip install -r requirements.txt
5.2 Poetry
poetry install
-
Start the application
6.1 In terminal:
python app/main.py
6.2 Poetry
poetry run uvicorn app.main:app --reload --timeout-keep-alive 720
- Google Cloud Account
- Google CLI
- Service account under IAM (to access to Google Cloud services.)
- (Access) Key downloaded as json (for the service account)
- main.tf
- variables.tf
- terraform.tfvars (not public): Declare values for variables
# GCP settings project_id = "project_id" # GCP region region = "europe-west3" # Artifact registry repository registry_id = "registry_id"
Run commands in order
terraform init
terraform plan
terraform apply
: create the GCP resources
Enable GCP APIs manually if Terraform reports errors with permission:
gcloud services enable artifactregistry.googleapis.com
gcloud services enable run.googleapis.com
- Create
requirements.txt
for docker file
poetry export -f requirements.txt --output requirements.txt
docker build --pull --rm -f "Dockerfile" -t <image_name>:latest "."
docker run --rm -it -p 8080:8080/tcp <image_name>:latest
- Create builder
docker buildx create --name <builder_name> --bootstrap --use
- Build the image
docker buildx build --file Dockerfile \
--platform linux/amd64 \
--builder <builder_name> \
--progress plain \
--build-arg DOCKER_REPO=<gcd_region>-docker.pkg.dev/<gcd_project_id>/<gcd_repository_name>/ \
--pull --push \
--tag <gcd_region>-docker.pkg.dev/<gcd_project_id>/<gcd_repository_name>/<image_name>:latest .
Added necessary API keys for the app to run probably.
If you configure OpenAI for llm
, add env var OPENAI_API_KEY
.
gcloud run deploy app \
--image <gcd_region>-docker.pkg.dev/<gcd_project_id>/<gcd_repository_name>/<image_name>:latest \
--region <gcd_region> \
--platform managed \
--allow-unauthenticated \
--set-env-vars GOOGLE_API_KEY=<GOOGLE_API_KEY>,TAVILY_API_KEY=<TAVILY_API_KEY>,CO_API_KEY=<CO_API_KEY>