retrieval.py 485 B

1234567891011121314151617181920212223
  1. from typing import Optional
  2. from pydantic import BaseModel
  3. from models.dataset import DocumentSegment
  4. class RetrievalChildChunk(BaseModel):
  5. """Retrieval segments."""
  6. id: str
  7. content: str
  8. score: float
  9. position: int
  10. class RetrievalSegments(BaseModel):
  11. """Retrieval segments."""
  12. model_config = {"arbitrary_types_allowed": True}
  13. segment: DocumentSegment
  14. child_chunks: Optional[list[RetrievalChildChunk]] = None
  15. score: Optional[float] = None