This project implements a sophisticated multi-agent system for generating personalized, context-aware quotes for complex products and services. It leverages LangChain/LangGraph to create an intelligent quoting workflow that incorporates:
- Retrieval-Augmented Generation (RAG) for context-sensitive data retrieval
- Multi-Agent Architecture with specialized roles
- Intelligent Classification using sentiment analysis
- Dynamic Workflow Management through a state graph system
- Database Integration for storing category rates
pip install langgraph pip install langchain-core pip install langchain-openai pip install langchain-groq pip install langchain-community pip install python-dotenv pip install pydantic pip install typing-extensions pip install chromadb pip install langchain-text-splitters
Create a .env
file with the following:
OPENAI_API_KEY=your_openai_key
LANGCHAIN_API_KEY=your_langchain_key
GROQ_API_KEY=your_groq_key
LANGCHAIN_TRACING_V2=optional
LANGCHAIN_PROJECT=optional
-
Database Setup
- SQLite database for category rates
- Predefined categories with associated rates
- Automated table creation and data population
-
Assistants
- Main Assistant: Guides users through information gathering
- Underwriting Assistant: Evaluates risk and validates categories
- Quote Assistant: Calculates and presents final premiums
-
Agents
- Retriever Agent: Extracts and summarizes business operations
- Reasoning Agent: Determines relevant insurance categories
- Classification Grading Agent: Evaluates category assignments
- Quote Generation Agent: Calculates final premiums
-
State Management
- MainState: Core workflow state
- RAGState: Retrieval state
- ExtraState: Additional workflow data
-
Routing Nodes
route_main_assistant
: Manages main assistant flowroute_underwriting_assistant
: Handles underwriting transitionsroute_quote_assistant
: Controls quote generation flowroute_to_workflow
: Determines assistant routing- Additional utility nodes for state updates and message handling
- Open the Jupyter notebook (
contextual_quoting_agentic_system.ipynb
) - Run all cells in sequence
- The system will prompt you for input when ready
- Type your questions/responses when prompted
- Type '/exit' to end the session
- Intelligent matching of business descriptions to categories
- Grade-based evaluation of category relevance
- Contextual understanding of business operations
- Revenue-based premium calculation
- Multi-category rate application
- Dynamic rate adjustment based on business complexity
- State-based conversation flow
- Error handling and fallback mechanisms
- Conditional routing between assistants
Hector -> hector@hetoll.com