Skip to content

Commit

Permalink
Gracefully skip indexing when empty list of docs provided
Browse files Browse the repository at this point in the history
Improve error message when fail to index content
  • Loading branch information
debanjum committed Jun 5, 2024
1 parent 21987f6 commit a1e4f4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/khoj/processor/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def embed_documents(self, docs):
embeddings += generated_embeddings
pbar.update(1000)
return embeddings
return self.embeddings_model.encode(docs, **self.docs_encode_kwargs).tolist()
return self.embeddings_model.encode(docs, **self.docs_encode_kwargs).tolist() if docs else []


class CrossEncoderModel:
Expand Down
2 changes: 1 addition & 1 deletion src/khoj/routers/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def update(
except Exception as e:
logger.error(f"Failed to process batch indexing request: {e}", exc_info=True)
logger.error(
f"🚨 Failed to {force} update {t} content index triggered via API call by {client} client: {e}",
f'🚨 Failed to {"force " if force else ""}update {t} content index triggered via API call by {client} client: {e}',
exc_info=True,
)
return Response(content="Failed", status_code=500)
Expand Down

0 comments on commit a1e4f4b

Please sign in to comment.