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

chore: Code refacto

Clémence Lesné80e7b4c11217
diff --git a/helpers/translation.py b/helpers/translation.py
index 788cd27..e6d9b36 100644
--- a/helpers/translation.py
+++ b/helpers/translation.py
@@ -16,6 +16,7 @@ from tenacity import (
_logger = build_logger(__name__)
_logger.info(f"Using Translation {CONFIG.ai_translation.endpoint}")
+
_cache = CONFIG.cache.instance()
@@ -37,7 +38,7 @@ async def translate_text(
return text
# Try cache
- cache_key = f"{__name__}:translate_text:{text}:{source_lang}:{target_lang}"
+ cache_key = f"{__name__}-translate_text-{text}-{source_lang}-{target_lang}"
cached = await _cache.aget(cache_key)
if cached:
return cached.decode()
diff --git a/persistence/ai_search.py b/persistence/ai_search.py
index 8e315cc..142137c 100644
--- a/persistence/ai_search.py
+++ b/persistence/ai_search.py
@@ -52,7 +52,7 @@ class AiSearchSearch(ISearch):
return None
# Try cache
- cache_key = f"{self.__class__.__name__}:training_asearch_all:{text}"
+ cache_key = f"{self.__class__.__name__}-training_asearch_all-{text}"
cached = await self._cache.aget(cache_key)
if cached:
try:
diff --git a/tests/conftest.py b/tests/conftest.py
index 2980513..a692cc7 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -126,7 +126,7 @@ class DeepEvalAzureOpenAI(DeepEvalBaseLLM):
def _cache_key(self, prompt: str) -> str:
langchain_hash = self._model._get_llm_string(**self._langchain_kwargs)
suffix = hashlib.sha256(
- f"{langchain_hash}:{prompt}".encode(),
+ f"{langchain_hash}-{prompt}".encode(),
usedforsecurity=False,
).digest() # Arguments contain secrets, so hash them
return f"claim-ai/{suffix}"