This repository accompanies the tutorial article
RAG Agent with Custom Tool: Development to Deployment
on Medium
FinAgent is a retrieval-augmented generation (RAG) financial insights agent that delivers real-time, context-aware explanations of market trends and financial concepts.
It leverages LangChain, FAISS, LangGraph, and GPT-4o, storing conversation history in PostgreSQL for persistent context.
Response
Query:
"Explain NVDA trend from 01/01/2024 to 01/01/2025"
- 🧠 RAG pipeline: Uses LangChain + FAISS for retrieval + LangGraph orchestration to deliver detailed, explainable answers.
- 🔗 FastAPI service: Exposes an HTTP GET
/
endpoint for real-time querying. - 🗄 Persistent history: Saves conversation state to PostgreSQL using
psycopg_pool
andPostgresSaver
. - ⚙️ Scalable deployment: Containerized with Docker, deployable via Kubernetes.
- LangChain, FAISS, LangGraph, GPT-4o
- FastAPI
- PostgreSQL
- Docker & Kubernetes
- Python 3.9+
- Docker
- Kubernetes (e.g., Minikube)
- PostgreSQL instance
- Clone the repository:
git clone https://github.com/raoashish10/FinAgent.git
cd finagent
- Create
.env
file:
touch .env
Example .env
:
DB_URI=postgresql://username:password@host:port/dbname
OPENAI_API_KEY=your_openai_key
- Install dependencies:
pip install -r requirements.txt
The API is served by default at localhost:8000.
✅ curl example:
curl -X 'GET' 'http://127.0.0.1:8000/?query=Explain%20NVDA%20trend%20from%2001%2F01%2F2024%20to%2001%2F01%2F2025' -H 'accept: application/json'
📄 Example response (as seen in FastAPI docs):
{
"response": "NVIDIA's stock trend between January 2024 and January 2025 shows..."
}
minikube start
kubectl apply -f kubernetes/postgres-deployment.yaml
kubectl apply -f kubernetes/finagent-api-deployment.yaml