Home / Function/ test_create_usage_metadata_chat_completions_with_details() — langchain Function Reference

test_create_usage_metadata_chat_completions_with_details() — langchain Function Reference

Architecture documentation for the test_create_usage_metadata_chat_completions_with_details() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a20180bc_62e4_f282_cfe0_cf9d4b831f73["test_create_usage_metadata_chat_completions_with_details()"]
  5bf2e477_37e0_3e98_4042_bc609f2f7f60["test_chat_models.py"]
  a20180bc_62e4_f282_cfe0_cf9d4b831f73 -->|defined in| 5bf2e477_37e0_3e98_4042_bc609f2f7f60
  style a20180bc_62e4_f282_cfe0_cf9d4b831f73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/groq/tests/unit_tests/test_chat_models.py lines 335–352

def test_create_usage_metadata_chat_completions_with_details() -> None:
    """Test usage metadata with hypothetical Chat Completions API format."""
    token_usage = {
        "prompt_tokens": 100,
        "completion_tokens": 50,
        "total_tokens": 150,
        "prompt_tokens_details": {"cached_tokens": 80},
        "completion_tokens_details": {"reasoning_tokens": 25},
    }

    result = _create_usage_metadata(token_usage)

    assert isinstance(result, dict)
    assert result["input_tokens"] == 100
    assert result["output_tokens"] == 50
    assert result["total_tokens"] == 150
    assert result.get("input_token_details", {}).get("cache_read") == 80
    assert result.get("output_token_details", {}).get("reasoning") == 25

Domain

Subdomains

Frequently Asked Questions

What does test_create_usage_metadata_chat_completions_with_details() do?
test_create_usage_metadata_chat_completions_with_details() is a function in the langchain codebase, defined in libs/partners/groq/tests/unit_tests/test_chat_models.py.
Where is test_create_usage_metadata_chat_completions_with_details() defined?
test_create_usage_metadata_chat_completions_with_details() is defined in libs/partners/groq/tests/unit_tests/test_chat_models.py at line 335.

Analyze Your Own Codebase

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

Try Supermodel Free