Skip to content

Commit

Permalink
shortcut return
Browse files Browse the repository at this point in the history
  • Loading branch information
epinzur committed Oct 23, 2024
1 parent 76edf89 commit 9dcc670
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libs/astradb/langchain_astradb/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,9 +1801,6 @@ async def asimilarity_search_with_embedding(
k: Number of Documents to return. Defaults to 4.
filter: Filter on the metadata to apply.
Notes:
Either 'query' or 'query_embedding' must be set.
Returns:
(query_embedding, List of (Document, embedding) most similar to the query).
"""
Expand Down Expand Up @@ -1831,6 +1828,10 @@ async def asimilarity_search_with_embedding(
)
raise TypeError(msg)

# shortcut return if query isn't needed.
if k == 0 and len(query_embedding) > 0:
return (query_embedding, [])

async_cursor = self.astra_env.async_collection.find(
filter=self.filter_to_query(filter),
projection=self.document_codec.full_projection,
Expand Down

0 comments on commit 9dcc670

Please sign in to comment.