Handled a bug around empty query results differently (#29877)

Thank you for contributing to LangChain!

- [ ] **Handled query records properly**: "community:
vectorstores/kinetica"

- [ ] **Bugfix for empty query results handling**: 
- **Description:** checked for the number of records returned by a query
before processing further
- **Issue:** resulted in an `AttributeError` earlier which has now been
fixed

@efriis
This commit is contained in:
am-kinetica 2025-02-20 22:37:49 +05:30 committed by GitHub
parent 2c403a3ea9
commit ca7eccba1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -430,16 +430,20 @@ class Kinetica(VectorStore):
) -> List[Tuple[Document, float]]:
# from gpudb import GPUdbException
results = []
resp: Dict = self.__query_collection(embedding, k, filter)
if resp and resp["status_info"]["status"] == "OK" and "records" in resp:
records: OrderedDict = resp["records"]
results = list(zip(*list(records.values())))
if resp and resp["status_info"]["status"] == "OK":
total_records = resp["total_number_of_records"]
if total_records > 0:
records: OrderedDict = resp["records"]
results = list(zip(*list(records.values())))
return self._results_to_docs_and_scores(results)
self.logger.error(resp["status_info"]["message"])
# raise GPUdbException(resp["status_info"]["message"])
return []
return self._results_to_docs_and_scores(results)
else:
self.logger.warning(
f"No records found; status: {resp['status_info']['status']}"
)
return results
def similarity_search_by_vector(
self,