47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
# Data Models for document processing and API responses
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
|
class DocumentChunk:
|
|
"""Represents a chunk of text to be embedded."""
|
|
|
|
def __init__(
|
|
self,
|
|
text: str,
|
|
metadata: Optional[Dict[str, Any]] = None
|
|
):
|
|
self.text = text
|
|
self.metadata = metadata or {}
|
|
|
|
@property
|
|
def doc_id(self) -> str:
|
|
"""Generate a document ID from content."""
|
|
return f"doc-{hash(self.text)}"
|
|
|
|
|
|
class IngestResponse:
|
|
"""Response model for document ingestion."""
|
|
|
|
def __init__(
|
|
self,
|
|
success: bool,
|
|
chunks_count: int = 0,
|
|
error: Optional[str] = None
|
|
):
|
|
self.success = success
|
|
self.chunks_count = chunks_count
|
|
self.error = error
|
|
|
|
|
|
class SearchResponse:
|
|
"""Response model for search results."""
|
|
|
|
def __init__(
|
|
self,
|
|
results: List[Dict[str, Any]],
|
|
query: str,
|
|
total_results: int
|
|
):
|
|
self.results = results
|
|
self.query = query
|
|
self.total_results = total_results |