Major updates: - Replace homepage with clean, minimalist Apple-style landing page - Focus on donation messaging and mission statement - Add comprehensive AI chat analysis documentation - Fix Azure OpenAI configuration with correct endpoints - Update embedding API to use text-embedding-ada-002 (1536 dims) Landing Page Features: - Hero section with tagline "Every Scripture. Every Language. Forever Free" - Mission statement emphasizing free access - Matthew 10:8 verse highlight - 6 feature cards (Global Library, Multilingual, Prayer Wall, AI Chat, Privacy, Offline) - Donation CTA sections with PayPal and card options - "Why It Matters" section with dark background - Clean footer with navigation links Technical Changes: - Updated .env.local with new Azure credentials - Fixed vector-search.ts to support separate embed API version - Integrated AuthModal into Bible reader and prayers page - Made prayer filters collapsible and mobile-responsive - Changed language picker to single-select Documentation Created: - AI_CHAT_FIX_PLAN.md - Comprehensive implementation plan - AI_CHAT_VERIFICATION_FINDINGS.md - Database analysis - AI_CHAT_ANALYSIS_SUMMARY.md - Executive summary - AI_CHAT_STATUS_UPDATE.md - Current status and next steps - logo.svg - App logo (MenuBook icon) Build: ✅ Successful (Next.js 15.5.3) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
9.8 KiB
AI Chat System Verification Findings
Date: 2025-10-10 Status: 🟡 Partially Operational - Configuration Issue Found
Executive Summary
The AI chat vector database is fully operational with 116 Bible versions across 47 languages, all with complete embeddings. However, there is a critical configuration issue with the Azure OpenAI API deployments that prevents the chat from functioning.
✅ What's Working
1. Vector Database Infrastructure (100% Operational)
- Database Connection: PostgreSQL 17.5 ✓
- pgvector Extension: v0.8.0 installed ✓
- Schema:
ai_bibleschema exists ✓
2. Bible Vector Tables (116 Tables - Fully Populated)
| Metric | Value |
|---|---|
| Total Vector Tables | 116 |
| Languages Supported | 47 |
| Embedding Coverage | 100% for all tables |
| Table Structure | Correct (all have embedding, tsv, ref, text_raw, etc.) |
Sample Table Statistics:
bv_ab_aau: 7,923 verses (100% embedded)bv_ac_aca: 4,406 verses (100% embedded)bv_ac_acr_acc: 7,930 verses (100% embedded)
3. Languages Available
The system currently supports 47 languages including:
- English (en): 9 versions (ASV, Brenton, KJV, KJV2006, LXX2012, RV, T4T, UK_LXX2012, WEB_C)
- German (de): 2 versions
- Dutch (nl): 3 versions
- French (fr): 1 version
- And 43+ other languages
Note: User requested support for Romanian (ro), Spanish (es), and Italian (it) but these languages are NOT found in the vector database. This is a critical gap.
4. Current Vector Search Implementation
The existing code in /root/biblical-guide/lib/vector-search.ts already implements:
- ✅ Multi-table search across all versions for a given language
- ✅ Hybrid search (vector + full-text)
- ✅ Language-based table filtering
- ✅ Proper query pattern:
bv_{lang}_{version}
❌ What's Broken
1. Azure OpenAI API Configuration (CRITICAL)
Problem: The deployment names in .env.local do not exist in the Azure OpenAI resource.
Environment Variables:
AZURE_OPENAI_DEPLOYMENT=gpt-4o # ❌ Deployment NOT FOUND (404)
AZURE_OPENAI_EMBED_DEPLOYMENT=embed-3 # ❌ Deployment NOT FOUND (404)
Error Message:
DeploymentNotFound: The API deployment for this resource does not exist.
Impact:
- Chat API cannot generate responses
- Embedding generation fails
- Vector search cannot create query embeddings
2. Missing Priority Languages
User Requirements: Romanian (ro), Spanish (es), Italian (it)
Current Status:
- ❌ Romanian (ro): NOT in vector database
- ❌ Spanish (es): NOT in vector database
- ❌ Italian (it): NOT in vector database
Available Languages: The current 47 languages are mostly obscure languages (ab, ac, ad, ag, etc.) and do NOT include the user's priority languages.
🔧 Required Fixes
Priority 1: Fix Azure OpenAI Deployments (IMMEDIATE)
Action Required:
- Identify the correct deployment names in the Azure OpenAI resource
- Update
.env.localwith correct values:AZURE_OPENAI_DEPLOYMENT=<actual-chat-deployment-name>AZURE_OPENAI_EMBED_DEPLOYMENT=<actual-embedding-deployment-name>
Options to Find Correct Deployment Names:
- Option A: Check Azure Portal → Azure OpenAI → Deployments
- Option B: Contact Azure admin who created the resource
- Option C: Check deployment history/documentation
Expected Deployment Patterns:
- Chat: Usually named like
gpt-4,gpt-4-32k,gpt-35-turbo, etc. - Embeddings: Usually named like
text-embedding-ada-002,text-embedding-3-small, etc.
Priority 2: Add Priority Language Vector Tables (HIGH)
Missing Tables Needed:
-- Romanian versions
ai_bible.bv_ro_cornilescu (Cornilescu Bible)
ai_bible.bv_ro_fidela (Fidela Bible - mentioned in BIBLE_MD_PATH)
-- Spanish versions
ai_bible.bv_es_rvr1960 (Reina-Valera 1960)
ai_bible.bv_es_nvi (Nueva Versión Internacional)
-- Italian versions
ai_bible.bv_it_nuovadiodati (Nuova Diodati)
ai_bible.bv_it_nuovariveduta (Nuova Riveduta)
Action Required:
- Verify if these Bible versions exist in source data
- Create embeddings for each version
- Import into
ai_bibleschema with proper naming
Priority 3: Implement English Fallback (MEDIUM)
Current Behavior:
- Search only looks in language-specific tables (e.g., only
bv_ro_*for Romanian) - If language not found, returns empty results
Required Behavior:
- Search in primary language tables first
- Check result quality (min 3 results, top similarity > 0.75)
- If insufficient → fallback to English (
bv_en_*tables) - Return combined results with language indicators
Implementation: Already planned in /root/biblical-guide/AI_CHAT_FIX_PLAN.md
📊 Current System Architecture
Vector Search Flow (Working)
User Query
↓
getEmbedding(query) ❌ FAILS HERE - Deployment Not Found
↓
searchBibleHybrid(query, language, limit)
↓
getAllVectorTables(language) ✓ Returns tables like ["ai_bible.bv_en_eng_kjv", ...]
↓
For each table:
- Vector similarity search (embedding <=> query)
- Full-text search (tsv @@ plainto_tsquery)
- Combine scores (0.7 * vector + 0.3 * text)
↓
Sort by combined_score and return top results
Chat API Flow (Partially Working)
User Message
↓
[Auth Check] ✓ Working
↓
[Conversation Management] ✓ Working
↓
generateBiblicalResponse(message, locale, history)
↓
searchBibleHybrid(message, locale, 5) ❌ FAILS - Embedding API 404
↓
[Build Context with Verses] ✓ Would work if embeddings worked
↓
[Call Azure OpenAI Chat API] ❌ FAILS - Chat API 404
↓
[Save to Database] ✓ Working
🎯 Implementation Plan
Phase 1: Fix Azure OpenAI (Day 1 - URGENT)
-
Identify Correct Deployments
- Check Azure Portal
- List all available deployments in the resource
- Document deployment names and models
-
Update Environment Configuration
- Update
.env.localwith correct deployment names - Verify API version compatibility
- Test connection with verification script
- Update
-
Validate Fix
- Run
npx tsx scripts/verify-ai-system.ts - Confirm both Chat API and Embedding API pass
- Test end-to-end chat flow
- Run
Phase 2: Add Priority Languages (Days 2-3)
-
Romanian (ro)
- Source Bible data for Cornilescu and Fidela versions
- Create embeddings using Azure OpenAI
- Import into
ai_bible.bv_ro_cornilescuandai_bible.bv_ro_fidela
-
Spanish (es)
- Source Bible data for RVR1960 and NVI
- Create embeddings
- Import into respective tables
-
Italian (it)
- Source Bible data for Nuova Diodati and Nuova Riveduta
- Create embeddings
- Import into respective tables
Phase 3: Implement Fallback Logic (Day 4)
-
Update
searchBibleHybridFunction- Add quality check logic
- Implement English fallback
- Add language indicators to results
-
Update Chat API Response
- Include source language in citations
- Inform user when fallback was used
- Format:
[KJV - English fallback] John 3:16
Phase 4: Testing (Day 5)
-
Test Each Language
- Romanian queries → Romanian results
- Spanish queries → Spanish results
- Italian queries → Italian results
- Unsupported language → English fallback
-
Test Edge Cases
- Empty results handling
- Mixed language queries
- Very specific vs. general queries
-
Performance Testing
- Query response time (target < 2s)
- Multi-table search performance
- Concurrent user handling
📝 Next Steps
Immediate Actions (Today)
- ✅ Run verification script (COMPLETED)
- ✅ Document findings (COMPLETED)
- 🔲 Fix Azure OpenAI deployment configuration
- Identify correct deployment names
- Update
.env.local - Re-run verification script
Short-term Actions (This Week)
- 🔲 Source Romanian Bible data (Cornilescu, Fidela)
- 🔲 Source Spanish Bible data (RVR1960, NVI)
- 🔲 Source Italian Bible data (Nuova Diodati, Nuova Riveduta)
- 🔲 Create embeddings for all priority language versions
- 🔲 Import into vector database
Medium-term Actions (Next 2 Weeks)
- 🔲 Implement English fallback logic
- 🔲 Add version metadata table (
bible_version_config) - 🔲 Create comprehensive test suite
- 🔲 Monitor performance and optimize queries
🚨 Critical Blockers
-
Azure OpenAI Deployment Names (Blocking ALL functionality)
- Cannot generate embeddings
- Cannot generate chat responses
- Need Azure admin access to resolve
-
Missing Priority Languages (Blocking user requirements)
- Romanian not available
- Spanish not available
- Italian not available
- Need Bible data sources and embeddings pipeline
📈 Success Metrics
Current Status:
- ✅ Database: 100%
- ❌ API Configuration: 0%
- ❌ Language Support: 0% (for priority languages)
- ⚠️ Code Implementation: 80% (search logic exists, just needs API fix)
Target Status:
- ✅ Database: 100%
- ✅ API Configuration: 100%
- ✅ Language Support: 100% (ro, es, it, en)
- ✅ Code Implementation: 100%
📚 Reference Documents
/root/biblical-guide/AI_CHAT_FIX_PLAN.md- Original implementation plan/root/biblical-guide/scripts/verify-ai-system.ts- Verification script/root/biblical-guide/lib/vector-search.ts- Current search implementation/root/biblical-guide/app/api/chat/route.ts- Chat API implementation
Contact & Support
Azure OpenAI Resource:
- Endpoint:
https://azureopenaiinstant.openai.azure.com - API Version:
2024-05-01-preview - Action Needed: Verify deployment names in Azure Portal
Vector Database:
- Host:
10.0.0.207:5432 - Database:
biblical-guide - Schema:
ai_bible - Status: ✅ Fully Operational