Files
rag-technical-docs-assistant/docs/guides/local-gapgpt-20261018.md
amirhosein mazaheri 9b5be918d4 docs: reconcile project status and local stack operations
Refresh entry points and progress checkpoints, document schema revision 0006, and consolidate the final ElevenLabs/GapGPT profile and host prerequisites.

Preserve dated activation evidence and distinguish implementation, targeted validation, incomplete full-suite checks and remaining human acceptance gates.

Validation: 409 local Markdown link targets resolved and staged whitespace checks passed.
2026-10-20 09:00:55 +03:30

196 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Current reading note (2026-10-20): the final recorded configuration is in
[the consolidated local runbook](current-local-stack.md). The initial all-GapGPT
activation and intermediate Gemini/TTS-only changes below are historical;
the final profile uses ElevenLabs STT/TTS and GapGPT dialogue only.
No new runtime verification was performed for this reading note.
# Local S2S through GapGPT — 2026-10-18
User-authorized local activation only. The Debian deployment was not contacted
or modified during this activation. All three Local S2S components now use
https://api.gapgpt.app/v1 in the local test stack:
- STT: whisper-1, Persian, final JSON transcription.
- LLM: gpt-4.1-mini, streaming Chat Completions and existing backend tools.
- TTS: gpt-4o-mini-tts, alloy, PCM 24kHz, existing speed 1.6.
## Configuration and routing
LOCAL_S2S_COMPONENT_PROVIDER=gapgpt must be set on both the API and engine.
The split default preserves existing deployments. The selected upstream is part
of frozen components/profile identity; switching it cannot silently reuse an old
session attestation. Actual initialized engine metadata is checked against it.
GapGPT routes never fall back to OpenAI or OpenRouter on error. Multipart STT,
streaming chat/tools, response bounds, deadlines and cancellation remain intact.
Only the engine reads GAPGPT_API_KEY or GAPGPT_API_KEY_FILE. The active local
stack mounts ignored .local-s2s-build/gapgpt-api.key read-only at
/run/secrets/gapgpt_api_key. The key is not embedded in source, image, API,
frontend or Compose environment. The fixed provider endpoint does not accept a
model-supplied destination. No additional package or migration was introduced.
Embedding remains local bge-m3 and document OCR remains its existing provider;
these are separate from the three speech pipeline components authorized here.
Existing documents, selection, embedding metadata and calibrated cutoff are
preserved. The local test UI exposes only Local S2S for this activation.
## Local run
Runtime uses image rag-local-gapgpt:20261018, built on the existing engine image
with the current app and services/local_s2s sources. The existing isolated
rag_bge_local_s2s_test database and original/extraction volumes are reused.
Start/check from the repository root:
.venv/Scripts/python .local-s2s-build/gapgpt-compose.py up -d
.venv/Scripts/python .local-s2s-build/gapgpt-compose.py ps
.venv/Scripts/python .local-s2s-build/check-gapgpt.py
Compose: .local-s2s-build/windows-gapgpt.compose.json. Runtime files are ignored
and contain host-specific paths; credentials are in the separate key file only.
Frontend preview is running at http://127.0.0.2:4201/login and proxies the local
API at 127.0.0.2:8092. It serves the current sibling Angular production build.
The existing test login is in .local-s2s-build/windows-browser-login.txt.
Preview config/PID/logs use the .local-s2s-build/gapgpt-preview prefix.
The migrated embedding identity pins http://localhost:11434/v1. A first startup
attempt using host.docker.internal correctly failed compatibility validation;
no profile or migrated metadata was rewritten. A local Python stdlib TCP relay
now shares the API/worker network namespace and forwards that same loopback
address to the host's Ollama. The relay has no provider key and no exposed
embedding port. The migration then succeeded and the API became ready.
## Actual verification
141 focused provider-free tests passed before the final added upstream-error
parameter cases. The earlier real feasibility checks verified streaming tool
arguments, PCM audio generation and the same audio transcribed as Persian
'سلام'. Native engine startup then made exactly three successful component
warmup requests, each logged with provider=gapgpt and status 200.
GET /health/ready returned 200 with ingestion available. The actual frontend
proxy login, allowed-provider inventory, public model catalog and WebSocket
session_ready/normal close passed. Evidence is retained in ignored
.local-s2s-build/combined-evidence/gapgpt-connection-20261018.json.
Human microphone quality, interruption and complete spoken RAG acceptance await
the user's browser test. These are not established by startup or mock tests.
Final focused command:
.venv/Scripts/python -m pytest tests/unit/test_local_s2s_gapgpt.py tests/unit/test_local_s2s_engine.py tests/unit/test_local_s2s_responsiveness.py tests/unit/test_local_s2s_boundary.py tests/unit/test_local_s2s_phase2.py tests/unit/test_local_s2s_repairs.py -m "not postgres" -q
Result: **144 passed**. Includes all three GapGPT routes with both successful
upstream responses and upstream 429 rejection, exactly one outbound attempt,
no fallback/credential mixing, profile mismatch rejection and prior-path coverage.
`git diff --check` passed. No tracked or pending source file contains the key.
The actual API container reached host Ollama through the loopback relay:
HTTP 200, 1024-dimensional bge-m3 output. Authenticated proxied document listing
returned HTTP 200 with four visible active documents; knowledge selection also
returned 200. No original content or selection was changed by these checks.
## Active Gemini TTS follow-up — 2026-10-18
User selected gemini-2.5-flash-preview-tts. The current local TTS model is now
that exact model, voice Kore. STT and LLM retain whisper-1 and gpt-4.1-mini.
The earlier gpt-4o-mini-tts activation above is historical.
GapGPT /audio/speech returned 503 channel:protocol_unsupported for Gemini TTS,
with and without speed. The native Gemini-style v1/models generateContent route
returned a successful response with empty audio parts. Actual usable audio was
verified through /v1/chat/completions with modalities=[audio], audio.voice=Kore,
audio.format=pcm16 and stream=false. The TTS gateway now uses that route only for
this exact model in GapGPT mode, validates the successful single-choice audio
envelope, bounds base64/decoded size, and passes PCM to the existing native TTS
handler. Valid mono 24kHz 16-bit WAV envelopes are unwrapped when present;
incompatible or empty/partial audio is rejected. No provider fallback exists.
Desired pace 1.6 is conveyed in the Gemini read-aloud instruction; unlike the
previous model's speed parameter this is not a measured guarantee of exact pace.
GapGPT's upstream inactivity wait now uses the configured total request deadline;
the old split-provider default remains 5 seconds. The current isolated local
profile uses 60 seconds (the existing validated maximum), preserving bounded
cancellation and no automatic retries. This removes the premature 5-second
cutoff observed in the user's STT/TTS logs. It does not guarantee the provider
will always reply within the total deadline.
Final focused suite: 152 passed (same six local_s2s test modules as above).
Actual native startup succeeded with all three component warmups: Gemini TTS
returned status 200, 48,526 PCM bytes, approximately 3.16 seconds for that one
request. Frontend-proxied session_ready and normal close passed again; F01
reports the requested Gemini TTS model. API/worker/engine were recreated locally
with the current sources. The server was not modified. Browser remains at
http://127.0.0.2:4201/login; refresh and start a new voice conversation.
## Active ElevenLabs TTS follow-up — 2026-10-18
User replaced Gemini TTS with ElevenLabs for the local test only. Current settings:
LOCAL_S2S_COMPONENT_PROVIDER=gapgpt, LOCAL_S2S_TTS_PROVIDER=elevenlabs,
LOCAL_S2S_TTS_MODEL=eleven_v3, LOCAL_S2S_TTS_VOICE=JBFqnCBsd6RMkjVDRZzb
(George), LOCAL_S2S_TTS_SPEED=1.2. STT and LLM remain whisper-1 and
gpt-4.1-mini through GapGPT. The previous Gemini TTS activation is historical.
A tiny actual Persian synthesis request returned HTTP 200, audio/pcm,
107,520 bytes (2.24 seconds at 24kHz mono 16-bit), in about 3.51 seconds.
The request explicitly selects output_format=pcm_24000 on ElevenLabs' native
text-to-speech endpoint. No MP3 decoding or sample-rate inference is used.
The API format contract is documented at
https://elevenlabs.io/docs/api-reference/text-to-speech/convert and
https://elevenlabs.io/docs/help-center/troubleshooting/what-audio-formats-do-you-support.
Human Persian listening/quality acceptance remains pending.
The supplied key permits synthesis but denies models_read, voices_read and
user_read; discovery endpoints returned missing_permissions. No extra permission
is needed to run the successful synthesis request using the documented George
voice. No key/account permission was changed.
Only the engine mounts ignored .local-s2s-build/elevenlabs-api.key at
/run/secrets/elevenlabs_api_key. The gateway uses xi-api-key for ElevenLabs only,
never forwards the GapGPT bearer key there, and never falls back to Gemini or
other providers. TTS provider/model/voice/speed are frozen in session identity.
Provider/model changes require a new voice conversation. Existing packet,
backlog, cancellation and total timeout limits remain in place. Speed outside
0.7–1.2 is rejected for ElevenLabs instead of silently clamped.
159 focused provider-free tests passed, including successful native TTS mapping,
401/429 with no fallback, credential separation, PCM 24kHz request parameters,
attestation mismatch and speed/credential validation. One new test fixture
initially omitted its handler speed; it was supplied to match runtime setup.
No runtime assertion was weakened. The API, worker and engine image were rebuilt
and restarted locally. Server deployment was not contacted or modified.
## Active ElevenLabs STT follow-up — 2026-10-18
The user also moved STT to ElevenLabs. The active local profile now uses
LOCAL_S2S_STT_PROVIDER=elevenlabs and LOCAL_S2S_STT_MODEL=scribe_v2.
TTS remains ElevenLabs eleven_v3/George at speed 1.2 with PCM 24000Hz.
Only the dialogue LLM remains gpt-4.1-mini through GapGPT.
A small Persian synthetic audio round trip succeeded with the existing key:
Scribe v2 returned 'سلام. خوش آمدید', language fas, HTTP 200, in about 1.07
seconds for that sample. The key does not require extra permissions for this
successful speech-to-text request.
The engine gateway maps its existing OpenAI-compatible multipart transport to
POST https://api.elevenlabs.io/v1/speech-to-text. Audio bytes are preserved;
model becomes model_id=scribe_v2, language_code=fa, event tagging/diarization
are disabled and timestamps_granularity=none. Whisper response_format, prompt
and temperature are not sent to ElevenLabs. The frozen STT profile no longer
claims those Whisper-specific settings for this route; sentence-at-a-time LLM
handling remains enabled. The final JSON text response uses the existing native
handler path. No second search implementation, migration or package was added.
STT provider is included in session identity and verified against engine setup.
The existing engine-only ElevenLabs key file is shared by STT/TTS; GapGPT
credentials are not forwarded to ElevenLabs. Authentication/rate failures do not
fall back to GapGPT or OpenAI. Existing total request bounds/cancellation remain.
164 focused tests passed across test_local_s2s_elevenlabs, gapgpt, engine,
responsiveness, boundary, phase2 and repairs. New coverage verifies multipart
field translation, original audio preservation, no credential mixing or fallback,
provider attestation, invalid duplicate fields and omitted Whisper-only policy.
Native engine warmup succeeded with STT ElevenLabs HTTP 200 (~0.97s), LLM
GapGPT HTTP 200 and TTS ElevenLabs HTTP 200. These are individual measurements,
not latency guarantees or human Persian-quality acceptance. No server changed.