Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions backend/app/api/qa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Quality Assurance API endpoints."""

from fastapi import APIRouter, Depends
from pydantic import BaseModel
from sqlalchemy.ext.asyncio import AsyncSession

from app.api.schemas import ConsistencyResult
from app.core.database import get_db
from app.services.consistency import run_consistency_check

router = APIRouter(prefix="/api", tags=["qa"])


class ConsistencyCheckRequest(BaseModel):
project_id: int
ngram_n: int = 4
ngram_threshold: int = 3


@router.post("/qa/check", response_model=list[ConsistencyResult])
async def check_consistency(
body: ConsistencyCheckRequest,
db: AsyncSession = Depends(get_db),
):
"""Run rule-based consistency checks on a project."""
return await run_consistency_check(
db,
body.project_id,
ngram_n=body.ngram_n,
ngram_threshold=body.ngram_threshold,
)
13 changes: 13 additions & 0 deletions backend/app/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ class LoreEntryOut(BaseModel):
model_config = {"from_attributes": True}


# --- Consistency Check ---

class ConsistencyResult(BaseModel):
type: str
severity: str
confidence: float
source: str
message: str
evidence: list[str]
evidence_locations: list[str]
suggest_fix: str


# --- KG ---

class KGNodeOut(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from app.api.kg import router as kg_router
from app.api.lorebook import router as lorebook_router
from app.api.projects import router as projects_router
from app.api.qa import router as qa_router
from app.api.summary import router as summary_router


Expand Down Expand Up @@ -46,6 +47,7 @@ async def lifespan(app: FastAPI):
app.include_router(summary_router)
app.include_router(export_router)
app.include_router(kg_router)
app.include_router(qa_router)


@app.get("/health")
Expand Down
Loading