Home / Function/ test_rate_limit_skips_cache_async() — langchain Function Reference

test_rate_limit_skips_cache_async() — langchain Function Reference

Architecture documentation for the test_rate_limit_skips_cache_async() function in test_rate_limiting.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2ca23980_3203_4791_911e_5ab3a8ad878e["test_rate_limit_skips_cache_async()"]
  df01695c_1dbe_973d_756a_a5cd86e49330["test_rate_limiting.py"]
  2ca23980_3203_4791_911e_5ab3a8ad878e -->|defined in| df01695c_1dbe_973d_756a_a5cd86e49330
  style 2ca23980_3203_4791_911e_5ab3a8ad878e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/language_models/chat_models/test_rate_limiting.py lines 244–270

async def test_rate_limit_skips_cache_async(output_version: str) -> None:
    """Test that rate limiting does not rate limit cache look ups."""
    cache = InMemoryCache()
    model = GenericFakeChatModel(
        messages=iter(["hello", "world", "!"]),
        rate_limiter=InMemoryRateLimiter(
            requests_per_second=20, check_every_n_seconds=0.1, max_bucket_size=1
        ),
        cache=cache,
        output_version=output_version,
    )

    tic = time.time()
    await model.ainvoke("foo")
    toc = time.time()
    # Should be larger than check every n seconds since the token bucket starts
    # with 0 tokens.
    assert 0.1 < toc - tic < 0.2

    for _ in range(2):
        # Cache hits
        tic = time.time()
        await model.ainvoke("foo")
        toc = time.time()
        # Should be larger than check every n seconds since the token bucket starts
        # with 0 tokens.
        assert toc - tic < 0.05

Subdomains

Frequently Asked Questions

What does test_rate_limit_skips_cache_async() do?
test_rate_limit_skips_cache_async() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/language_models/chat_models/test_rate_limiting.py.
Where is test_rate_limit_skips_cache_async() defined?
test_rate_limit_skips_cache_async() is defined in libs/core/tests/unit_tests/language_models/chat_models/test_rate_limiting.py at line 244.

Analyze Your Own Codebase

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

Try Supermodel Free