diff --git a/libs/community/langchain_community/retrievers/kendra.py b/libs/community/langchain_community/retrievers/kendra.py index ec1554c0abf8b..e93ef3ff5695d 100644 --- a/libs/community/langchain_community/retrievers/kendra.py +++ b/libs/community/langchain_community/retrievers/kendra.py @@ -379,7 +379,9 @@ 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(), + # truncate the query to ensure that + # there is no validation exception from Kendra. + "QueryText": query.strip()[0:999], "PageSize": self.top_k, } if self.attribute_filter is not None: