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

@@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js for frontend build
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
# Copy requirements first for better caching
@@ -26,20 +26,30 @@ COPY migrations/ ./migrations/
COPY alembic.ini ./
# Build frontend
COPY admin-frontend/ ./admin-frontend/
COPY admin-frontend/package*.json ./admin-frontend/
WORKDIR /app/admin-frontend
# Clear any existing node_modules and lock files
RUN rm -rf node_modules package-lock.json yarn.lock
# Install dependencies first (better caching)
RUN npm install --silent
# Install dependencies with npm (using .npmrc config)
RUN npm install
# Copy frontend source code
COPY admin-frontend/ ./
# Build with increased memory for Node.js
# Build with increased memory for Node.js and disable optimization
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Build React app or create fallback
RUN npm run build || mkdir -p build
RUN test -f build/index.html || echo "<html><body><h1>Discord Fishbowl Admin</h1><p>Interface loading...</p></body></html>" > build/index.html
ENV GENERATE_SOURCEMAP=false
ENV DISABLE_ESLINT_PLUGIN=true
ENV CI=false
ENV REACT_APP_API_URL=""
ENV PUBLIC_URL="/admin"
ENV TSC_COMPILE_ON_ERROR=true
ENV ESLINT_NO_DEV_ERRORS=true
# Build React app
RUN npm run build
# Verify build output
RUN ls -la build/ && test -f build/index.html
# Back to main directory
WORKDIR /app
@@ -51,7 +61,7 @@ RUN mkdir -p logs
ENV PYTHONPATH=/app/src
# Expose admin port
EXPOSE 8000
EXPOSE 8294
# Run the admin interface
CMD ["python", "-m", "src.admin.app"]