diff --git a/langserve/serialization.py b/langserve/serialization.py index 41433fc9..5093d5de 100644 --- a/langserve/serialization.py +++ b/langserve/serialization.py @@ -116,8 +116,6 @@ def _decode_lc_objects(value: Any) -> Any: try: obj = WellKnownLCObject.model_validate(v) parsed = obj.root - if set(parsed.model_dump()) != set(value): - raise ValueError("Invalid object") return parsed except (ValidationError, ValueError, TypeError): return v diff --git a/poetry.lock b/poetry.lock index f1c0ce0e..75250b0e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1564,18 +1564,18 @@ test = ["hatch", "ipykernel", "openapi-core (>=0.18.0,<0.19.0)", "openapi-spec-v [[package]] name = "langchain-core" -version = "0.3.0.dev4" +version = "0.3.0.dev5" description = "Building applications with LLMs through composability" optional = false python-versions = "<4.0,>=3.9" files = [ - {file = "langchain_core-0.3.0.dev4-py3-none-any.whl", hash = "sha256:5b2e84b7ab9d3ed93341f44a276f046bfdd4df349801ed50d4201af7a29cf3ac"}, - {file = "langchain_core-0.3.0.dev4.tar.gz", hash = "sha256:d090e34739599531a1c2597f5522091a647917c009fbd786cedd539dfa7b8a98"}, + {file = "langchain_core-0.3.0.dev5-py3-none-any.whl", hash = "sha256:8de38ea9dd15f9705d20ee44af7160216052467d47893d5473e0e878861685be"}, + {file = "langchain_core-0.3.0.dev5.tar.gz", hash = "sha256:d0986b3e2810522d90eb09d048ee4a92b079a334b313f4b7429624b4a062adff"}, ] [package.dependencies] jsonpatch = ">=1.33,<2.0" -langsmith = ">=0.1.112,<0.2.0" +langsmith = ">=0.1.117,<0.2.0" packaging = ">=23.2,<25" pydantic = ">=2.7.4,<3.0.0" PyYAML = ">=5.3" @@ -3882,4 +3882,4 @@ server = ["fastapi", "sse-starlette"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "3a5eccd3cb9078e545ff256d4bf7c38924fee54fd896be3f1524aee089a187ac" +content-hash = "bee76de01384e265c807d785959226cdf9c788b4d5dfc3772dcce5d70a8f6121" diff --git a/pyproject.toml b/pyproject.toml index 8a949e6a..c0357cbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ python = "^3.9" httpx = ">=0.23.0" # May be able to decrease this version fastapi = {version = ">=0.90.1,<1", optional = true} sse-starlette = {version = "^1.3.0", optional = true} -langchain-core = "0.3.0dev4" +langchain-core = "0.3.0dev5" orjson = ">=2" pyproject-toml = "^0.0.10" pydantic = "^2.7" diff --git a/tests/unit_tests/test_serialization.py b/tests/unit_tests/test_serialization.py index 526c7954..9d3f7a4e 100644 --- a/tests/unit_tests/test_serialization.py +++ b/tests/unit_tests/test_serialization.py @@ -6,6 +6,7 @@ import pytest from langchain_core.documents.base import Document from langchain_core.messages import HumanMessage, HumanMessageChunk, SystemMessage +from langchain_core.outputs import ChatGeneration from pydantic import BaseModel from langserve.serialization import ( @@ -48,8 +49,7 @@ def test_document_serialization() -> None: "numbers": [1, 2, 3], "boom": "Hello, world!", }, - # Requires typing ChatGeneration with Anymessage - # [ChatGeneration(message=HumanMessage(content="Hello"))], + [ChatGeneration(message=HumanMessage(content="Hello"))], ], ) def test_serialization(data: Any) -> None: diff --git a/tests/unit_tests/test_server_client.py b/tests/unit_tests/test_server_client.py index 6d78b31f..3cadda82 100644 --- a/tests/unit_tests/test_server_client.py +++ b/tests/unit_tests/test_server_client.py @@ -2675,6 +2675,7 @@ async def test_astream_events_with_prompt_model_parser_chain( { "additional_kwargs": {}, "content": "hello", + "example": False, "name": None, "response_metadata": {}, "type": "human", @@ -2867,6 +2868,7 @@ async def test_astream_events_with_prompt_model_parser_chain( ], "llm_output": None, "run": None, + "type": "LLMResult", }, }, "event": "on_chat_model_end",