mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-07 22:11:51 +00:00
core(fix): revert set_text
optimization (#31555)
Revert serialization regression introduced in https://github.com/langchain-ai/langchain/pull/31238 Fixes https://github.com/langchain-ai/langchain/issues/31486
This commit is contained in:
@@ -3,7 +3,7 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
from langchain_core.load import Serializable, dumpd, load
|
||||
from langchain_core.load.serializable import _is_field_useful
|
||||
from langchain_core.messages import AIMessage
|
||||
from langchain_core.outputs import ChatGeneration
|
||||
from langchain_core.outputs import ChatGeneration, Generation
|
||||
|
||||
|
||||
class NonBoolObj:
|
||||
@@ -223,3 +223,8 @@ def test_serialization_with_pydantic() -> None:
|
||||
assert isinstance(deser, ChatGeneration)
|
||||
assert deser.message.content
|
||||
assert deser.message.additional_kwargs["parsed"] == my_model.model_dump()
|
||||
|
||||
|
||||
def test_serialization_with_generation() -> None:
|
||||
generation = Generation(text="hello-world")
|
||||
assert dumpd(generation)["kwargs"] == {"text": "hello-world", "type": "Generation"}
|
||||
|
Reference in New Issue
Block a user