Home / Function/ test_streaming_tool_call() — langchain Function Reference

test_streaming_tool_call() — langchain Function Reference

Architecture documentation for the test_streaming_tool_call() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5fb43796_d8be_bf73_b1ed_f82bc6b663f9["test_streaming_tool_call()"]
  af57ae60_607e_c138_9ab0_fb8bb1c5916a["test_chat_models.py"]
  5fb43796_d8be_bf73_b1ed_f82bc6b663f9 -->|defined in| af57ae60_607e_c138_9ab0_fb8bb1c5916a
  style 5fb43796_d8be_bf73_b1ed_f82bc6b663f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/groq/tests/integration_tests/test_chat_models.py lines 459–493

def test_streaming_tool_call() -> None:
    """Test that tool choice is respected."""
    llm = ChatGroq(model=DEFAULT_MODEL_NAME)

    class MyTool(BaseModel):
        name: str
        age: int

    with_tool = llm.bind_tools([MyTool], tool_choice="MyTool")

    resp = with_tool.stream("Who was the 27 year old named Erick?")
    additional_kwargs = None
    for chunk in resp:
        assert isinstance(chunk, AIMessageChunk)
        assert chunk.content == ""  # should just be tool call
        additional_kwargs = chunk.additional_kwargs

    assert additional_kwargs is not None
    tool_calls = additional_kwargs["tool_calls"]
    assert len(tool_calls) == 1
    tool_call = tool_calls[0]
    assert tool_call["function"]["name"] == "MyTool"
    assert json.loads(tool_call["function"]["arguments"]) == {
        "age": 27,
        "name": "Erick",
    }
    assert tool_call["type"] == "function"

    assert isinstance(chunk, AIMessageChunk)
    assert isinstance(chunk.tool_call_chunks, list)
    assert len(chunk.tool_call_chunks) == 1
    tool_call_chunk = chunk.tool_call_chunks[0]
    assert tool_call_chunk["name"] == "MyTool"
    assert isinstance(tool_call_chunk["args"], str)
    assert json.loads(tool_call_chunk["args"]) == {"name": "Erick", "age": 27}

Domain

Subdomains

Frequently Asked Questions

What does test_streaming_tool_call() do?
test_streaming_tool_call() is a function in the langchain codebase, defined in libs/partners/groq/tests/integration_tests/test_chat_models.py.
Where is test_streaming_tool_call() defined?
test_streaming_tool_call() is defined in libs/partners/groq/tests/integration_tests/test_chat_models.py at line 459.

Analyze Your Own Codebase

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

Try Supermodel Free