LiabilityIQ now includes AI-powered document summarization and analysis using OpenAI's GPT models. The system can work with or without AI - if AI is disabled or unavailable, it falls back to pattern matching.
- Document Summarization: AI generates concise, contextual summaries of each document
- Entity Extraction: AI extracts structured entities (names, dates, locations, etc.)
- Risk Analysis: AI identifies potential risks and issues
- Recommendations: AI generates actionable recommendations
-
Get an API Key:
- Sign up at https://platform.openai.com
- Create an API key in your account settings
-
Set Environment Variable:
# Windows PowerShell $env:OPENAI_API_KEY="your-api-key-here" # Windows CMD set OPENAI_API_KEY=your-api-key-here # Linux/Mac export OPENAI_API_KEY="your-api-key-here"
-
Enable AI in Config: Edit
config/config.yaml:ai: enabled: true model: "gpt-4o-mini" # or "gpt-4", "gpt-3.5-turbo"
-
Install Dependencies:
pip install openai>=1.0.0
Edit config/config.yaml:
ai:
enabled: falseThe system will automatically use pattern matching fallbacks.
When AI is enabled, you'll see:
-
Processing Page: Shows animated AI processing steps
- 🤖 AI icon with pulsing animation
- Step-by-step progress indicators
- AI-specific step highlighting (purple border)
-
Dossier Header: Shows "🤖 AI-Powered" badge
-
Console Output: Shows "✓ AI/LLM service initialized" on startup
In config/config.yaml:
ai:
enabled: true # Enable/disable AI
provider: "openai" # Provider (currently only OpenAI)
model: "gpt-4o-mini" # Model to use
api_key_env: "OPENAI_API_KEY" # Environment variable name
use_ai_for_summarization: true # Use AI for document summaries
use_ai_for_entity_extraction: true # Use AI for entity extraction
use_ai_for_risk_analysis: true # Use AI for risk analysis
use_ai_for_recommendations: true # Use AI for recommendations- gpt-4o-mini: ~$0.15 per 1M input tokens, ~$0.60 per 1M output tokens
- gpt-4: ~$30 per 1M input tokens, ~$60 per 1M output tokens
For MVP/demo purposes, gpt-4o-mini is recommended as it's cost-effective and provides good quality.
If AI is unavailable or fails:
- System automatically falls back to pattern matching
- No errors are thrown
- Processing continues normally
- Warning messages are logged
-
With AI Enabled:
export OPENAI_API_KEY="your-key" python web_app.py
Process a claim and watch the AI processing indicators.
-
Without AI:
# Edit config.yaml: ai.enabled = false python web_app.pySystem uses pattern matching (faster, no API costs).
- Set the environment variable (see Setup above)
- Or disable AI in config
- Check your API key is valid
- Check you have API credits
- System will automatically fall back to pattern matching
- AI processing takes 5-15 seconds per document
- Consider using
gpt-4o-miniinstead ofgpt-4 - Or disable AI for faster processing
- Support for local models (Ollama, etc.)
- Caching of AI responses
- Batch processing optimization
- Custom prompt templates
- Multi-model support