MCPcopy
hub / github.com/langroid/langroid / _get_cached_client

Function _get_cached_client

langroid/language_models/client_cache.py:51–62  ·  view source on GitHub ↗

Get cached client and refresh its last-used timestamp. Must be called while holding ``_client_cache_lock``.

(cache_key: str)

Source from the content-addressed store, hash-verified

49
50
51def _get_cached_client(cache_key: str) -> Optional[Any]:
52 """Get cached client and refresh its last-used timestamp.
53
54 Must be called while holding ``_client_cache_lock``.
55 """
56 entry = _client_cache.get(cache_key)
57 if entry is None:
58 return None
59
60 client, _ = entry
61 _client_cache[cache_key] = (client, time.monotonic())
62 return client
63
64
65def _store_client(cache_key: str, client: Any) -> None:

Callers 6

get_openai_clientFunction · 0.85
get_async_openai_clientFunction · 0.85
get_groq_clientFunction · 0.85
get_async_groq_clientFunction · 0.85
get_cerebras_clientFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…