From d8bb6b24c4f5dec9bdf846780e39fa51183b296c Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Wed, 14 May 2025 08:08:37 -0700 Subject: [PATCH] remove another id -> str custom validator --- libs/core/langchain_core/documents/base.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libs/core/langchain_core/documents/base.py b/libs/core/langchain_core/documents/base.py index fba997f4959..685271b54f8 100644 --- a/libs/core/langchain_core/documents/base.py +++ b/libs/core/langchain_core/documents/base.py @@ -33,7 +33,7 @@ class BaseMedia(Serializable): # The ID field is optional at the moment. # It will likely become required in a future major release after # it has been adopted by enough vectorstore implementations. - id: Optional[str] = None + id: Optional[str] = Field(default=None, coerce_numbers_to_str=True) """An optional identifier for the document. Ideally this should be unique across the document collection and formatted @@ -45,17 +45,6 @@ class BaseMedia(Serializable): metadata: dict = Field(default_factory=dict) """Arbitrary metadata associated with the content.""" - @field_validator("id", mode="before") - def cast_id_to_str(cls, id_value: Any) -> Optional[str]: - """Coerce the id field to a string. - - Args: - id_value: The id value to coerce. - """ - if id_value is not None: - return str(id_value) - return id_value - class Blob(BaseMedia): """Blob represents raw data by either reference or value.