The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Max marginal relecance search fails if there are not enough docs (#1117)
Tom Bocklisch47c3221fda9c
diff --git a/langchain/vectorstores/faiss.py b/langchain/vectorstores/faiss.pyindex ed1eeccdd5..e4bbd8dba9 100644--- a/langchain/vectorstores/faiss.py+++ b/langchain/vectorstores/faiss.py@@ -189,6 +189,9 @@ class FAISS(VectorStore):docs = []for i in selected_indices:_id = self.index_to_docstore_id[i]+ if _id == -1:+ # This happens when not enough docs are returned.+ continuedoc = self.docstore.search(_id)if not isinstance(doc, Document):raise ValueError(f"Could not find document for id {_id}, got {doc}")