Home / Function/ test_lc_tool_call_to_openai_tool_call_unicode() — langchain Function Reference

test_lc_tool_call_to_openai_tool_call_unicode() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 2974–2997

def test_lc_tool_call_to_openai_tool_call_unicode() -> None:
    """Test that Unicode characters in tool call args are preserved correctly."""
    from langchain_openai.chat_models.base import _lc_tool_call_to_openai_tool_call

    tool_call = ToolCall(
        id="call_123",
        name="create_customer",
        args={"customer_name": "你好啊集团"},
        type="tool_call",
    )

    result = _lc_tool_call_to_openai_tool_call(tool_call)

    assert result["type"] == "function"
    assert result["id"] == "call_123"
    assert result["function"]["name"] == "create_customer"

    # Ensure Unicode characters are preserved, not escaped as \\uXXXX
    arguments_str = result["function"]["arguments"]
    parsed_args = json.loads(arguments_str)
    assert parsed_args["customer_name"] == "你好啊集团"
    # Also ensure the raw JSON string contains Unicode, not escaped sequences
    assert "你好啊集团" in arguments_str
    assert "\\u4f60" not in arguments_str  # Should not contain escaped Unicode

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free