mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
26 lines
591 B
Python
26 lines
591 B
Python
|
"""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
|