LLM Service Integration Plan
Executive Summary
Current State Analysis
Files Using OPENAI_API_KEY (126 files found)
Files Using ANTHROPIC_API_KEY (37 files found)
Current LLM Architecture
Orchestrator LLM Provider (services/llm_provider.py)
services/llm_provider.py)LLM Service (Reference Implementation)
Credential System (PRD-18)
System Settings
Target Architecture
Refactored LLM Provider Structure
Key Features
Integration Points
1. System Settings Integration
2. Credential Resolution Flow
3. Service-Specific Configuration
Implementation Plan
Phase 1: Refactor Existing LLM Provider Service
Step 1.1: Create Clients Directory Structure
Step 1.2: Move Existing Base Classes
Step 1.3: Split Provider Clients into Separate Files
Step 1.4: Refactor Main LLM Service
Phase 2: Integrate with System Settings
Step 2.1: Update System Settings Model
Step 2.2: Update OrchestratorLLMSettingsTab
Step 2.3: Update CodeGraphSettingsTab
Phase 3: Migrate Existing Services
Step 3.1: Update LLM Provider Service
Step 3.2: Update CodeGraph Service
Step 3.3: Update CodeGraph API
Step 3.4: Update Chatbot LLM API
Phase 4: Update Other Services
Step 4.1: Document Processing
Step 4.2: Embeddings Service
Step 4.3: RAG Service
Phase 5: Add HuggingFace Support
Step 5.1: Create HuggingFace Client
Step 5.2: Update Credential Type
Phase 6: Testing & Validation
Step 6.1: Unit Tests
Step 6.2: Integration Tests
Step 6.3: User Journey Tests
File-by-File Migration Plan
Files Requiring Migration
High Priority (Core Services)
Medium Priority (Document Services)
Low Priority (Other Services)
Migration Strategy per File
Pattern 1: Direct API Key Usage
Pattern 2: Credential Resolver (Already Migrated)
Pattern 3: LLMManager Usage
Configuration Schema
System Settings Required
Orchestrator LLM Settings
CodeGraph LLM Settings
Credential Naming Convention
Error Handling Strategy
Lazy Loading Errors
Missing Credentials
Missing Settings
Testing Checklist
Unit Tests
Integration Tests
User Journey Tests
Deployment Checklist
Pre-Deployment
Deployment Steps
Post-Deployment
Success Criteria
Functional
Non-Functional
Timeline Estimate
Risks & Mitigations
Risk 1: Breaking Changes
Risk 2: Credential Resolution Failures
Risk 3: Performance Impact
Risk 4: Missing Provider Support
Next Steps
PreviousPRD 22: Anthropic-Style Dynamic Skill Loading via Git-Backed RepositoriesNextPRD-26: System Settings Audit - Current Status
Last updated

