test_astreaming_tool_call() — langchain Function Reference
Architecture documentation for the test_astreaming_tool_call() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bacb6f37_ecd3_c556_0efc_70b91dcc90e9["test_astreaming_tool_call()"] af57ae60_607e_c138_9ab0_fb8bb1c5916a["test_chat_models.py"] bacb6f37_ecd3_c556_0efc_70b91dcc90e9 -->|defined in| af57ae60_607e_c138_9ab0_fb8bb1c5916a style bacb6f37_ecd3_c556_0efc_70b91dcc90e9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/groq/tests/integration_tests/test_chat_models.py lines 497–531
async def test_astreaming_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.astream("Who was the 27 year old named Erick?")
additional_kwargs = None
async 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
Source
Frequently Asked Questions
What does test_astreaming_tool_call() do?
test_astreaming_tool_call() is a function in the langchain codebase, defined in libs/partners/groq/tests/integration_tests/test_chat_models.py.
Where is test_astreaming_tool_call() defined?
test_astreaming_tool_call() is defined in libs/partners/groq/tests/integration_tests/test_chat_models.py at line 497.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free