mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 20:09:01 +00:00
huggingface: fix tool argument serialization in _convert_TGI_message_to_LC_message (#26075)
Currently `_convert_TGI_message_to_LC_message` replaces `'` in the tool arguments, so an argument like "It's" will be converted to `It"s` and could cause a json parser to fail. --------- Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Co-authored-by: Erick Friis <erick@langchain.dev> Co-authored-by: Vadym Barda <vadym@langchain.dev>
This commit is contained in:
@@ -66,7 +66,7 @@ def test_convert_message_to_chat_message(
|
||||
TGI_MESSAGE(
|
||||
role="assistant",
|
||||
content="",
|
||||
tool_calls=[{"function": {"arguments": "'function string'"}}],
|
||||
tool_calls=[{"function": {"arguments": "function string"}}],
|
||||
),
|
||||
AIMessage(
|
||||
content="",
|
||||
@@ -75,6 +75,23 @@ def test_convert_message_to_chat_message(
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
TGI_MESSAGE(
|
||||
role="assistant",
|
||||
content="",
|
||||
tool_calls=[
|
||||
{"function": {"arguments": {"answer": "function's string"}}}
|
||||
],
|
||||
),
|
||||
AIMessage(
|
||||
content="",
|
||||
additional_kwargs={
|
||||
"tool_calls": [
|
||||
{"function": {"arguments": '{"answer": "function\'s string"}'}}
|
||||
]
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_convert_TGI_message_to_LC_message(
|
||||
|
Reference in New Issue
Block a user