This commit is contained in:
Muja Kayadan 2025-04-24 00:57:03 -07:00 committed by GitHub
commit 20142380cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,10 +14,14 @@ class LLMClientCache(InMemoryCache):
If none, use the key as is.
"""
try:
event_loop = asyncio.get_event_loop()
try:
event_loop = asyncio.get_running_loop()
except RuntimeError:
event_loop = asyncio.new_event_loop()
stringified_event_loop = str(id(event_loop))
return f"{key}-{stringified_event_loop}"
except Exception: # handle no current event loop
except Exception: # handle other potential errors
return key
def set_cache(self, key, value, **kwargs):