langchain/tests/unit_tests/chat_models/test_openai.py
Harrison Chase 3bfe7cf467
Harrison/split schema dir (#7025)
should be no functional changes

also keep __init__ exposing a lot for backwards compat

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-07-01 13:39:19 -04:00

24 lines
591 B
Python

"""Test OpenAI Chat API wrapper."""
import json
from langchain.chat_models.openai import (
_convert_dict_to_message,
)
from langchain.schema.messages 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