feat(backend): integrate document deletion and grounded speech providers

Enable replay-safe document deletion and public deployment model identifiers with the forward voice-model schema revision.

Add GapGPT dialogue and ElevenLabs speech routing, strict extractive grounding, ten-source retrieval and regression coverage.

Validation: 199 targeted provider-free tests passed. The full provider-free run stalled and was interrupted; PostgreSQL acceptance was not run because TEST_DATABASE_URL is unset.
This commit is contained in:
amirhosein mazaheri
2026-10-20 09:00:37 +03:30
parent 2bffb9476a
commit 42400495af
27 changed files with 1003 additions and 28 deletions
+23
View File
@@ -5,6 +5,7 @@ from typing import Annotated, Literal, NamedTuple
from uuid import UUID
from fastapi import APIRouter, Depends, Header, Query, Request, Response
from pydantic import BaseModel, ConfigDict, Field
from app.api.v1.dependencies import (
get_engine, get_ingestion_settings, require_admin, require_csrf, error,
MAX_DECISION_BYTES, JSON_RECEIVE_SECONDS, RETRY_RECEIVE_SECONDS,
@@ -220,3 +221,25 @@ def _apply_decision(review, identity, document_id, key, payload):
return review.decide(identity, document_id, request_id=key, payload=payload.model_dump(mode='json'))
finally:
_DECISION_SLOTS.release()
class DeleteDocumentRequest(BaseModel):
model_config = ConfigDict(extra='forbid')
expected_revision: int = Field(ge=1, strict=True)
@router.delete('/{document_id}', status_code=202,
summary='Soft Delete Document',
openapi_extra={'requestBody': {'required': True, 'content': {'application/json': {
'schema': DeleteDocumentRequest.model_json_schema()}}}})
async def delete(document_id: UUID, request: Request, response: Response, user: Admin,
key: Key, _csrf: Csrf, engine=Depends(get_engine)):
from app.modules.documents.deletion import delete_document
from app.modules.knowledge.service import KnowledgeError
payload = await receive_json(request, DeleteDocumentRequest, max_bytes=1024)
try:
result = await blocking(delete_document, engine, user.id, document_id, key, payload.expected_revision)
replay_header(response, result)
return {k: v for k, v in result.items() if k != 'replayed'}
except KnowledgeError as exc:
raise error(exc.code) from None