feat(backend): add PDF extraction with OCR fallback and cache
This commit is contained in:
1 parent
1b860dc599
commit
b75b746a40
8 files changed
+647
No files matched your search
@@ -0,0 +1,55 @@
|
||||
"""Schemas Pydantic de entrada e saída da API."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ChatMessage(BaseModel):
|
||||
role: Literal["user", "assistant"]
|
||||
content: str = Field(min_length=1, max_length=8000)
|
||||
|
||||
|
||||
class ChatRequest(BaseModel):
|
||||
message: str = Field(min_length=1, max_length=4000)
|
||||
history: list[ChatMessage] = Field(default_factory=list)
|
||||
|
||||
|
||||
class Source(BaseModel):
|
||||
"""Trecho bíblico recuperado, exibido no accordion de fontes."""
|
||||
|
||||
reference: str
|
||||
text: str
|
||||
book: str
|
||||
chapter: int
|
||||
verse: int
|
||||
page: int
|
||||
file: str
|
||||
score: float = 0.0
|
||||
|
||||
|
||||
class StatusResponse(BaseModel):
|
||||
state: Literal["ready", "indexing", "error"]
|
||||
pdfs_total: int = 0
|
||||
pdfs_indexed: int = 0
|
||||
chunks: int = 0
|
||||
model: str = ""
|
||||
last_indexed_at: str | None = None
|
||||
errors: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class HealthResponse(BaseModel):
|
||||
status: Literal["ok"] = "ok"
|
||||
llm_provider: str
|
||||
indexing: Literal["ready", "indexing", "error"]
|
||||
version: str = "1.0.0"
|
||||
|
||||
|
||||
class ReindexResponse(BaseModel):
|
||||
state: Literal["indexing"] = "indexing"
|
||||
|
||||
|
||||
class SourcesResponse(BaseModel):
|
||||
sources: list[Source] = Field(default_factory=list)
|
||||
Reference in new issue
Block a user