test_astream_implementation_fallback_to_stream() — langchain Function Reference
Architecture documentation for the test_astream_implementation_fallback_to_stream() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 55285081_e5e6_6fd1_0b9a_239b90e2ed4d["test_astream_implementation_fallback_to_stream()"] 0cad5588_a6f2_d365_b61b_841ca3437132["test_base.py"] 55285081_e5e6_6fd1_0b9a_239b90e2ed4d -->|defined in| 0cad5588_a6f2_d365_b61b_841ca3437132 cd389776_a867_c3a4_8656_f85ca1708f1c["_stream()"] 55285081_e5e6_6fd1_0b9a_239b90e2ed4d -->|calls| cd389776_a867_c3a4_8656_f85ca1708f1c 3c96260d_040e_902b_2b08_6bf3e26432d4["_generate()"] 55285081_e5e6_6fd1_0b9a_239b90e2ed4d -->|calls| 3c96260d_040e_902b_2b08_6bf3e26432d4 b19deba4_e834_4fe0_3b1e_d1687a455bd1["_llm_type()"] 55285081_e5e6_6fd1_0b9a_239b90e2ed4d -->|calls| b19deba4_e834_4fe0_3b1e_d1687a455bd1 style 55285081_e5e6_6fd1_0b9a_239b90e2ed4d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/language_models/llms/test_base.py lines 164–199
async def test_astream_implementation_fallback_to_stream() -> None:
"""Test astream uses appropriate implementation."""
class ModelWithSyncStream(BaseLLM):
def _generate(
self,
prompts: list[str],
stop: list[str] | None = None,
run_manager: CallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> LLMResult:
"""Top Level call."""
raise NotImplementedError
@override
def _stream(
self,
prompt: str,
stop: list[str] | None = None,
run_manager: CallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> Iterator[GenerationChunk]:
"""Stream the output of the model."""
yield GenerationChunk(text="a")
yield GenerationChunk(text="b")
@property
def _llm_type(self) -> str:
return "fake-chat-model"
model = ModelWithSyncStream()
chunks = list(model.stream("anything"))
assert chunks == ["a", "b"]
assert type(model)._astream == BaseLLM._astream
astream_chunks = [chunk async for chunk in model.astream("anything")]
assert astream_chunks == ["a", "b"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_astream_implementation_fallback_to_stream() do?
test_astream_implementation_fallback_to_stream() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/llms/test_base.py.
Where is test_astream_implementation_fallback_to_stream() defined?
test_astream_implementation_fallback_to_stream() is defined in libs/core/tests/unit_tests/language_models/llms/test_base.py at line 164.
What does test_astream_implementation_fallback_to_stream() call?
test_astream_implementation_fallback_to_stream() calls 3 function(s): _generate, _llm_type, _stream.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free