Files
DeepTutor/.env.example
Bingxi Zhao (Frank) 2c39eb4fc9 feat(embedding): tri-state send_dimensions toggle (UI + env + catalog)
Generalises #368: adds an explicit per-model `send_dimensions` opt-in
exposed as a Settings UI toggle and an EMBEDDING_SEND_DIMENSIONS env var.

Tri-state semantics:
  true   -> always send (user knows their provider supports it)
  false  -> never send  (e.g. Qwen text-embedding-v4 via litellm gateway
                         which returns HTTP 400 when `dimensions` is sent)
  unset  -> fall back to the text-embedding-3* heuristic from #368

Backend:
- Adapter base accepts `send_dimensions`; OpenAI-compatible adapter
  decides via `_should_send_dimensions(model)` (replaces the hardcoded
  startswith check from #368).
- ResolvedEmbeddingConfig / EmbeddingConfig carry the flag through.
- EnvStore reads/writes EMBEDDING_SEND_DIMENSIONS, dropping the line
  entirely when empty so legacy `.env` files keep the Auto behaviour.
- ModelCatalogService syncs the flag from .env back into the catalog.

Frontend:
- Settings page shows a "Send dimensions" checkbox next to Dimension,
  with an instant CSS-only info tooltip (replaces native `title` to
  avoid the browser's ~1s delay). Disabling the toggle greys out the
  Dimension input.
- New models default to send_dimensions=true.
- en/zh i18n strings added.

Tests (46 new cases, including the unit tests #368 marked added but
did not actually ship):
- adapter `_should_send_dimensions` tri-state + parametrized non-3 family
- httpx-mocked payload assertions for all four combinations
- runtime resolver: catalog wins over env, garbage values -> None
- env_store helpers + render_from_catalog + write skip-empty round-trip
- EmbeddingClient propagates the flag to the adapter config dict

Made-with: Cursor
2026-04-23 20:16:08 +08:00

76 lines
2.9 KiB
Plaintext

# ============================================
# DeepTutor Environment Template
# ============================================
# Copy this file to `.env` and fill in your values.
# Core runtime settings are grouped as:
# ports / llm / embedding / search / docker-cloud / security
# --------------------------------------------
# Ports
# --------------------------------------------
BACKEND_PORT=8001
FRONTEND_PORT=3782
# --------------------------------------------
# LLM (Required)
# --------------------------------------------
# Supported bindings: openai, lm_studio, ollama, azure_openai, deepseek, ...
# For a full list run: deeptutor provider list // README
LLM_BINDING=openai
LLM_MODEL=gpt-4o-mini
LLM_API_KEY=sk-xxx
LLM_HOST=https://api.openai.com/v1
LLM_API_VERSION=
# --------------------------------------------
# Embedding (Required for knowledge base features)
# --------------------------------------------
EMBEDDING_BINDING=openai
EMBEDDING_MODEL=text-embedding-3-large
EMBEDDING_API_KEY=sk-xxx
EMBEDDING_HOST=https://api.openai.com/v1
EMBEDDING_DIMENSION=3072
EMBEDDING_API_VERSION=
# Whether to send the `dimensions` request parameter to the embedding endpoint.
# true -> always send (only OpenAI text-embedding-3* officially supports it)
# false -> never send (set this for Qwen text-embedding-v4 and other providers
# that return HTTP 400 when `dimensions` is present)
# <empty> or unset -> auto: send only for OpenAI text-embedding-3* family
EMBEDDING_SEND_DIMENSIONS=
# ⚠️ Docker + local LLM (LM Studio / Ollama / vLLM)
# ─────────────────────────────────────────────────────
# When running DeepTutor in Docker and your LLM runs on the HOST machine:
# - Do NOT use "localhost" or "127.0.0.1" — inside the container these
# refer to the container itself, not the host.
# - macOS / Windows Docker Desktop: use http://host.docker.internal:<port>/v1
# - Linux: use the host's LAN IP, e.g. http://192.168.1.100:<port>/v1
# (or run Docker with --network=host)
#
# Example (LM Studio on port 1234):
# LLM_BINDING=lm_studio
# LLM_HOST=http://host.docker.internal:1234/v1
# EMBEDDING_BINDING=lm_studio
# EMBEDDING_HOST=http://host.docker.internal:1234/v1
# --------------------------------------------
# Web Search (Optional)
# --------------------------------------------
SEARCH_PROVIDER=
SEARCH_API_KEY=
SEARCH_BASE_URL=
# --------------------------------------------
# Docker / Cloud deployment (Optional)
# --------------------------------------------
# Public backend URL used by the frontend when deployed remotely.
NEXT_PUBLIC_API_BASE_EXTERNAL=
# Alternative direct API base URL.
NEXT_PUBLIC_API_BASE=
# --------------------------------------------
# Security / Networking (Optional)
# --------------------------------------------
# Keep this false in production.
DISABLE_SSL_VERIFY=false