MCPcopy Index your code
hub / github.com/PromtEngineer/localGPT / _apply_index_embedding_model

Function _apply_index_embedding_model

rag_system/api_server.py:42–69  ·  view source on GitHub ↗

Ensure retrieval pipeline uses the embedding model stored with the first index.

(idx_ids)

Source from the content-addressed store, hash-verified

40# -------------- Helper ----------------
41
42def _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
71def _get_table_name_for_session(session_id):
72 """Get the correct vector table name for a session by looking up its linked indexes."""

Callers 2

handle_chatMethod · 0.85
handle_chat_streamMethod · 0.85

Calls 2

get_indexMethod · 0.80

Tested by

no test coverage detected