Bagatur/pinecone by vector (#9087)

Co-authored-by: joseph <joe@outverse.com>
pull/5769/head^2
Bagatur 1 year ago committed by GitHub
parent 6abb2c2c08
commit b80e3825a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -142,12 +142,25 @@ class Pinecone(VectorStore):
Returns:
List of Documents most similar to the query and score for each
"""
return self.similarity_search_by_vector_with_score(
self._embed_query(query), k=k, filter=filter, namespace=namespace
)
def similarity_search_by_vector_with_score(
self,
embedding: List[float],
*,
k: int = 4,
filter: Optional[dict] = None,
namespace: Optional[str] = None,
) -> List[Tuple[Document, float]]:
"""Return pinecone documents most similar to embedding, along with scores."""
if namespace is None:
namespace = self._namespace
query_obj = self._embed_query(query)
docs = []
results = self._index.query(
[query_obj],
[embedding],
top_k=k,
include_metadata=True,
namespace=namespace,

Loading…
Cancel
Save