mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 09:45:24 -04:00
fix(rag): forward owner through manager wrapper (#2991)
This commit is contained in:
+12
-3
@@ -5,7 +5,7 @@ A thin wrapper around VectorRAG for backward compatibility and additional featur
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict, Any, Optional
|
||||
|
||||
# Try to import from different possible locations
|
||||
try:
|
||||
@@ -34,9 +34,18 @@ class RAGManager:
|
||||
"""Search for documents - delegates to VectorRAG."""
|
||||
return self.vector_rag.search(query, k)
|
||||
|
||||
def index_personal_documents(self, directory: str) -> Dict[str, Any]:
|
||||
def index_personal_documents(
|
||||
self,
|
||||
directory: str,
|
||||
file_extensions: Optional[set] = None,
|
||||
owner: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""Index documents - delegates to VectorRAG."""
|
||||
return self.vector_rag.index_personal_documents(directory)
|
||||
return self.vector_rag.index_personal_documents(
|
||||
directory,
|
||||
file_extensions=file_extensions,
|
||||
owner=owner,
|
||||
)
|
||||
|
||||
def retrieve(self, query: str, k: int = 5) -> List[str]:
|
||||
"""Retrieve relevant chunks - delegates to VectorRAG."""
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from src.rag_manager import RAGManager
|
||||
|
||||
|
||||
class _FakeVectorRAG:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
def index_personal_documents(self, directory, file_extensions=None, owner=None):
|
||||
self.calls.append(
|
||||
{
|
||||
"directory": directory,
|
||||
"file_extensions": file_extensions,
|
||||
"owner": owner,
|
||||
}
|
||||
)
|
||||
return {"success": True, "indexed_count": 1}
|
||||
|
||||
|
||||
def test_rag_manager_forwards_owner_and_file_extensions():
|
||||
fake = _FakeVectorRAG()
|
||||
manager = RAGManager.__new__(RAGManager)
|
||||
manager.vector_rag = fake
|
||||
extensions = {".md", ".txt"}
|
||||
|
||||
result = manager.index_personal_documents(
|
||||
"/tmp/personal",
|
||||
file_extensions=extensions,
|
||||
owner="alice",
|
||||
)
|
||||
|
||||
assert result == {"success": True, "indexed_count": 1}
|
||||
assert fake.calls == [
|
||||
{
|
||||
"directory": "/tmp/personal",
|
||||
"file_extensions": extensions,
|
||||
"owner": "alice",
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user