From e53995836aff54e625b625cb5ae28687f2a6d0dc Mon Sep 17 00:00:00 2001 From: Piyush Jain Date: Tue, 27 Jun 2023 16:30:11 -0700 Subject: [PATCH] Added missing attribute value object (#6849) ## Description Adds a missing type class for [AdditionalResultAttributeValue](https://docs.aws.amazon.com/kendra/latest/APIReference/API_AdditionalResultAttributeValue.html). Fixes validation failure for the query API that have `AdditionalAttributes` in the response. cc @dev2049 cc @zhichenggeng --- langchain/retrievers/kendra.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/langchain/retrievers/kendra.py b/langchain/retrievers/kendra.py index d694a20430f..c86b8122445 100644 --- a/langchain/retrievers/kendra.py +++ b/langchain/retrievers/kendra.py @@ -32,16 +32,17 @@ class TextWithHighLights(BaseModel, extra=Extra.allow): Highlights: Optional[Any] +class AdditionalResultAttributeValue(BaseModel, extra=Extra.allow): + TextWithHighlightsValue: TextWithHighLights + + class AdditionalResultAttribute(BaseModel, extra=Extra.allow): Key: str ValueType: Literal["TEXT_WITH_HIGHLIGHTS_VALUE"] - Value: Optional[TextWithHighLights] + Value: AdditionalResultAttributeValue def get_value_text(self) -> str: - if not self.Value: - return "" - else: - return self.Value.Text + return self.Value.TextWithHighlightsValue.Text class QueryResultItem(BaseModel, extra=Extra.allow):