test_astream_implementation_uses_astream() — langchain Function Reference
Architecture documentation for the test_astream_implementation_uses_astream() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 828c8e26_7a0b_9f00_1d69_a968ad3a1534["test_astream_implementation_uses_astream()"] 4404310a_b16c_e9e6_1de2_90e5ea6f3ce3["test_base.py"] 828c8e26_7a0b_9f00_1d69_a968ad3a1534 -->|defined in| 4404310a_b16c_e9e6_1de2_90e5ea6f3ce3 bbd70c92_2349_7e67_26af_2e8aabb3c962["_astream()"] 828c8e26_7a0b_9f00_1d69_a968ad3a1534 -->|calls| bbd70c92_2349_7e67_26af_2e8aabb3c962 6fde93f4_513d_1a3f_701f_1a4d762ee752["_generate()"] 828c8e26_7a0b_9f00_1d69_a968ad3a1534 -->|calls| 6fde93f4_513d_1a3f_701f_1a4d762ee752 5ddb6fca_46b7_b6c6_10aa_c263c14caa90["_llm_type()"] 828c8e26_7a0b_9f00_1d69_a968ad3a1534 -->|calls| 5ddb6fca_46b7_b6c6_10aa_c263c14caa90 style 828c8e26_7a0b_9f00_1d69_a968ad3a1534 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/language_models/llms/test_base.py lines 202–234
async def test_astream_implementation_uses_astream() -> None:
"""Test astream uses appropriate implementation."""
class ModelWithAsyncStream(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
async def _astream(
self,
prompt: str,
stop: list[str] | None = None,
run_manager: AsyncCallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> AsyncIterator[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 = ModelWithAsyncStream()
chunks = [chunk async for chunk in model.astream("anything")]
assert chunks == ["a", "b"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_astream_implementation_uses_astream() do?
test_astream_implementation_uses_astream() 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_uses_astream() defined?
test_astream_implementation_uses_astream() is defined in libs/core/tests/unit_tests/language_models/llms/test_base.py at line 202.
What does test_astream_implementation_uses_astream() call?
test_astream_implementation_uses_astream() calls 3 function(s): _astream, _generate, _llm_type.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free