feat(rag): Implement auto-indexing and status indicators
This commit is contained in:
@@ -986,6 +986,8 @@ class AppController:
|
||||
self.rag_config = models.RAGConfig()
|
||||
|
||||
self.rag_engine = rag_engine.RAGEngine(self.rag_config, self.active_project_root)
|
||||
if self.rag_config.enabled and self.rag_engine.is_empty():
|
||||
self._rebuild_rag_index()
|
||||
|
||||
from src.personas import PersonaManager
|
||||
self.persona_manager = PersonaManager(Path(self.active_project_path).parent if self.active_project_path else None)
|
||||
|
||||
+17
-1
@@ -483,7 +483,23 @@ class App:
|
||||
except Exception as e:
|
||||
self.ai_status = f"error: {e}"
|
||||
imgui.end_menu()
|
||||
|
||||
|
||||
# RAG status indicator
|
||||
if self.controller.rag_config and self.controller.rag_config.enabled:
|
||||
imgui.same_line()
|
||||
status = self.controller.rag_status
|
||||
if status == "indexing...":
|
||||
color = vec4(100, 255, 100)
|
||||
elif status == "error":
|
||||
color = vec4(255, 100, 100)
|
||||
else:
|
||||
color = vec4(180, 180, 180)
|
||||
imgui.text_colored(color, f"[RAG: {status}]")
|
||||
if imgui.is_item_hovered():
|
||||
imgui.set_tooltip(f"RAG is enabled. Status: {status}. Click to rebuild index.")
|
||||
if imgui.is_item_clicked():
|
||||
self.controller._rebuild_rag_index()
|
||||
|
||||
# Draw right-aligned window controls directly in the menu bar (Win32 only)
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
|
||||
@@ -80,6 +80,15 @@ class RAGEngine:
|
||||
else:
|
||||
raise ValueError(f"Unknown vector store provider: {vs_config.provider}")
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
if not self.config.enabled:
|
||||
return True
|
||||
if self.config.vector_store.provider == 'mock' or self.collection == "mock":
|
||||
return True
|
||||
if self.collection is None:
|
||||
return True
|
||||
return self.collection.count() == 0
|
||||
|
||||
def add_documents(self, ids: List[str], texts: List[str], metadatas: Optional[List[Dict[str, Any]]] = None):
|
||||
if not self.config.enabled or self.collection == "mock":
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user