Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialization fix for defaults #757

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions langserve/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/test_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading