Skip to content

Commit

Permalink
query PineconeGrpcFuture?
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-inkeep committed Nov 5, 2024
1 parent 463c30d commit eb18f37
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pinecone/grpc/index_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ def query(
include_values: Optional[bool] = None,
include_metadata: Optional[bool] = None,
sparse_vector: Optional[Union[GRPCSparseValues, SparseVectorTypedDict]] = None,
async_req: Optional[bool] = False,
**kwargs,
) -> QueryResponse:
) -> Union[QueryResponse, PineconeGrpcFuture]:
"""
The Query operation searches a namespace, using a query vector.
It retrieves the ids of the most similar items in a namespace, along with their similarity scores.
Expand Down Expand Up @@ -392,9 +393,14 @@ def query(
request = QueryRequest(**args_dict)

timeout = kwargs.pop("timeout", None)
response = self.runner.run(self.stub.Query, request, timeout=timeout)
json_response = json_format.MessageToDict(response)
return parse_query_response(json_response, _check_type=False)

if async_req:
future = self.runner.run(self.stub.Query.future, request, timeout=timeout)
return PineconeGrpcFuture(future, result_transformer=parse_fetch_response)
else:
response = self.runner.run(self.stub.Query, request, timeout=timeout)
return parse_fetch_response(response)


def update(
self,
Expand Down

0 comments on commit eb18f37

Please sign in to comment.