Home / File/ test_groq.py — langchain Source File

test_groq.py — langchain Source File

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

File python CoreAbstractions MessageSchema 6 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61["test_groq.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> d758344f_537f_649e_f467_b9d7442e86df
  a1369c93_b21f_2edb_d15c_ec3e09ac1e42["langchain_core.messages.base"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> a1369c93_b21f_2edb_d15c_ec3e09ac1e42
  23170be8_e8a8_a728_6471_2a7fe6195245["langchain_core.messages.block_translators"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> 23170be8_e8a8_a728_6471_2a7fe6195245
  e69e205b_6bf7_c984_80ce_967c9568d8b5["langchain_core.messages.block_translators.groq"]
  6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 --> e69e205b_6bf7_c984_80ce_967c9568d8b5
  style 6231d74d_5c5b_9e4f_aea3_7ee8e5e85c61 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test groq block translator."""

from typing import cast

import pytest

from langchain_core.messages import AIMessage
from langchain_core.messages import content as types
from langchain_core.messages.base import _extract_reasoning_from_additional_kwargs
from langchain_core.messages.block_translators import PROVIDER_TRANSLATORS
from langchain_core.messages.block_translators.groq import (
    _parse_code_json,
    translate_content,
)


def test_groq_translator_registered() -> None:
    """Test that groq translator is properly registered."""
    assert "groq" in PROVIDER_TRANSLATORS
    assert "translate_content" in PROVIDER_TRANSLATORS["groq"]
    assert "translate_content_chunk" in PROVIDER_TRANSLATORS["groq"]


def test_extract_reasoning_from_additional_kwargs_exists() -> None:
    """Test that _extract_reasoning_from_additional_kwargs can be imported."""
    # Verify it's callable
    assert callable(_extract_reasoning_from_additional_kwargs)


def test_groq_translate_content_basic() -> None:
    """Test basic groq content translation."""
    # Test with simple text message
    message = AIMessage(content="Hello world")
    blocks = translate_content(message)

    assert isinstance(blocks, list)
    assert len(blocks) == 1
    assert blocks[0]["type"] == "text"
    assert blocks[0]["text"] == "Hello world"


def test_groq_translate_content_with_reasoning() -> None:
    """Test groq content translation with reasoning content."""
    # Test with reasoning content in additional_kwargs
    message = AIMessage(
        content="Final answer",
        additional_kwargs={"reasoning_content": "Let me think about this..."},
    )
    blocks = translate_content(message)

    assert isinstance(blocks, list)
    assert len(blocks) == 2

    # First block should be reasoning
    assert blocks[0]["type"] == "reasoning"
    assert blocks[0]["reasoning"] == "Let me think about this..."

    # Second block should be text
    assert blocks[1]["type"] == "text"
    assert blocks[1]["text"] == "Final answer"
// ... (81 more lines)

Subdomains

Dependencies

  • langchain_core.messages
  • langchain_core.messages.base
  • langchain_core.messages.block_translators
  • langchain_core.messages.block_translators.groq
  • pytest
  • typing

Frequently Asked Questions

What does test_groq.py do?
test_groq.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_groq.py?
test_groq.py defines 7 function(s): test_extract_reasoning_from_additional_kwargs_exists, test_groq_translate_content_basic, test_groq_translate_content_with_executed_tools, test_groq_translate_content_with_reasoning, test_groq_translate_content_with_tool_calls, test_groq_translator_registered, test_parse_code_json.
What does test_groq.py depend on?
test_groq.py imports 6 module(s): langchain_core.messages, langchain_core.messages.base, langchain_core.messages.block_translators, langchain_core.messages.block_translators.groq, pytest, typing.
Where is test_groq.py in the architecture?
test_groq.py is located at libs/core/tests/unit_tests/messages/block_translators/test_groq.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/messages/block_translators).

Analyze Your Own Codebase

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

Try Supermodel Free