test_chat_models.py — langchain Source File
Architecture documentation for test_chat_models.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ec975712_a998_0a1f_0930_22940fc39a1e["test_chat_models.py"] 9d14ea65_8b2e_6721_a947_acc89905651f["json"] ec975712_a998_0a1f_0930_22940fc39a1e --> 9d14ea65_8b2e_6721_a947_acc89905651f feec1ec4_6917_867b_d228_b134d0ff8099["typing"] ec975712_a998_0a1f_0930_22940fc39a1e --> feec1ec4_6917_867b_d228_b134d0ff8099 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] ec975712_a998_0a1f_0930_22940fc39a1e --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 9444498b_8066_55c7_b3a2_1d90c4162a32["langchain_core.messages"] ec975712_a998_0a1f_0930_22940fc39a1e --> 9444498b_8066_55c7_b3a2_1d90c4162a32 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] ec975712_a998_0a1f_0930_22940fc39a1e --> dd5e7909_a646_84f1_497b_cae69735550e f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] ec975712_a998_0a1f_0930_22940fc39a1e --> f85fae70_1011_eaec_151c_4083140ae9e5 8fb0b028_3090_f6d0_439f_e1b8a0c592ed["langchain_fireworks"] ec975712_a998_0a1f_0930_22940fc39a1e --> 8fb0b028_3090_f6d0_439f_e1b8a0c592ed style ec975712_a998_0a1f_0930_22940fc39a1e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test ChatFireworks API wrapper.
You will need FIREWORKS_API_KEY set in your environment to run these tests.
"""
from __future__ import annotations
import json
from typing import Annotated, Any, Literal
import pytest
from langchain_core.messages import AIMessage, AIMessageChunk, BaseMessageChunk
from pydantic import BaseModel, Field
from typing_extensions import TypedDict
from langchain_fireworks import ChatFireworks
_MODEL = "accounts/fireworks/models/gpt-oss-120b"
@pytest.mark.parametrize("strict", [None, True, False])
def test_tool_choice_bool(strict: bool | None) -> None: # noqa: FBT001
"""Test that tool choice is respected with different strict values."""
llm = ChatFireworks(model="accounts/fireworks/models/kimi-k2-instruct-0905")
class MyTool(BaseModel):
name: str
age: int
kwargs = {"tool_choice": True}
if strict is not None:
kwargs["strict"] = strict
with_tool = llm.bind_tools([MyTool], **kwargs)
# Verify that strict is correctly set in the tool definition
assert hasattr(with_tool, "kwargs")
tools = with_tool.kwargs.get("tools", [])
assert len(tools) == 1
tool_def = tools[0]
assert "function" in tool_def
if strict is None:
assert "strict" not in tool_def["function"]
else:
assert tool_def["function"].get("strict") is strict
resp = with_tool.invoke("Who was the 27 year old named Erick?")
assert isinstance(resp, AIMessage)
assert resp.content == "" # should just be tool call
tool_calls = resp.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"
async def test_astream() -> None:
// ... (114 more lines)
Domain
Subdomains
Functions
Dependencies
- json
- langchain_core.messages
- langchain_fireworks
- pydantic
- pytest
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_chat_models.py do?
test_chat_models.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, LanguageModelBase subdomain.
What functions are defined in test_chat_models.py?
test_chat_models.py defines 7 function(s): _get_joke_class, test_abatch_tags, test_ainvoke, test_astream, test_invoke, test_structured_output_json_schema, test_tool_choice_bool.
What does test_chat_models.py depend on?
test_chat_models.py imports 7 module(s): json, langchain_core.messages, langchain_fireworks, pydantic, pytest, typing, typing_extensions.
Where is test_chat_models.py in the architecture?
test_chat_models.py is located at libs/partners/fireworks/tests/integration_tests/test_chat_models.py (domain: LangChainCore, subdomain: LanguageModelBase, directory: libs/partners/fireworks/tests/integration_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free