Skip to content

feat: LiteLLM model settings, dynamic discovery, and UI selectors - #20

Merged
spelech merged 7 commits into
mainfrom
feat/litellm-model-settings-and-discovery
Sep 8, 2026
Merged

feat: LiteLLM model settings, dynamic discovery, and UI selectors#20
spelech merged 7 commits into
mainfrom
feat/litellm-model-settings-and-discovery

Conversation

@spelech

@spelech spelech commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

This pull request brings full dynamic LiteLLM model discovery, configuration, and classification to the ContextCortex UI, allowing operators to dynamically query upstream LiteLLM endpoints, inspect available models by capability, and persist dense embedding, sparse embedding, Vision AI OCR, and general chat model selections without restarting containers.

Key Changes

  1. Dynamic Model Discovery Service (app/services/litellm_service.py):

    • Implements discover_models() to query upstream LiteLLM /v1/models.
    • Categorizes models into Embeddings (embedding_models), Vision OCR fallback models (vision_models), and Chat models (chat_models).
    • Resilient error handling with non-blocking fallbacks if LiteLLM is unreachable or unauthenticated.
  2. Model Persistence & Hot-Reloading (app/services/database/connection.py, app/services/embeddings.py):

    • Persists vision_ocr_model and chat_model alongside litellm_url, litellm_api_key, and embedding models in SQLite/Postgres system_metadata.
    • Hot-reloaded in-memory so newly selected models take effect immediately.
    • Updated app/services/pdf_extractor.py to use dynamic vision model for PDF OCR fallbacks.
  3. REST API Endpoints (app/api/routers/settings.py):

    • Added GET /admin/api/models/discover accepting optional url and api_key query parameters.
    • Updated POST /admin/api/settings/embedding to accept and save vision_ocr_model and chat_model.
    • Updated GET /admin/api/stats to return full model configurations.
  4. Frontend UI (frontend/src/components/settings/EmbeddingSettings.tsx, Settings.tsx):

    • Added Discover LiteLLM Models action button with spinner and status badge reporting total and categorized models found.
    • Replaced static text inputs with dynamic capability-filtered dropdowns for Dense Embeddings, Vision OCR Fallback, and Default Chat Model.
    • Added custom manual entry toggle (-- Custom / Enter manually --) allowing manual model override when needed.
  5. Test Coverage & Verification:

    • 100% test pass across backend Pytest (492 tests passed) and frontend Vitest (284 tests passed across 27 test files).
    • Verified live with homelab LiteLLM returning 50 models.
    • Production frontend build verified with npm run build.

@spelech
spelech merged commit dbec496 into main Sep 8, 2026
2 checks passed
@spelech
spelech deleted the feat/litellm-model-settings-and-discovery branch September 8, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant