From 05a44797ee8b8626a6a5542599a3058f44ebd446 Mon Sep 17 00:00:00 2001 From: Yudai Kotani Date: Wed, 18 Dec 2024 23:43:04 +0900 Subject: [PATCH] langchain_community: Add default None values to DocumentAttributeValue class properties (#28785) **Description**: This PR addresses an issue where the DocumentAttributeValue class properties did not have default values of None. By explicitly setting the Optional attributes (DateValue, LongValue, StringListValue, and StringValue) to default to None, this change ensures the class functions as expected when no value is provided for these attributes. **Changes Made**: Added default None values to the following properties of the DocumentAttributeValue class: DateValue LongValue StringListValue StringValue Removed the invalid argument extra="allow" from the BaseModel inheritance. Dependencies: None. **Twitter handle (optional)**: @__korikori1021 **Checklist** - [x] Verified that KendraRetriever works as expected after the changes. Co-authored-by: y1u0d2a1i --- libs/community/langchain_community/retrievers/kendra.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/community/langchain_community/retrievers/kendra.py b/libs/community/langchain_community/retrievers/kendra.py index fe36e85dbe1..d674c368663 100644 --- a/libs/community/langchain_community/retrievers/kendra.py +++ b/libs/community/langchain_community/retrievers/kendra.py @@ -119,13 +119,13 @@ class AdditionalResultAttribute(BaseModel, extra="allow"): # type: ignore[call- class DocumentAttributeValue(BaseModel, extra="allow"): # type: ignore[call-arg] """Value of a document attribute.""" - DateValue: Optional[str] + DateValue: Optional[str] = None """The date expressed as an ISO 8601 string.""" - LongValue: Optional[int] + LongValue: Optional[int] = None """The long value.""" - StringListValue: Optional[List[str]] + StringListValue: Optional[List[str]] = None """The string list value.""" - StringValue: Optional[str] + StringValue: Optional[str] = None """The string value.""" @property