fix(openai): prompt engineering and transcript model

This commit is contained in:
amirhosein mazaheri
2026-10-11 17:28:22 +03:30
parent 21a0ea076a
commit f14166a89f
35 changed files with 12882 additions and 46 deletions
@@ -0,0 +1,87 @@
# Measured search calibration activation — 2026-10-11
The approved ten-case calibration was executed against the PostgreSQL database used by the running `app.server` API. The successful report is now mounted read-only and selected by the API. Transport-testing bypass is disabled. This is a measured retrieval configuration for frontend testing, not completion of the independent Persian voice quality gates.
## Approval and input identity
The user explicitly approved the sample original and its ten frozen labels in this conversation, then authorized execution of the workflow.
- Original: `data/calibration/phase2-source.md`
- Original SHA-256: `7d1e384210faa9430f715a3f30736c8ad7c782f701843a68bab969845934835f`
- Frozen annotations: [phase2-cases.json](../calibration/phase2-cases.json), six answerable and four unsupported cases.
- Actual document: `aa4f291c-8808-497f-975f-ce0f7f6f838a`
- Organization: `37439088-523c-4403-899f-47e3f809123c`
- Enabled administrator: `aec70b67-db27-4696-b2b9-49435a99a3b1`
- [Actual bindings](../calibration/approved-bindings.json)
- [Scoped operator approval](../calibration/operator-approval-2026-10-11.json)
The original and labels were preserved. Intake used `app.ingest import` with request ID `872d6761-e74b-4492-9e54-f3a1d5d9f066`, not direct database publication. The existing worker completed its first attempt and atomically published six chunks. Extracted block text was checked against the approved original; this deterministic check does not invent a human review. Markdown used readable-text extraction without vision inference.
Selection was changed through `app.knowledge selection replace`, fenced at revision 8. The resulting knowledge revision is 9 and access epoch remains 3. All three previously active documents remain selected; the approved calibration document was added. The queue contained no pending unrelated jobs before import.
## Actual measurement
[Measured report](../calibration/measured-search-2026-10-11.json):
| Item | Observed result |
| --- | --- |
| Status | `calibrated` |
| Complete support | 6/6 answerable cases |
| Unsupported false positives | 0/4 unsupported cases |
| Calibration query embedding calls | 10, within the authorized budget of 10 |
| Embedding profile | Ollama / bge-m3 / 1024 dimensions / preprocessing v1 |
| Canonical embedding endpoint | `http://localhost:11434/v1` |
| Selected cosine distance | `0.33686461167069426` |
| Calibration ID | `baec206d-3e5c-477c-9290-fd84f706fa28` |
| Final authorization check | Confirmed |
| OpenAI voice calls by this workflow | 0 |
| Billing and token usage | Not reported by the calibration harness |
The adapter translates the local embedding endpoint to `host.docker.internal` for container transport while preserving canonical profile identity. Ingestion embedding work is separate from the ten counted calibration query calls.
The cutoff was selected by the existing calibration algorithm from measured candidate distances. No manually chosen threshold, edited label, fabricated recording, or unsupported successful result was substituted.
Execution used the existing API image and service configuration:
```powershell
$taskRepo = (Get-Location).Path
docker compose run --rm --no-deps --volume "${taskRepo}/docs/calibration:/app/docs/calibration" --volume "${taskRepo}/data/calibration:/app/data/calibration:ro" api python -m app.calibrate_search --user-id aec70b67-db27-4696-b2b9-49435a99a3b1 --bindings /app/docs/calibration/approved-bindings.json --output /app/docs/calibration/measured-search-2026-10-11.json --allow-provider-calls
```
The report path is immutable for this run: rerunning requires a new output filename. The measured report can contain retrieved text from selected documents; retain it as an environment-specific evaluation artifact and review its contents before sharing.
## Activated runtime
Only the API service received the new read-only Compose mount:
```yaml
- ./docs/calibration:/app/docs/calibration:ro
```
The ignored local `.env` now selects:
```dotenv
SEARCH_CALIBRATION_REPORT=/app/docs/calibration/measured-search-2026-10-11.json
VOICE_TRANSPORT_TESTING=false
```
The API was recreated with `docker compose up -d --no-deps api`. Its candidate voice settings remain OpenAI `gpt-realtime-2.1`, reasoning `low`, voice `shimmer`, and user ASR `gpt-transcribe`. Gemini, applied database migrations, model cancellation classification, and existing runtime code were not edited by this operational calibration workflow.
## Verification
- All ten measured case results passed: A1–A6 returned complete evidence; U1–U4 returned `no_evidence`.
- Report annotation hash, successful status, final authorization, call budget, and embedding-profile equality passed.
- Container-side execution of the existing configuration handler with the actual administrator ID returned `voice=true`, `captions=true`, `calibration_status=calibrated`, and `voice_transport_testing=false`. This was a trusted read-only handler check, not a browser login or an authenticated HTTP acceptance test.
- The existing voice capability loader accepted the mounted report and produced the expected calibration ID, distance, profile, and retrieval policy without opening a voice-provider connection.
- HTTP `GET http://localhost:8080/health/ready`: 200, ready.
- HTTP CORS preflight for `http://localhost:4200` to `/api/v1/configuration`: 200 with the matching allowed origin.
- `git diff --check`: passed before the documentation checkpoint; rerun after final documentation.
- Broad regression suites were not rerun for this configuration/data-only workflow. Previously reported suite limitations remain.
## Frontend test and remaining acceptance
Connect the frontend to `http://localhost:8080` and create a fresh voice session. Existing session reservations keep their frozen profiles and are not upgraded by this restart.
For a direct calibration smoke check, ask about the sample pump pressure and temperature condition, or the application discount and permit exclusion. An unsupported question such as the land price should yield a lack-of-evidence answer rather than an invented value. Then test actual uploaded documents and record displayed user transcript, tool query, returned evidence, spoken answer, pauses, and interruptions separately.
The independent 26-case corpus still lacks complete approvals, bindings, and human labels. No independent retrieval gate, real OpenAI dialogue evaluation, listening score, or candidate interruption compatibility was run here. The sample's 10/10 result does not prove accuracy on every uploaded document and does not establish ASR or Persian delivery quality. Phase 3 quality acceptance remains open.