a7d6d88f6f
CI / changes (push) Has been cancelled
CI / cd libs/checkpoint (push) Has been cancelled
CI / cd libs/checkpoint-conformance (push) Has been cancelled
CI / cd libs/checkpoint-postgres (push) Has been cancelled
CI / cd libs/checkpoint-sqlite (push) Has been cancelled
CI / cd libs/cli (push) Has been cancelled
CI / cd libs/prebuilt (push) Has been cancelled
CI / cd libs/sdk-py (push) Has been cancelled
CI / cd libs/langgraph (push) Has been cancelled
CI / Check SDK methods matching (push) Has been cancelled
CI / Check CLI schema hasn't changed #3.13 (push) Has been cancelled
CI / CLI integration test (push) Has been cancelled
CI / sdk-py integration test (push) Has been cancelled
CI / CI Success (push) Has been cancelled
baseline / benchmark (push) Has been cancelled
Deploy Redirects to GitHub Pages / deploy (push) Has been cancelled
29 lines
842 B
Python
29 lines
842 B
Python
"""Redefined messages as a work-around for pydantic issue with AnyStr.
|
|
|
|
The code below creates version of pydantic models
|
|
that will work in unit tests with AnyStr as id field
|
|
Please note that the `id` field is assigned AFTER the model is created
|
|
to workaround an issue with pydantic ignoring the __eq__ method on
|
|
subclassed strings.
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
from langchain_core.messages import HumanMessage, ToolMessage
|
|
|
|
from tests.any_str import AnyStr
|
|
|
|
|
|
def _AnyIdHumanMessage(**kwargs: Any) -> HumanMessage:
|
|
"""Create a human message with an any id field."""
|
|
message = HumanMessage(**kwargs)
|
|
message.id = AnyStr()
|
|
return message
|
|
|
|
|
|
def _AnyIdToolMessage(**kwargs: Any) -> ToolMessage:
|
|
"""Create a tool message with an any id field."""
|
|
message = ToolMessage(**kwargs)
|
|
message.id = AnyStr()
|
|
return message
|