Home / Function/ test_openai_invoke_name() — langchain Function Reference

test_openai_invoke_name() — langchain Function Reference

Architecture documentation for the test_openai_invoke_name() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b53ad105_aedf_cb92_a5e6_a639fa4a37d2["test_openai_invoke_name()"]
  48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"]
  b53ad105_aedf_cb92_a5e6_a639fa4a37d2 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5
  style b53ad105_aedf_cb92_a5e6_a639fa4a37d2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 703–719

def test_openai_invoke_name(mock_client: MagicMock) -> None:
    llm = ChatOpenAI()

    with patch.object(llm, "client", mock_client):
        messages = [HumanMessage(content="Foo", name="Katie")]
        res = llm.invoke(messages)
        call_args, call_kwargs = mock_client.with_raw_response.create.call_args
        assert len(call_args) == 0  # no positional args
        call_messages = call_kwargs["messages"]
        assert len(call_messages) == 1
        assert call_messages[0]["role"] == "user"
        assert call_messages[0]["content"] == "Foo"
        assert call_messages[0]["name"] == "Katie"

        # check return type has name
        assert res.content == "Bar Baz"
        assert res.name == "Erick"

Domain

Subdomains

Frequently Asked Questions

What does test_openai_invoke_name() do?
test_openai_invoke_name() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test_openai_invoke_name() defined?
test_openai_invoke_name() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 703.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free