The Claim Chatbot is a Python-based application designed to assist with generating and managing auto insurance test claims. It leverages modern frameworks like FastAPI, Streamlit, and SQLAlchemy to offer a seamless experience for creating, extracting, and managing claims.
- Claim Synthesis: Automatically fills in missing details for partial claims using
synthesizer.py. - Information Extraction: Extracts claim details from user input using AI-powered models (
extraction_agent.py). - API Backend: FastAPI backend with endpoints to create, retrieve, and list claims.
- Interactive Chatbot: Streamlit-based chatbot interface for describing incidents and generating claims.
- Database Integration: Stores and manages claims data using SQLite.
Follow these steps to set up the project:
-
Clone the Repository
git clone https://github.com/your-repo/claim-chatbot.git cd claim-chatbot -
Set Up a Virtual Environment
python3 -m venv venv source venv/bin/activate -
Install Dependencies
pip install -r requirements.txt
-
Set Up the Database
The SQLite database is automatically created when the FastAPI app is started.
Run the FastAPI server in the first terminal:
uvicorn app.main:app --reloadThe API will be available at: http://127.0.0.1:8000
You can set your OPENAI_API_KEY in one of the following ways:
Run the following command in your terminal:
export OPENAI_API_KEY="your-api-key-here"You may also choose to set this in your .zshrc file for Mac, or the windows environment variable
Create a .env file in the project root directory and add the following line:
OPENAI_API_KEY=your-api-key-here
Make sure to install the python-dotenv package if not already installed:
pip install python-dotenvRun the Streamlit chatbot interface in the second terminal:
streamlit run chatbot.pyThe chatbot will open in your default web browser.
claim-chatbot/
├── app/
│ ├── __init__.py # App module initializer
│ ├── crud.py # CRUD operations for claims
│ ├── database.py # DB configuration and session management
│ ├── main.py # FastAPI app with endpoints
│ ├── models.py # SQLAlchemy models
│ ├── schemas.py # Pydantic schemas for API validation
├── chatbot.py # Streamlit chatbot interface
├── extraction_agent.py # AI-powered information extraction agent
├── synthesizer.py # Claim synthesizer logic
├── requirements.txt # Python dependencies
├── README.md # Project documentation
-
POST /claims/
Create a new claim
Request Body:ClaimCreateschema
Response: Created claim -
GET /claims/{claim_id}
Retrieve a claim by ID
Response:Claimschema -
GET /claims/
List all claims
Response: List ofClaimschemas
- Fills in missing claim details using predefined data and randomization.
- Example: Generates policy numbers, adjuster names, and incident descriptions.
- Uses AI (e.g., GPT-4) to extract claim details from text.
- Example: Extracts vehicle info and incident context.
- Interactive Streamlit chatbot for incident input.
- Connects to FastAPI backend to create and manage claims.
- Contains FastAPI backend code, including:
- DB models
- Pydantic schemas
- CRUD logic
The project uses the following libraries:
- FastAPI – Backend API framework
- Streamlit – Chatbot frontend
- SQLAlchemy – Database ORM
- Pydantic – Data validation
- OpenAI – AI-based extraction
- Faker – Synthetic data generation
Install all using:
pip install -r requirements.txt- Integrate additional AI models for better accuracy
- Use LLM to match the POI (Point of Impact) with the incident.
- Expand database support to PostgreSQL and others
- Add advanced logging and error handling
This project is licensed under the MIT License. See the LICENSE file for details.