Implement comprehensive LLM provider system with global cost protection

- Add multi-provider LLM architecture supporting OpenRouter, OpenAI, Gemini, and custom providers
- Implement global LLM on/off switch with default DISABLED state for cost protection
- Add per-character LLM configuration with provider-specific models and settings
- Create performance-optimized caching system for LLM enabled status checks
- Add API key validation before enabling LLM providers to prevent broken configurations
- Implement audit logging for all LLM enable/disable actions for cost accountability
- Create comprehensive admin UI with prominent cost warnings and confirmation dialogs
- Add visual indicators in character list for custom AI model configurations
- Build character-specific LLM client system with global fallback mechanism
- Add database schema support for per-character LLM settings
- Implement graceful fallback responses when LLM is globally disabled
- Create provider testing and validation system for reliable connections
This commit is contained in:
root
2025-07-08 07:35:48 -07:00
parent 004f0325ec
commit 10563900a3
59 changed files with 6686 additions and 791 deletions

View File

@@ -35,7 +35,7 @@ LLM_API_KEY=x
LLM_TIMEOUT=300
LLM_MAX_TOKENS=2000
LLM_TEMPERATURE=0.8
LLM_MAX_PROMPT_LENGTH=6000
LLM_MAX_PROMPT_LENGTH=16000
LLM_MAX_HISTORY_MESSAGES=5
LLM_MAX_MEMORIES=5
@@ -46,6 +46,29 @@ ADMIN_USERNAME=admin
ADMIN_PASSWORD=FIre!@34
SECRET_KEY=CAKUZ5ds49B1PUEWDWt07TdgxjTtDvvxOOkvOOfbnDE
# LLM Provider Configuration
# OpenRouter (supports Claude, GPT, Llama, etc.)
OPENROUTER_ENABLED=false
OPENROUTER_API_KEY=
OPENROUTER_MODEL=anthropic/claude-3-sonnet
# OpenAI
OPENAI_ENABLED=false
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4o-mini
# Google Gemini
GEMINI_ENABLED=false
GEMINI_API_KEY=
GEMINI_MODEL=gemini-1.5-flash
# Custom/Local LLM (current setup)
CUSTOM_LLM_ENABLED=true
# Ollama
OLLAMA_ENABLED=false
OLLAMA_MODEL=llama3
# System Configuration
CONVERSATION_FREQUENCY=0.5
RESPONSE_DELAY_MIN=1.0