fix(rag): Final RAG stability and status fixes
- Corrected GeminiEmbeddingProvider model name to gemini-embedding-001. - Prevented _fetch_models from overwriting active i_status (sending/done/error). - Updated est_rag_engine.py to correctly patch the lazy-loaded chromadb getter. - Adjusted RAG simulation tests to account for the new initializing... status and automatic initial indexing. - Fixed typo in est_z_negative_flows.py.
This commit is contained in:
@@ -1983,8 +1983,10 @@ class AppController:
|
|||||||
if self.current_model not in models_list and models_list:
|
if self.current_model not in models_list and models_list:
|
||||||
self.current_model = models_list[0]
|
self.current_model = models_list[0]
|
||||||
ai_client.set_provider(self._current_provider, self.current_model)
|
ai_client.set_provider(self._current_provider, self.current_model)
|
||||||
|
if self.ai_status == "fetching models...":
|
||||||
self.ai_status = f"models loaded: {len(models_list)}"
|
self.ai_status = f"models loaded: {len(models_list)}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if self.ai_status == "fetching models...":
|
||||||
self.ai_status = f"model fetch error: {e}"
|
self.ai_status = f"model fetch error: {e}"
|
||||||
self.models_thread = threading.Thread(target=do_fetch, daemon=True)
|
self.models_thread = threading.Thread(target=do_fetch, daemon=True)
|
||||||
self.models_thread.start()
|
self.models_thread.start()
|
||||||
|
|||||||
@@ -19,14 +19,17 @@ def test_rag_engine_init_mock(mock_rag_config):
|
|||||||
assert engine.collection == "mock"
|
assert engine.collection == "mock"
|
||||||
|
|
||||||
@patch('src.rag_engine.LocalEmbeddingProvider.embed')
|
@patch('src.rag_engine.LocalEmbeddingProvider.embed')
|
||||||
@patch('src.rag_engine.chromadb.PersistentClient')
|
@patch('src.rag_engine._get_chromadb')
|
||||||
def test_rag_engine_chroma(mock_chroma, mock_embed):
|
def test_rag_engine_chroma(mock_get_chroma, mock_embed):
|
||||||
mock_embed.return_value = [[0.1, 0.2, 0.3]]
|
mock_chroma = MagicMock()
|
||||||
|
mock_settings = MagicMock()
|
||||||
|
mock_get_chroma.return_value = (mock_chroma, mock_settings)
|
||||||
|
|
||||||
|
mock_embed.return_value = [[0.1, 0.2, 0.3]]
|
||||||
mock_collection = MagicMock()
|
mock_collection = MagicMock()
|
||||||
mock_client = MagicMock()
|
mock_client = MagicMock()
|
||||||
mock_client.get_or_create_collection.return_value = mock_collection
|
mock_client.get_or_create_collection.return_value = mock_collection
|
||||||
mock_chroma.return_value = mock_client
|
mock_chroma.PersistentClient.return_value = mock_client
|
||||||
|
|
||||||
vs_config = models.VectorStoreConfig(provider='chroma', collection_name='test')
|
vs_config = models.VectorStoreConfig(provider='chroma', collection_name='test')
|
||||||
config = models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
|
config = models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def test_rag_full_lifecycle_sim(live_gui):
|
|||||||
|
|
||||||
# 3. Verify initial status
|
# 3. Verify initial status
|
||||||
status = client.get_value('rag_status')
|
status = client.get_value('rag_status')
|
||||||
assert status in ['idle', 'ready'], f"Unexpected initial status: {status}"
|
assert status in ['idle', 'ready', 'initializing...'], f"Unexpected initial status: {status}"
|
||||||
|
|
||||||
# 4. Trigger Rebuild Index
|
# 4. Trigger Rebuild Index
|
||||||
print("[SIM] Triggering index rebuild...")
|
print("[SIM] Triggering index rebuild...")
|
||||||
|
|||||||
Reference in New Issue
Block a user