Новый раг
This commit is contained in:
15
app/modules/rag/indexing/common/document_upserter.py
Normal file
15
app/modules/rag/indexing/common/document_upserter.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.modules.rag.contracts import RagDocument
|
||||
from app.modules.rag.persistence.repository import RagRepository
|
||||
|
||||
|
||||
class RagDocumentUpserter:
|
||||
def __init__(self, repository: RagRepository) -> None:
|
||||
self._repository = repository
|
||||
|
||||
def replace(self, rag_session_id: str, docs: list[RagDocument]) -> None:
|
||||
self._repository.replace_documents(rag_session_id, docs)
|
||||
|
||||
def apply_changes(self, rag_session_id: str, delete_paths: list[str], docs: list[RagDocument]) -> None:
|
||||
self._repository.apply_document_changes(rag_session_id, delete_paths, docs)
|
||||
21
app/modules/rag/indexing/common/report.py
Normal file
21
app/modules/rag/indexing/common/report.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class IndexReport:
|
||||
indexed_files: int = 0
|
||||
failed_files: int = 0
|
||||
cache_hit_files: int = 0
|
||||
cache_miss_files: int = 0
|
||||
documents: int = 0
|
||||
warnings: list[str] = field(default_factory=list)
|
||||
|
||||
def as_tuple(self) -> tuple[int, int, int, int]:
|
||||
return (
|
||||
self.indexed_files,
|
||||
self.failed_files,
|
||||
self.cache_hit_files,
|
||||
self.cache_miss_files,
|
||||
)
|
||||
Reference in New Issue
Block a user