Skip to content

Commit

Permalink
Update kendra.py to avoid Kendra query ValidationException (#14866)
Browse files Browse the repository at this point in the history
Fixing issue - #14494 to
avoid Kendra query ValidationException

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
- **Description:** Update kendra.py to avoid Kendra query
ValidationException,
- **Issue:** the issue
##14494,
  - **Dependencies:** None,
  - **Tag maintainer:** ,
  - **Twitter handle:** 

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->

---------

Co-authored-by: Harrison Chase <[email protected]>
  • Loading branch information
abhjaw and hwchase17 authored Dec 19, 2023
1 parent 7b2a68a commit 6fbd068
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/community/langchain_community/retrievers/kendra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6fbd068

Please sign in to comment.