Home / Function/ test_perplexity_stream_includes_videos_and_reasoning() — langchain Function Reference

test_perplexity_stream_includes_videos_and_reasoning() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f95afc50_cf32_467a_c484_c6297079b730["test_perplexity_stream_includes_videos_and_reasoning()"]
  c1722844_1503_63a7_de81_d01bf41ba40d["test_chat_models.py"]
  f95afc50_cf32_467a_c484_c6297079b730 -->|defined in| c1722844_1503_63a7_de81_d01bf41ba40d
  style f95afc50_cf32_467a_c484_c6297079b730 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/perplexity/tests/unit_tests/test_chat_models.py lines 117–144

def test_perplexity_stream_includes_videos_and_reasoning(mocker: MockerFixture) -> None:
    """Test that stream extracts videos and reasoning_steps."""
    llm = ChatPerplexity(model="test", timeout=30, verbose=True)

    mock_chunk_0 = {
        "choices": [{"delta": {"content": "Thinking... "}, "finish_reason": None}],
        "videos": [{"url": "http://video.com", "thumbnail_url": "http://thumb.com"}],
        "reasoning_steps": [{"thought": "I should search", "type": "web_search"}],
    }
    mock_chunk_1 = {
        "choices": [{"delta": {}, "finish_reason": "stop"}],
    }

    mock_chunks: list[dict[str, Any]] = [mock_chunk_0, mock_chunk_1]
    mock_stream = MagicMock()
    mock_stream.__iter__.return_value = mock_chunks
    mocker.patch.object(llm.client.chat.completions, "create", return_value=mock_stream)

    stream = list(llm.stream("test"))
    first_chunk = stream[0]

    assert "videos" in first_chunk.additional_kwargs
    assert first_chunk.additional_kwargs["videos"][0]["url"] == "http://video.com"
    assert "reasoning_steps" in first_chunk.additional_kwargs
    assert (
        first_chunk.additional_kwargs["reasoning_steps"][0]["thought"]
        == "I should search"
    )

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free