Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

quality: Code quality

Clémence Lesnée8d164931a3e
diff --git a/persistence/memory.py b/persistence/memory.py
index 19d32c4..2e3ba72 100644
--- a/persistence/memory.py
+++ b/persistence/memory.py
@@ -49,7 +49,8 @@ class MemoryCache(ICache):
res = self._cache.get(sha_key, None)
if not res:
return None
- self._cache.move_to_end(sha_key, last=False) # Move to first
+ # Move to first
+ self._cache.move_to_end(sha_key, last=False)
return res
async def aset(self, key: str, value: str | bytes | None, ttl_sec: int) -> bool:
@@ -57,8 +58,9 @@ class MemoryCache(ICache):
Set a value in the cache.
"""
sha_key = self._key_to_hash(key)
+ # Delete the last if full
if len(self._cache) >= self._config.max_size:
- self._cache.popitem() # Delete the last
+ self._cache.popitem()
# Add to first
self._cache[sha_key] = value.encode() if isinstance(value, str) else value
self._cache.move_to_end(sha_key, last=False)
diff --git a/tests/conftest.py b/tests/conftest.py
index b26093d..1d1b6bd 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -165,6 +165,7 @@ class DeepEvalAzureOpenAI(GPTModel):
res = super().generate(prompt)
# Update cache
self._cache.set(cache_key, res)
+ # Return
return res
async def a_generate(self, prompt: str) -> tuple[str, float]:
@@ -178,6 +179,7 @@ class DeepEvalAzureOpenAI(GPTModel):
res = await super().a_generate(prompt)
# Update cache
self._cache.set(cache_key, res)
+ # Return
return res
def get_model_name(self) -> str: