mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 23:13:31 +00:00
community[patch]: Add ToolMessage for ChatZhipuAI (#25547)
- **Description:** Add ToolMessage for `ChatZhipuAI` to solve the issue #25490
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
"""Test ZhipuAI Chat API wrapper"""
|
||||
|
||||
import pytest
|
||||
from langchain_core.messages import ToolMessage
|
||||
|
||||
from langchain_community.chat_models.zhipuai import ChatZhipuAI
|
||||
from langchain_community.chat_models.zhipuai import (
|
||||
ChatZhipuAI,
|
||||
_convert_message_to_dict,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.requires("httpx", "httpx_sse", "jwt")
|
||||
@@ -11,3 +15,15 @@ def test_zhipuai_model_param() -> None:
|
||||
assert llm.model_name == "foo"
|
||||
llm = ChatZhipuAI(api_key="test", model_name="foo") # type: ignore[call-arg]
|
||||
assert llm.model_name == "foo"
|
||||
|
||||
|
||||
def test__convert_message_to_dict_with_tool() -> None:
|
||||
message = ToolMessage(name="foo", content="bar", tool_call_id="abc123")
|
||||
result = _convert_message_to_dict(message)
|
||||
expected_output = {
|
||||
"name": "foo",
|
||||
"content": "bar",
|
||||
"tool_call_id": "abc123",
|
||||
"role": "tool",
|
||||
}
|
||||
assert result == expected_output
|
||||
|
Reference in New Issue
Block a user