MCPcopy
hub / github.com/langroid/langroid / get_groq_client

Function get_groq_client

langroid/language_models/client_cache.py:236–255  ·  view source on GitHub ↗

Get or create a singleton Groq client with the given configuration. Args: api_key: Groq API key Returns: Groq client instance

(api_key: str)

Source from the content-addressed store, hash-verified

234
235
236def get_groq_client(api_key: str) -> Groq:
237 """
238 Get or create a singleton Groq client with the given configuration.
239
240 Args:
241 api_key: Groq API key
242
243 Returns:
244 Groq client instance
245 """
246 cache_key = _get_cache_key("groq", api_key=api_key)
247
248 with _client_cache_lock:
249 cached_client = _get_cached_client(cache_key)
250 if cached_client is not None:
251 return cast(Groq, cached_client)
252
253 client = Groq(api_key=api_key)
254 _store_client(cache_key, client)
255 return client
256
257
258def get_async_groq_client(api_key: str) -> AsyncGroq:

Callers 3

__init__Method · 0.90

Calls 3

_get_cache_keyFunction · 0.85
_get_cached_clientFunction · 0.85
_store_clientFunction · 0.85

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…