30 lines
638 B
Python
30 lines
638 B
Python
|
|
"""Define domain models for retrieval."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from dataclasses import dataclass, field
|
||
|
|
from typing import Any
|
||
|
|
# Keep module behavior explicit so the backend flow stays easy to audit.
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class RetrievalQuery:
|
||
|
|
"""Represent the Retrieval Query type."""
|
||
|
|
query: str
|
||
|
|
top_k: int
|
||
|
|
filters: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class RetrievedChunk:
|
||
|
|
"""Represent the Retrieved Chunk type."""
|
||
|
|
chunk_id: str
|
||
|
|
doc_id: str
|
||
|
|
doc_name: str
|
||
|
|
content: str
|
||
|
|
score: float
|
||
|
|
section_title: str = ""
|
||
|
|
page_number: int = 0
|
||
|
|
metadata: dict[str, Any] = field(default_factory=dict)
|