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
+78 -8
View File
@@ -42,7 +42,7 @@ Section numbers and heading names below are verified against these files; no inf
| --- | --- | --- |
| `RAG-AI-Phase1-Delivery-Plan.md` | [Delivery plan](specifications/RAG-AI-Phase1-Delivery-Plan.md) | Scope, sequence, acceptance: 3. Included and Deferred Scope; 6. Document Lifecycle and Knowledge Changes; 8. Delivery Schedule and Checkpoints; 9. Acceptance Criteria; 10. Demonstration Script |
| `RAG-Phase1-Implementation-Guide.md` | [Implementation guide](specifications/RAG-Phase1-Implementation-Guide.md) | Modules/workflows: 3. Modules and ports; 5. Identity and request context; 6. Document upload and ingestion; 7. Selection, revisions and revocation; 8. Deferred text turn execution; 9. Live lifecycle; 10. Internal search contract; 12. Tests and handoff; 13. Decisions still requiring confirmation |
| `RAG-Phase1-API-Catalog.md` | [API catalog](specifications/RAG-Phase1-API-Catalog.md) | Routes/DTOs/permissions/errors/replay: 1. Transport and common conventions; 2. Endpoint inventory; 4. Documents and selected knowledge; 6. Conversations and deferred text; 7. Voice contract — OpenAI Realtime; frozen application audio/events; 9. Error envelope and mapping |
| `RAG-Phase1-API-Catalog.md` | [API catalog](specifications/RAG-Phase1-API-Catalog.md) | Routes/DTOs/permissions/errors/replay: 1. Transport and common conventions; 2. Endpoint inventory; 4. Documents and selected knowledge; 6. Conversations and deferred text; 7. Voice contract أ¢â‚¬â€‌ OpenAI Realtime; frozen application audio/events; 9. Error envelope and mapping |
| `RAG-Phase1-Database-Design.md` | [Database design](specifications/RAG-Phase1-Database-Design.md) | Schema/constraints/transactions: 4. Knowledge tables; 5. Minimal voice conversation and evidence; deferred text tables; 6. Live and audit tables; 7. Transaction boundaries and invariant enforcement; 8. Migration plan; 9. Essential database validation |
| `RAG-Phase1-MVP-Scenarios.md` | [English MVP scenarios](specifications/RAG-Phase1-MVP-Scenarios.md) | Current journeys: 2. Examples and unseen files; 3. Upload/replay; 4-5. Exact review and factual FAQ; 6. Publication; 7-10. Voice/failure/revocation; 11-12. Restart/evaluation |
| `RAG-AI-Architecture.md` | [Architecture](specifications/RAG-AI-Architecture.md) | Context/future direction: 4. Backend Modules and Dependency Rules; 6. Search Tool Contract; 7. Dynamic Document Lifecycle; 17. Historical prototype mapping; 19. Open Decisions and Owners; 22. Current Live document MVP decisions |
@@ -301,11 +301,11 @@ Persian, ZWNJ, CJK and emoji metadata. No real provider checks were run; these
repairs introduce no provider behavior. Original-store power-loss guarantees and
unavailable Windows symlink creation remain outside the verified evidence.
## Persian document and voice MVP documentation — 2026-10-06
## Persian document and voice MVP documentation أ¢â‚¬â€‌ 2026-10-06
The governing specifications now include page-level PDF quality/fallback, DOCX FAQ pairing, infographic group preservation, retained extraction artifacts, shared semantic/identifier retrieval and direct Gemini Live `search_knowledge`. The earlier proposed `search_documents` name and SDP request/answer contract are superseded; prototype `retriever_tool` remains unchanged.
[Architecture Sections 7, 8 and 21](specifications/RAG-AI-Architecture.md) cover diagrams, decisions and static implementation evidence. [Delivery plan Sections 9 and 14–15](specifications/RAG-AI-Phase1-Delivery-Plan.md) retain P1-01–P1-12, add P1-13–P1-17 and record budget/account/rehearsal gates. [API Section 7](specifications/RAG-Phase1-API-Catalog.md) distinguishes HTTP, application Live WSS and internal tools. [Database Section 4.4](specifications/RAG-Phase1-Database-Design.md) proposes extraction artifacts without content-version entities. [Persian scenarios Sections 18–22](specifications/RAG-Phase1-Scenario-Report-FA.md) document actual sample inspection limits and worked examples.
[Architecture Sections 7, 8 and 21](specifications/RAG-AI-Architecture.md) cover diagrams, decisions and static implementation evidence. [Delivery plan Sections 9 and 14أ¢â‚¬â€œ15](specifications/RAG-AI-Phase1-Delivery-Plan.md) retain P1-01أ¢â‚¬â€œP1-12, add P1-13أ¢â‚¬â€œP1-17 and record budget/account/rehearsal gates. [API Section 7](specifications/RAG-Phase1-API-Catalog.md) distinguishes HTTP, application Live WSS and internal tools. [Database Section 4.4](specifications/RAG-Phase1-Database-Design.md) proposes extraction artifacts without content-version entities. [Persian scenarios Sections 18أ¢â‚¬â€œ22](specifications/RAG-Phase1-Scenario-Report-FA.md) document actual sample inspection limits and worked examples.
All four supplied files exist in `data/documents/`; DOCX XML and infographic were inspected locally, and PDF structure confirms five/one pages. Full local PDF text/layout extraction was unavailable; prior word/number-order observations remain supplied context. No provider/OCR benchmark or Persian speech test was run.
@@ -757,7 +757,7 @@ Executed evidence for these four semantic repairs (2026-10-06):
An intermediate corrected targeted run had one compatibility failure:
`Decision dated 1403/01/02` was being treated as an identifier. The final parser
recognizes the explicit dated/مورخ metadata qualifier; the existing control passes.
recognizes the explicit dated/ط¸â€¦ط¸ث†ط·آ±ط·آ® metadata qualifier; the existing control passes.
Real-provider extraction quality and manual Persian fidelity acceptance remain
**unverified**. These generated fixtures and fake providers do not establish
@@ -791,7 +791,7 @@ changes, immutable originals, frozen profiles, normalization and applied migrati
Active position/case/hiding semantics fail safely; resets, harmless formatting
and unused styles pass. Deeper DOCX answer headings/table continuations stay
atomic; incomplete/ambiguous/oversized groups fail. English singular/plural and
Persian ماده/مواد targets support explicit conjunction/comma lists and simple
Persian ط¸â€¦ط·آ§ط·آ¯ط¸â€،/ط¸â€¦ط¸ث†ط·آ§ط·آ¯ targets support explicit conjunction/comma lists and simple
integer ranges; unsupported malformed/complex identifiers fail. Incidental
citations and ordinary decision prose remain accepted. See the setup guide for
exact grammar and output/intake bounds. Attachment/reuse remain Phase 5 gated;
@@ -1899,8 +1899,8 @@ Exactly one API process owns media guards; ingestion runs separately. Fake tests
are not real provider/Persian speech/browser hardware or frontend readiness proof.
Verified final commands: `.venv/bin/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short`
— **1679 passed**, two existing Windows path skips; `.venv/bin/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short`
— **372 passed**, zero skips, using only the isolated task-created test database.
أ¢â‚¬â€‌ **1679 passed**, two existing Windows path skips; `.venv/bin/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short`
أ¢â‚¬â€‌ **372 passed**, zero skips, using only the isolated task-created test database.
Affected PostgreSQL cases: **61 passed**. Missing TEST_DATABASE_URL produced the
required prerequisite failure. Executable JS, syntax/compile, diff and baseline
preservation checks passed. See the report for exact durations, failed/interrupted
@@ -1917,7 +1917,7 @@ intake/review/worker/selection services, with bounded streaming
prior pending-HTTP statements above. The standalone frontend developer handoff is
[Phase 3 integration](guides/realtime-agent-phase3-handoff.md), with executable
DocumentClient and a same-origin Vite proxy example. Existing VoiceClient/worklet,
Gemini/OpenAI selection, canonical search and migrations 0001–0005 are preserved.
Gemini/OpenAI selection, canonical search and migrations 0001أ¢â‚¬â€œ0005 are preserved.
`INGEST_OCR_REVIEW_REQUIRED=true` is a deployment default frozen in new job
profiles; false admits only automatically validated OCR. Legacy profiles retain
@@ -2100,3 +2100,73 @@ and deployment are unverified; the currently inspected API selected Gemini.
## Continuous microphone input accounting repair (2026-10-10)
The [scoped repair report](guides/voice-input-accounting-repair.md) supersedes the historical 10-second silence overflow requirement. API 7.1.3 now bounds detected uncommitted speech independently of queued/in-flight transport; absolute positions and commitment fencing remain. Fixed speech-stop and existing commit/send deadlines protect missing events. Stable overflow diagnostics distinguish input, output, playback and control branches. Verification: 1834 provider-free passed (three existing Windows symlink skips); final adapter/diagnostic follow-up 80 passed. No database behavior or migration changed; no deployment or paid provider calls. Real-provider/browser acceptance remains unverified. See the report for exact commands, intermediate failures, counter definitions and provider evidence.
## OpenAI Persian speech Phase 1 foundation (2026-10-11)
The [scoped implementation/frontend handoff](guides/openai-persian-speech-phase1.md)
and [baseline/check report](evaluation/openai-persian-speech-baseline.json) track
Phase 1 of the Persian quality plan only. OpenAI input ASR/VAD/noise settings
flow through existing configuration/factory/adapter paths and freeze in
execution_profile.audio_input. Existing replay/stream admission rejects missing
or mismatched snapshots without rewriting them; Gemini/public contracts remain.
User transcription now rejects malformed types/post-completion deltas.
New offline command: .venv/Scripts/python -m app.score_speech --help.
The scorer, 30-slot manifest, blank human annotation/observation templates and
runnable examples/voice-transcripts.js are preparation, not real quality evidence.
Actual live comparisons, human speech/critical facts, natural pauses and actual
frontend/browser reconciliation remain not_run; Phase 1 is not closed.
Read-only rag-api inspection selected OpenAI gpt-realtime-mini/shimmer,
transport testing true and no calibration report. No rebuild/restart or provider
evaluation was performed. Final checks are recorded in the linked report.
Phase 1 affected checks: 361 provider-free regressions and 82 isolated PostgreSQL
cases passed, no database skips. Broader database acceptance is incomplete after
a reported failure and stalled progress; ordinary-suite attempts have timing
failures. See the report for all attempts and final outcomes. No assertions were
weakened, no operational containers were restarted, and test storage was removed.
Final full provider-free run: 1874 passed, three Windows symlink skips, one
existing GeminiVision extraction deadline failure; isolated retest 2 passed.
The full suite remains non-green. Phase 1 live/frontend acceptance remains not_run.
## OpenAI Persian delivery Phase 2 ? 2026-10-11
Fixed OpenAI-only style and instruction digest now reuse the existing execution
profile; shared POLICY/Gemini instructions and cancellation classifier are unchanged.
See [Phase 2 handoff](guides/openai-persian-delivery-phase2.md),
[comparison manifest](evaluation/openai-persian-delivery-comparison.json), and
[style source](../app/modules/voice/openai_style.py). Human examples/listening and
real candidate interruption acceptance remain pending; Phase 2 is not closed.
Phase 2 actual checks: 338 focused checks and 10 isolated PostgreSQL profile cases
passed. Broad provider-free run excluding the duplicate-suite driver: 1880 passed,
3 symlink skips, 1 unchanged JSON responsiveness failure; isolated JSON rerun also
failed its timing bound (different parameter). See the handoff for exact commands
and outcomes. No clean full-suite or real-speech acceptance claim.
## Persian quality Phase 3 (2026-10-11)
[Phase 3 report](guides/openai-persian-understanding-phase3.md) and
[comparison status](evaluation/openai-persian-understanding-comparison.json)
record optional OpenAI low/medium reasoning through existing configuration,
factory and adapter, frozen private execution profiles and acknowledgment/replay
regressions. Gemini and canonical search remain unchanged. Real retrieval/model
acceptance is blocked by approval/bindings, measured calibration, selected speech
profile, human scenarios and explicit bounded authorization. No provider calls or
candidate promotion. Consult the report for actual checks and unresolved failures.
## Measured calibration activation (2026-10-11)
[Operational handoff](guides/search-calibration-activation-2026-10-11.md) records
actual approved sample intake, six ready chunks, selection revision 9 with existing
documents preserved, and ten local bge-m3 query embedding calls. Measured support
is 6/6, unsupported false positives 0/4. The successful environment-specific
report is mounted read-only into rag-api; SEARCH_CALIBRATION_REPORT selects it
and VOICE_TRANSPORT_TESTING is false. Read-only capability checks report calibrated;
HTTP readiness and localhost:4200 CORS preflight passed. No OpenAI voice calls.
Independent 26-case evaluation, real speech/delivery and candidate interruption
acceptance remain unrun; Phase 3 is still open. Earlier no-call checkpoints above
are historical and precede this separately approved operational workflow.