mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-18 16:16:33 +00:00
add FunctionMessage support to _convert_dict_to_message()
in OpenAI chat model (#6382)
Already supported in the reverse operation in `_convert_message_to_dict()`, this just provides parity. @hwchase17 @agola11 --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
25
tests/unit_tests/chat_models/test_openai.py
Normal file
25
tests/unit_tests/chat_models/test_openai.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""Test OpenAI Chat API wrapper."""
|
||||
|
||||
import json
|
||||
|
||||
from langchain.chat_models.openai import (
|
||||
_convert_dict_to_message,
|
||||
)
|
||||
from langchain.schema import (
|
||||
FunctionMessage,
|
||||
)
|
||||
|
||||
|
||||
def test_function_message_dict_to_function_message() -> None:
|
||||
content = json.dumps({"result": "Example #1"})
|
||||
name = "test_function"
|
||||
result = _convert_dict_to_message(
|
||||
{
|
||||
"role": "function",
|
||||
"name": name,
|
||||
"content": content,
|
||||
}
|
||||
)
|
||||
assert isinstance(result, FunctionMessage)
|
||||
assert result.name == name
|
||||
assert result.content == content
|
Reference in New Issue
Block a user