Home / File/ test_chat_models.py — langchain Source File

test_chat_models.py — langchain Source File

Architecture documentation for test_chat_models.py, a python file in the langchain codebase. 2 imports, 0 dependents.

File python LangChainCore LanguageModelBase 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  f28fd121_9d98_6d1d_bc45_cccbf6b9fad5["test_chat_models.py"]
  9444498b_8066_55c7_b3a2_1d90c4162a32["langchain_core.messages"]
  f28fd121_9d98_6d1d_bc45_cccbf6b9fad5 --> 9444498b_8066_55c7_b3a2_1d90c4162a32
  2f967164_2cd3_eb77_a27e_07b76a631243["langchain_fireworks.chat_models"]
  f28fd121_9d98_6d1d_bc45_cccbf6b9fad5 --> 2f967164_2cd3_eb77_a27e_07b76a631243
  style f28fd121_9d98_6d1d_bc45_cccbf6b9fad5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Unit tests for ChatFireworks."""

from __future__ import annotations

from langchain_core.messages import AIMessage

from langchain_fireworks.chat_models import _convert_dict_to_message


def test_convert_dict_to_message_with_reasoning_content() -> None:
    """Test that reasoning_content is correctly extracted from API response."""
    response_dict = {
        "role": "assistant",
        "content": "The answer is 42.",
        "reasoning_content": "Let me think about this step by step...",
    }

    message = _convert_dict_to_message(response_dict)

    assert isinstance(message, AIMessage)
    assert message.content == "The answer is 42."
    assert "reasoning_content" in message.additional_kwargs
    expected_reasoning = "Let me think about this step by step..."
    assert message.additional_kwargs["reasoning_content"] == expected_reasoning


def test_convert_dict_to_message_without_reasoning_content() -> None:
    """Test that messages without reasoning_content work correctly."""
    response_dict = {
        "role": "assistant",
        "content": "The answer is 42.",
    }

    message = _convert_dict_to_message(response_dict)

    assert isinstance(message, AIMessage)
    assert message.content == "The answer is 42."
    assert "reasoning_content" not in message.additional_kwargs

Domain

Subdomains

Dependencies

  • langchain_core.messages
  • langchain_fireworks.chat_models

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 2 function(s): test_convert_dict_to_message_with_reasoning_content, test_convert_dict_to_message_without_reasoning_content.
What does test_chat_models.py depend on?
test_chat_models.py imports 2 module(s): langchain_core.messages, langchain_fireworks.chat_models.
Where is test_chat_models.py in the architecture?
test_chat_models.py is located at libs/partners/fireworks/tests/unit_tests/test_chat_models.py (domain: LangChainCore, subdomain: LanguageModelBase, directory: libs/partners/fireworks/tests/unit_tests).

Analyze Your Own Codebase

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

Try Supermodel Free