From e461743dec623c4d355c5165009f8b764674702d Mon Sep 17 00:00:00 2001 From: abhjaw <54004795+abhjaw@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:06:31 -0800 Subject: [PATCH] Update kendra.py Fixing issue - https://github.com/langchain-ai/langchain/issues/14494 to avoid Kendra query ValidationException --- libs/community/langchain_community/retrievers/kendra.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/retrievers/kendra.py b/libs/community/langchain_community/retrievers/kendra.py index ec1554c0abf8b..5254ef49bff1d 100644 --- a/libs/community/langchain_community/retrievers/kendra.py +++ b/libs/community/langchain_community/retrievers/kendra.py @@ -379,7 +379,7 @@ def create_client(cls, values: Dict[str, Any]) -> Dict[str, Any]: def _kendra_query(self, query: str) -> Sequence[ResultItem]: kendra_kwargs = { "IndexId": self.index_id, - "QueryText": query.strip(), + "QueryText": query.strip()[0:999], #trucate the query to ensure that there is no validation exception from Kendra. "PageSize": self.top_k, } if self.attribute_filter is not None: