mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 23:13:31 +00:00
community[patch]: Extend Baichuan model with tool support (#24529)
**Description:** Expanded the chat model functionality to support tools in the 'baichuan.py' file. Updated module imports and added tool object handling in message conversions. Additional changes include the implementation of tool binding and related unit tests. The alterations offer enhanced model capabilities by enabling interaction with tool-like objects. --------- Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ from langchain_core.messages import (
|
||||
HumanMessage,
|
||||
HumanMessageChunk,
|
||||
SystemMessage,
|
||||
ToolMessage,
|
||||
)
|
||||
from langchain_core.pydantic_v1 import SecretStr
|
||||
from pytest import CaptureFixture, MonkeyPatch
|
||||
@@ -58,6 +59,18 @@ def test__convert_message_to_dict_system() -> None:
|
||||
assert result == expected_output
|
||||
|
||||
|
||||
def test__convert_message_to_dict_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
|
||||
|
||||
|
||||
def test__convert_message_to_dict_function() -> None:
|
||||
message = FunctionMessage(name="foo", content="bar")
|
||||
with pytest.raises(TypeError) as e:
|
||||
|
Reference in New Issue
Block a user