Ensure retrieval pipeline uses the embedding model stored with the first index.
(idx_ids)
| 40 | # -------------- Helper ---------------- |
| 41 | |
| 42 | def _apply_index_embedding_model(idx_ids): |
| 43 | """Ensure retrieval pipeline uses the embedding model stored with the first index.""" |
| 44 | debug_info = f"🔧 _apply_index_embedding_model called with idx_ids: {idx_ids}\n" |
| 45 | |
| 46 | if not idx_ids: |
| 47 | debug_info += "⚠️ No index IDs provided\n" |
| 48 | with open("logs/embedding_debug.log", "a") as f: |
| 49 | f.write(debug_info) |
| 50 | return |
| 51 | try: |
| 52 | idx = db.get_index(idx_ids[0]) |
| 53 | debug_info += f"🔧 Retrieved index: {idx.get('id')} with metadata: {idx.get('metadata', {})}\n" |
| 54 | model = (idx.get("metadata") or {}).get("embedding_model") |
| 55 | debug_info += f"🔧 Embedding model from metadata: {model}\n" |
| 56 | if model: |
| 57 | rp = RAG_AGENT.retrieval_pipeline |
| 58 | current_model = rp.config.get("embedding_model_name") |
| 59 | debug_info += f"🔧 Current embedding model: {current_model}\n" |
| 60 | rp.update_embedding_model(model) |
| 61 | debug_info += f"🔧 Updated embedding model to: {model}\n" |
| 62 | else: |
| 63 | debug_info += "⚠️ No embedding model found in metadata\n" |
| 64 | except Exception as e: |
| 65 | debug_info += f"⚠️ Could not apply index embedding model: {e}\n" |
| 66 | |
| 67 | # Write debug info to file |
| 68 | with open("logs/embedding_debug.log", "a") as f: |
| 69 | f.write(debug_info) |
| 70 | |
| 71 | def _get_table_name_for_session(session_id): |
| 72 | """Get the correct vector table name for a session by looking up its linked indexes.""" |
no test coverage detected