-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
core[minor]: add name to basemessage #17539
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
assert AIMessageChunk(content="I am") + HumanMessageChunk( | ||
content=" indeed." | ||
) == AIMessageChunk( | ||
content="I am indeed." | ||
), "MessageChunk + MessageChunk should be a MessageChunk of same class as the left side" # noqa: E501 | ||
|
||
assert ( | ||
AIMessageChunk(content="", additional_kwargs={"foo": "bar"}) | ||
+ AIMessageChunk(content="", additional_kwargs={"baz": "foo"}) | ||
== AIMessageChunk(content="", additional_kwargs={"foo": "bar", "baz": "foo"}) | ||
assert AIMessageChunk( | ||
content="", additional_kwargs={"foo": "bar"} | ||
) + AIMessageChunk(content="", additional_kwargs={"baz": "foo"}) == AIMessageChunk( | ||
content="", additional_kwargs={"foo": "bar", "baz": "foo"} | ||
), "MessageChunk + MessageChunk should be a MessageChunk with merged additional_kwargs" # noqa: E501 | ||
|
||
assert ( | ||
AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"name": "web_search"}} | ||
) | ||
+ AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"arguments": None}} | ||
) | ||
+ AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"arguments": "{\n"}} | ||
) | ||
+ AIMessageChunk( | ||
content="", | ||
additional_kwargs={ | ||
"function_call": {"arguments": ' "query": "turtles"\n}'} | ||
}, | ||
) | ||
== AIMessageChunk( | ||
content="", | ||
additional_kwargs={ | ||
"function_call": { | ||
"name": "web_search", | ||
"arguments": '{\n "query": "turtles"\n}', | ||
} | ||
}, | ||
) | ||
assert AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"name": "web_search"}} | ||
) + AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"arguments": None}} | ||
) + AIMessageChunk( | ||
content="", additional_kwargs={"function_call": {"arguments": "{\n"}} | ||
) + AIMessageChunk( | ||
content="", | ||
additional_kwargs={"function_call": {"arguments": ' "query": "turtles"\n}'}}, | ||
) == AIMessageChunk( | ||
content="", | ||
additional_kwargs={ | ||
"function_call": { | ||
"name": "web_search", | ||
"arguments": '{\n "query": "turtles"\n}', | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no changes here - just formatting
@@ -192,6 +185,21 @@ def test_multiple_msg() -> None: | |||
assert messages_from_dict(messages_to_dict(msgs)) == msgs | |||
|
|||
|
|||
def test_multiple_msg_with_name() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test to confirm name loads/dumps with dict
@@ -480,3 +488,49 @@ def test_convert_to_messages() -> None: | |||
HumanMessage(content="Hello!"), | |||
AIMessage(content="Hi!"), | |||
] | |||
|
|||
|
|||
@pytest.mark.parametrize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test all message types with name except tool (different case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add "name" to snapshots
Adds an optional name param to our base message to support passing names into LLMs.
OpenAI supports having a name on anything except tool message now (system, ai, user/human).