Skip to content

RajkumarManala1/DisputeAI-Financial-Dispute-Resolution-with-RAG-and-Agentic-AI-on-Azure

Repository files navigation

🏦 DisputeAI — Financial Dispute Resolution with RAG + Agentic AI

An AI-powered financial dispute resolution system built on Azure, demonstrating Retrieval-Augmented Generation (RAG) and Agentic AI workflows for enterprise compliance use cases.

Python Azure OpenAI Azure AI Search Streamlit


Architecture

Sample Dispute Docs (12 policy documents)
        ↓
Azure Blob Storage (document store)
        ↓
Chunking + Embedding (Python + text-embedding-3-small)
        ↓
Azure AI Search (vector index, 52 chunks)
        ↓
Azure OpenAI GPT-4o (chat completions)
        ↓
Agentic Workflow (classify → retrieve → validate → respond/escalate)
        ↓
Streamlit Frontend (demo UI with audit trail)

Features

RAG Pipeline

  • Document Chunking: Splits 12 compliance documents into ~500-token overlapping segments
  • Vector Embeddings: Azure OpenAI text-embedding-3-small (1,536 dimensions)
  • Hybrid Search: Azure AI Search with vector similarity + semantic ranking
  • Grounded Responses: GPT-4o generates answers citing specific policy sections

Agentic Workflow

Multi-step AI workflow mimicking a real dispute analyst:

Step Agent Purpose
1 Classify Categorize dispute type (BILLING, FRAUD, UNAUTH, MERCHANT) and applicable regulation
2 Retrieve Pull targeted policy sections based on classification
3 Validate Check compliance, PII safety, completeness, and confidence
4 Respond/Escalate Generate resolution guidance OR escalate to human review

Escalation Logic

Cases are automatically escalated when:

  • Classification confidence < 70%
  • Compliance validation fails
  • Dispute amount exceeds $5,000
  • Validation confidence score < 70%

Human-in-the-Loop

Escalated cases include the full audit trail for human review, maintaining accountability and compliance.


Knowledge Base

12 internal policy documents covering:

Document Content
Dispute Resolution Policy Master policy — categories, regulations, intake, investigation
Regulation E Compliance Guide Debit/EFT disputes — timelines, provisional credit, liability
Regulation Z Compliance Guide Credit card billing errors — chargeback codes, protections
Chargeback Processing Procedures Chargeback lifecycle — reason codes, representment, arbitration
Fraud Investigation Procedures Fraud tiers, indicators, card blocking, SAR filing
Billing Dispute Handling Guide Duplicate charges, wrong amounts, not received, cancelled recurring
Merchant Dispute Guidelines Category-specific rules, high-risk merchants
Customer Communication Templates Acknowledgment, provisional credit, resolution letters
Escalation Matrix & SLA Guide 4-tier escalation, SLA targets, breach consequences
Provisional Credit Policy Eligibility, calculation, reversal rules
Evidence Collection Standards Evidence requirements by dispute type
Quality Assurance Checklist 100-point scoring, regulatory compliance checks

Tech Stack

Component Service
LLM Azure OpenAI GPT-4o
Embeddings Azure OpenAI text-embedding-3-small
Vector Search Azure AI Search (free tier)
Document Storage Azure Blob Storage
Frontend Streamlit
Language Python 3.10+

Setup

Prerequisites

  • Azure subscription with Azure OpenAI access
  • Python 3.10+
  • Azure CLI

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/disputeai.git
cd disputeai

2. Create virtual environment

python3 -m venv venv
source venv/bin/activate  # Mac/Linux
# venv\Scripts\activate   # Windows
pip install -r requirements.txt

3. Azure Setup

# Create resource group
az group create --name rg-disputeai --location eastus2

# Create storage account
az storage account create --name stadisputeai --resource-group rg-disputeai --location eastus2 --sku Standard_LRS
az storage container create --name dispute-documents --account-name stadisputeai

# Create AI Search (free tier)
az search service create --name search-disputeai --resource-group rg-disputeai --location eastus2 --sku free

# Create OpenAI resource
az cognitiveservices account create --name openai-disputeai --resource-group rg-disputeai --location eastus2 --kind AIServices --sku S0

# Deploy models
az cognitiveservices account deployment create --name openai-disputeai --resource-group rg-disputeai --deployment-name embedding-small --model-name text-embedding-3-small --model-version "1" --model-format OpenAI --sku-name GlobalStandard --sku-capacity 10

az cognitiveservices account deployment create --name openai-disputeai --resource-group rg-disputeai --deployment-name gpt-4o --model-name gpt-4o --model-version "2024-11-20" --model-format OpenAI --sku-name GlobalStandard --sku-capacity 10

4. Configure environment

Create a .env file:

AZURE_OPENAI_ENDPOINT=https://openai-disputeai.cognitiveservices.azure.com/
AZURE_OPENAI_API_KEY=your-key-here
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=embedding-small
AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-4o
AZURE_OPENAI_API_VERSION=2024-10-21
AZURE_SEARCH_ENDPOINT=https://search-disputeai.search.windows.net
AZURE_SEARCH_API_KEY=your-key-here
AZURE_SEARCH_INDEX_NAME=dispute-knowledge-base
AZURE_STORAGE_CONNECTION_STRING=your-connection-string-here
AZURE_STORAGE_CONTAINER=dispute-documents

5. Index documents

python3 index_documents.py --source local

6. Test search

python3 test_search.py

7. Run the app

streamlit run app.py

Sample Scenarios

Try these in the chat interface:

  • "Customer says they were charged twice for the same Netflix subscription of $15.99"
  • "Customer's debit card was stolen. They see 3 unauthorized transactions totaling $2,300"
  • "Customer cancelled gym membership 2 months ago but is still being charged $49.99 monthly"
  • "Customer ordered a laptop for $1,299 — tracking shows delivered but they never received it"
  • "Customer's credit card was used for a $15,000 wire transfer they don't recognize" (triggers escalation)

Project Structure

disputeai/
├── documents/              # 12 policy documents (knowledge base)
├── index_documents.py      # Document chunking, embedding, indexing pipeline
├── test_search.py          # Search index verification
├── rag_engine.py           # RAG query engine + agentic workflow
├── app.py                  # Streamlit demo UI
├── requirements.txt        # Python dependencies
├── .env                    # Azure credentials (not in repo)
└── .gitignore

Author

Raj Kumar Manala


License

This project is for educational and demonstration purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages