test_image_tool_calling() — langchain Function Reference
Architecture documentation for the test_image_tool_calling() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 58e8797b_ef8c_878c_3aa7_227f18f1d802["test_image_tool_calling()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] 58e8797b_ef8c_878c_3aa7_227f18f1d802 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style 58e8797b_ef8c_878c_3aa7_227f18f1d802 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1218–1276
def test_image_tool_calling() -> None:
"""Test tool calling with image inputs."""
class color_picker(BaseModel): # noqa: N801
"""Input your fav color and get a random fact about it."""
fav_color: str
human_content: list[dict] = [
{
"type": "text",
"text": "what's your favorite color in this image",
},
]
image_url = "https://raw.githubusercontent.com/langchain-ai/docs/4d11d08b6b0e210bd456943f7a22febbd168b543/src/images/agentic-rag-output.png"
image_data = b64encode(httpx.get(image_url).content).decode("utf-8")
human_content.append(
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": image_data,
},
},
)
messages = [
SystemMessage("you're a good assistant"),
HumanMessage(human_content), # type: ignore[arg-type]
AIMessage(
[
{"type": "text", "text": "Hmm let me think about that"},
{
"type": "tool_use",
"input": {"fav_color": "purple"},
"id": "foo",
"name": "color_picker",
},
],
),
HumanMessage(
[
{
"type": "tool_result",
"tool_use_id": "foo",
"content": [
{
"type": "text",
"text": "purple is a great pick! that's my sister's favorite color", # noqa: E501
},
],
"is_error": False,
},
{"type": "text", "text": "what's my sister's favorite color"},
],
),
]
llm = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
_ = llm.bind_tools([color_picker]).invoke(messages)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_image_tool_calling() do?
test_image_tool_calling() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_image_tool_calling() defined?
test_image_tool_calling() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 1218.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free