Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatbot example with Agentic RAG for an insurance company

This chatbot is built using an Agentic RAG approach and FastAPI. It leverages the Mixtral-8x7B model with Chroma database and incorporates three tools corresponding to different RAG implementations: FAQ queries, product details queries, and occupation-based insurance product queries.

* The Mixtral-8x7B model is free to run. You may improve the overal performance of the agent using a more powerful LLM such as GPT 3.5 or later.

Diagram

Agent Architecture Diagram

Sample run demo

Watch the video

Features

  • Interactive chat interface
  • Agentic RAG
  • Web-based UI using FastAPI and Jinja2 templates
  • Chroma DB

Prerequisites

  • Python 3.11+
  • FastAPI
  • LangChain
  • LangSmith API key
  • NVIDIA AI API key
  • Uvicorn

Project Structor

project_root/
│
├── assets/
│   ├── chat_screen.webm
│   └── diagram.jpg   
├── data/
│   ├── raw:JSON, CSV
│   └── vector: ChormaDB
├── src/
│   ├── __init__.py
│   ├── agent.py
│   ├── config.py
│   ├── data_classes.py
│   ├── db_creator.py
│   ├── rags.py
│   ├── utils.py
│   └── templates/
│       └── indexes.html
│── tests/
│   ├── __init__.py
│   └── test_rag.py      
├── README.md
├── Dockerfile
└── requirements.txt

Installation

To locally run the agent use the following steps

  1. Clone the repository:
git clone https://github.com/YJonmo/agentic_rag.git
cd agentic_rag
  1. Create a virtual env:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Get an API key from Nvidia website and an API key for LangSmith and place them in your .env file using the following commands:
echo NVIDIA_API_KEY="your-nvidia-api-key" >> .env
echo LANGSMITH_API_KEY="your-langsmith-key" >> .env
  1. Run the following file to create a vector DB from the JSON and the CSV files in the data/raw folde:
python src/db_creator.py
  1. Test the vector DB:
pytest

If there was not error then the vector DB is created inside the .data/vector folder.

  1. Run the agent locally:
uvicorn src.agent:app --host 0.0.0.0 --port 8000 --reload
  1. Open a web browser at:
http://0.0.0.0:8000/

You could build the docker image and deploy either locally or in the cloud

  1. Build the docker image:
docker build -t agentic_rag .
  1. Run the docker image:
docker run -e NVIDIA_API_KEY="your-nvidia-api-key" -p 8000:8000 agentic_rag

About

Agentic RAG for FAQ and other purposes. Accepts JSON and CSV files as input to create a Chroma database.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages