Files
rag-technical-docs-assistant/.env.example
T
amirhosein mazaheri 628aec8def feat(voice): implement local S2S responsiveness candidate and direct TTS routing
Add local S2S responsiveness candidate pinning ASR options and sentence-at-a-time generation. Route speech synthesis directly to OpenAI API for fluent Persian phonetics with gpt-4o-mini-tts-2025-12-15. Add responsiveness, budget carry, and browser watch unit tests along with acceptance benchmarks and evaluation evidence.
2026-10-17 13:02:41 +03:30

179 lines
8.0 KiB
Bash

# App Config
APP_NAME="Technical Documentation Assistant"
APP_VERSION="1.0.0"
APP_ENVIRONMENT="development"
# LLM Config
API_KEY="your-api-key-here"
LLM_BASE_URL="https://openrouter.ai/api/v1"
LLM_MODEL="gpt-4o-mini"
LLM_TEMPERATURE=0.0
LLM_MAX_TOKENS=2048
LLM_MAX_ITERATIONS=3
# RAG Config
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
DOCS_DIR="./data/documents"
CHROMA_PERSIST_DIR="./data/vector_db"
# Independent ingestion settings. Choose the real deployment profile explicitly.
INGEST_DATABASE_URL="postgresql+psycopg://user:password@localhost:5432/rag"
INGEST_EMBEDDING_PROVIDER=""
# HTTP(S) host/optional port/path only; no userinfo/query/fragment/encoded components.
INGEST_EMBEDDING_ENDPOINT=""
INGEST_EMBEDDING_MODEL=""
INGEST_EMBEDDING_DIMENSIONS=
# Not needed for schema/bootstrap; required by the hosted embedding adapter.
INGEST_EMBEDDING_API_KEY=""
INGEST_EMBEDDING_PREPROCESSING_VERSION="v1"
INGEST_EMBEDDING_TIMEOUT_SECONDS=60
INGEST_ORIGINAL_DIRECTORY="data/originals"
INGEST_ACCEPTED_FORMATS='[".pdf", ".md", ".docx", ".jpg", ".jpeg", ".png"]'
INGEST_MAX_ORIGINAL_BYTES=20971520
INGEST_MAX_PDF_PAGES=200
INGEST_MAX_NORMALIZED_CHARACTERS=1000000
INGEST_MAX_CHUNKS=2000
INGEST_CHUNK_SIZE_CHARACTERS=1000
INGEST_CHUNK_OVERLAP_CHARACTERS=200
INGEST_EMBEDDING_BATCH_SIZE=32
INGEST_MAX_STAGED_BYTES=134217728
INGEST_WORKER_CONCURRENCY=1
INGEST_POLL_SECONDS=2
INGEST_HEARTBEAT_SECONDS=20
INGEST_LEASE_SECONDS=120
INGEST_MAX_AUTOMATIC_ATTEMPTS=3
INGEST_RETRY_BASE_SECONDS=2
INGEST_RETRY_CAP_SECONDS=300
# Engineering deployment defaults, not product-owner approval. No OCR at intake.
INGEST_EXTRACTION_DIRECTORY="data/extractions"
INGEST_MAX_DOCX_ENTRIES=2048
INGEST_MAX_DOCX_MEMBER_BYTES=16777216
INGEST_MAX_DOCX_EXPANDED_BYTES=67108864
INGEST_MAX_DOCX_COMPRESSION_RATIO=200
INGEST_MAX_IMAGE_WIDTH=12000
INGEST_MAX_IMAGE_HEIGHT=12000
INGEST_MAX_IMAGE_PIXELS=40000000
INGEST_EXTRACTION_STRATEGY="direct-quality-fallback-v1"
# Optional identity: configure all three together; credentials are needed only for opt-in Phase 3 vision.
# INGEST_VISION_PROVIDER="<chosen-provider>"
# INGEST_VISION_ENDPOINT="https://provider.example.invalid/v1"
# INGEST_VISION_MODEL="<chosen-model>"
# INGEST_VISION_API_KEY="<secret>"
INGEST_VISION_TIMEOUT_SECONDS=60
INGEST_FALLBACK_POLICY="affected-pages-v1"
INGEST_QUALITY_POLICY="bounded-checks-manual-review-v1"
# INGEST_OCR_REVIEW_REQUIRED=true
# INGEST_FACTUAL_REVIEW_REQUIRED=true
# Preserve existing embedding preprocessing. New Persian normalization requires migration/reindex design.
INGEST_NORMALIZATION_POLICY="unicode-line-endings-v1"
INGEST_CHUNKING_POLICY="paragraph-v1"
INGEST_RENDER_DPI=144
INGEST_MAX_RENDERED_PAGE_PIXELS=20000000
INGEST_MAX_EXTRACTION_ARTIFACT_BYTES=33554432
INGEST_MAX_EXTRACTED_BLOCKS=10000
# Phase 4: select endpoint/model limits explicitly; no character-to-token estimate.
# INGEST_EMBEDDING_LIMITS='{"unit":"tokens","max_input_units":8192,"max_batch_units":300000,"max_batch_inputs":2048,"tokenizer":"tiktoken:cl100k_base"}'
# The example is NOT compatibility approval for an arbitrary endpoint/model.
INGEST_EMBEDDING_SEND_DIMENSIONS=false
INGEST_EMBEDDING_MAX_RESPONSE_BYTES=16777216
# Backend voice selection; Gemini is the temporary default. No automatic fallback.
# Legacy PROVIDER is accepted; do not set it differently from VOICE_PROVIDER.
VOICE_PROVIDER=gemini
# Additional per-session UI choices; empty preserves default-provider-only admission.
VOICE_SELECTABLE_PROVIDERS=[]
GEMINI_API_KEY=
GEMINI_MODEL=gemini-2.0-flash-exp
GEMINI_VOICE=Aoede
# GEMINI_PROXY=https://trusted-proxy.example:443
# Required only when VOICE_PROVIDER=openai. Independent of embedding/LLM OPENAI_API_KEY.
OPENAI_REALTIME_API_KEY=
OPENAI_REALTIME_MODEL=gpt-realtime-mini
OPENAI_REALTIME_VOICE=shimmer
# Phase 3: optional; low/medium only for gpt-realtime-2.1 or gpt-realtime-2.1-mini.
# Keep omitted for baseline models. Candidate promotion requires quality/compatibility evidence.
OPENAI_REALTIME_REASONING_EFFORT=null
# Phase 1 input quality settings. Keep baseline; candidates require separate evaluation.
OPENAI_REALTIME_ASR_MODEL=whisper-1
OPENAI_REALTIME_ASR_LANGUAGE=fa
OPENAI_REALTIME_ASR_LANGUAGES=[]
OPENAI_REALTIME_ASR_PROMPT=""
OPENAI_REALTIME_ASR_KEYWORDS=[]
OPENAI_REALTIME_VAD_THRESHOLD=0.5
OPENAI_REALTIME_VAD_PREFIX_PADDING_MS=300
OPENAI_REALTIME_VAD_SILENCE_DURATION_MS=500
OPENAI_REALTIME_NOISE_REDUCTION=null
# Explicit candidate (replace the baseline values; do not add conflicting fields):
# OPENAI_REALTIME_ASR_MODEL=gpt-transcribe
# OPENAI_REALTIME_ASR_LANGUAGE=null
# OPENAI_REALTIME_ASR_LANGUAGES=["fa","en"]
# OPENAI_REALTIME_ASR_PROMPT="Iranian Persian technical support with English terminology."
# OPENAI_REALTIME_ASR_KEYWORDS=["PCM16LE","API"]
# Compare ASR first, then VAD 500/800 ms, then device-appropriate noise independently.
# OPENAI_REALTIME_PROXY=https://trusted-proxy.example:443
TRUSTED_ORIGINS=["http://localhost:8000","http://127.0.0.1:8000"]
TRUSTED_HOSTS=["localhost:8000","127.0.0.1:8000"]
# Explicit local development only. Production requires HTTPS and true.
COOKIE_SECURE=false
AUTH_SESSION_SECONDS=28800
LIVE_SESSION_SECONDS=600
# 60 seconds of speech plus up to 4 seconds of VAD padding; independent 65-second stop deadline.
LIVE_MAX_INPUT_BUFFER_BYTES=3072000
LIVE_SPEECH_STOP_TIMEOUT_SECONDS=65
# Current repair profile: numeric audio/cancellation traces enabled; set 0 to disable.
LIVE_DIAGNOSTIC_TRACE_ENABLED=1
# Session replay capacity includes audio and transcript deltas.
LIVE_MAX_EVENTS=32768
# Aggregate generated/undrained PCM defaults: OpenAI 5760000 bytes (120 s),
# Gemini 1440000 bytes (30 s). Optional smaller override; transport credit stays 72000.
# LIVE_MAX_OUTPUT_BACKLOG_BYTES=5760000 # OpenAI only; omit for provider-specific defaults.
# Path to a measured, profile-compatible calibrated report; never a status placeholder.
# SEARCH_CALIBRATION_REPORT=/absolute/path/measured-report.json
# Explicit connectivity testing only; no uncalibrated document evidence is admitted.
# Sessions expose calibration_status=uncalibrated. Production default remains false.
VOICE_TRANSPORT_TESTING=false
# Temporary best-effort admission: bypass all manual approval and retain recognition warnings.
# New uploads only; existing snapshots remain unchanged.
INGEST_ALLOW_PARTIAL_EXTRACTION=false
# OCR supervisor gate for NEW jobs only; false admits only automatically validated OCR.
# Existing/legacy jobs keep their frozen policy. Factual/non-OCR review remains required.
INGEST_OCR_REVIEW_REQUIRED=true
# OpenAI per-response output budget, inclusive of tools (1..4096); not a PCM duration.
OPENAI_REALTIME_MAX_OUTPUT_TOKENS=2048
# Provider-side speech speed (0.25..1.5); frozen for each new Live session.
OPENAI_REALTIME_SPEED=1.30
# Local S2S Phase 2 candidate (off by default; isolated development only).
# See services/local_s2s/README.md. Do not change the operational VOICE_PROVIDER.
LOCAL_S2S_ENABLED=false
# Phase 3 development opt-in; saved interrupted text is not treated as heard.
LOCAL_S2S_RETAIN_INTERRUPTED_ANSWERS=false
# Isolated responsiveness candidate; pins ASR options and sentence-at-a-time generation.
LOCAL_S2S_RESPONSIVE=false
# Provider synthesis speed; 1.0 preserves normal local speech.
LOCAL_S2S_TTS_SPEED=1.0
LOCAL_S2S_ENDPOINT=ws://local-s2s-engine:8765/v1/realtime
LOCAL_S2S_ENGINE_REVISION=619e3fe4f71d1c6f35c15870d588a3638de34722
LOCAL_S2S_STT_MODEL=openai/whisper-large-v3
LOCAL_S2S_LLM_MODEL=openai/gpt-4.1-mini
# Candidate only: actual voice/rate/Persian compatibility is not accepted yet.
LOCAL_S2S_TTS_MODEL=gpt-4o-mini-tts-2025-12-15
LOCAL_S2S_TTS_VOICE=alloy
LOCAL_S2S_MAX_OUTPUT_TOKENS=256
LOCAL_S2S_REQUEST_TIMEOUT_SECONDS=30
LOCAL_S2S_TOKEN=
# Engine-only OpenRouter key: set at launch, never forward it to the API/browser.
# OPENROUTER_API_KEY=
# Local engine v2: provision these local bundles separately, never at startup.
# Compose host paths (see services/local_s2s/README.md):
# LOCAL_S2S_VAD_SOURCE=<local-silero-source-and-jit-bundle>
# LOCAL_S2S_NLTK_SOURCE=<local-unpacked-nltk-data>
# LOCAL_S2S_ASSET_MANIFEST_SOURCE=<local-assets.json>
# LOCAL_S2S_ASSET_MANIFEST_SHA256=<reviewed-manifest-sha256>