mirror of
https://github.com/hwchase17/langchain
synced 2024-11-20 03:25:56 +00:00
Update kendra.py to avoid Kendra query ValidationException (#14866)
Fixing issue - https://github.com/langchain-ai/langchain/issues/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 #https://github.com/langchain-ai/langchain/issues/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 <hw.chase.17@gmail.com>
This commit is contained in:
parent
7b2a68ac72
commit
6fbd068b3f
@ -379,7 +379,9 @@ class AmazonKendraRetriever(BaseRetriever):
|
|||||||
def _kendra_query(self, query: str) -> Sequence[ResultItem]:
|
def _kendra_query(self, query: str) -> Sequence[ResultItem]:
|
||||||
kendra_kwargs = {
|
kendra_kwargs = {
|
||||||
"IndexId": self.index_id,
|
"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,
|
"PageSize": self.top_k,
|
||||||
}
|
}
|
||||||
if self.attribute_filter is not None:
|
if self.attribute_filter is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user