Skip to content

Commit

Permalink
Backport PR #735: Catch embedding model validation errors on extensio…
Browse files Browse the repository at this point in the history
…n init (#740)

Co-authored-by: david qiu <[email protected]>
  • Loading branch information
meeseeksmachine and dlqqq authored Apr 22, 2024
1 parent 011c0ea commit d13a73c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,23 @@ def __init__(self, *args, **kwargs):

def _load(self):
"""Loads the vector store."""
embeddings = self.get_embedding_model()
if not embeddings:
if self.index is not None:
return
if self.index is None:
try:
self.index = FAISS.load_local(
INDEX_SAVE_DIR, embeddings, index_name=self.index_name
)
self.load_metadata()
except Exception as e:
self.log.error("Could not load vector index from disk.")

try:
embeddings = self.get_embedding_model()
if not embeddings:
return

self.index = FAISS.load_local(
INDEX_SAVE_DIR, embeddings, index_name=self.index_name
)
self.load_metadata()
except Exception as e:
self.log.error(
"Could not load vector index from disk. Full exception details printed below."
)
self.log.error(e)

async def process_message(self, message: HumanChatMessage):
# If no embedding provider has been selected
Expand Down

0 comments on commit d13a73c

Please sign in to comment.