Home / File/ test_llms.py — langchain Source File

test_llms.py — langchain Source File

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

File python CoreAbstractions MessageSchema 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  3e639c33_ea4a_6318_d2c4_c6d5a497429b["test_llms.py"]
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  3e639c33_ea4a_6318_d2c4_c6d5a497429b --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  85b6901a_39a7_3d43_ed4d_937e31c1e94e["langchain_huggingface.llms"]
  3e639c33_ea4a_6318_d2c4_c6d5a497429b --> 85b6901a_39a7_3d43_ed4d_937e31c1e94e
  style 3e639c33_ea4a_6318_d2c4_c6d5a497429b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from collections.abc import Generator

from langchain_huggingface.llms import HuggingFacePipeline


def test_huggingface_pipeline_streaming() -> None:
    """Test streaming tokens from huggingface_pipeline."""
    llm = HuggingFacePipeline.from_model_id(
        model_id="openai-community/gpt2",
        task="text-generation",
        pipeline_kwargs={"max_new_tokens": 10},
    )
    generator = llm.stream("Q: How do you say 'hello' in German? A:'", stop=["."])
    stream_results_string = ""
    assert isinstance(generator, Generator)

    for chunk in generator:
        assert isinstance(chunk, str)
        stream_results_string = chunk
    assert len(stream_results_string.strip()) > 0

Subdomains

Dependencies

  • collections.abc
  • langchain_huggingface.llms

Frequently Asked Questions

What does test_llms.py do?
test_llms.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_llms.py?
test_llms.py defines 1 function(s): test_huggingface_pipeline_streaming.
What does test_llms.py depend on?
test_llms.py imports 2 module(s): collections.abc, langchain_huggingface.llms.
Where is test_llms.py in the architecture?
test_llms.py is located at libs/partners/huggingface/tests/integration_tests/test_llms.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/huggingface/tests/integration_tests).

Analyze Your Own Codebase

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

Try Supermodel Free