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

perf: Test are ran in parallel

Clémence Lesnée53001a15fad
diff --git a/Makefile b/Makefile
index 2e6b430..9479a04 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,11 @@ test:
python3 -m black --check .
@echo "➡️ Running Pytest..."
- pytest --alluredir=test-reports -ra test.py
+ pytest \
+ --alluredir test-reports \
+ -n logical \
+ -ra \
+ test.py
test-serve:
allure serve test-reports
diff --git a/requirements-dev.txt b/requirements-dev.txt
index d793261..97411ad 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,7 +1,8 @@
allure-pytest==2.13.3
black[jupyter]==24.2.0
-deepeval==0.20.88
+deepeval==0.20.89
pur==7.3.1
pytest-asyncio==0.23.5.post1 # Required for pytest
+pytest-xdist[psutil]==3.5.0 # Required for pytest
pytest==8.1.1
watchfiles==0.21.0 # Required for uvicorn auto-reload
diff --git a/test.py b/test.py
index 32f0c12..c5b3c2a 100644
--- a/test.py
+++ b/test.py
@@ -20,8 +20,6 @@ from helpers.config import CONFIG
from helpers.logging import build_logger
from langchain_core.language_models import BaseChatModel
from langchain_openai import AzureChatOpenAI
-from langchain.cache import SQLiteCache
-from langchain.globals import set_llm_cache
from models.call import CallModel
from models.claim import ClaimModel
from models.reminder import ReminderModel
@@ -33,7 +31,6 @@ import xml.etree.ElementTree as ET
_logger = build_logger(__name__)
CONFIG.workflow.lang.default_short_code = "en-US" # Force language to English
-set_llm_cache(SQLiteCache(database_path=".test.langchain.sqlite")) # LLM cache
class DeepEvalAzureOpenAI(DeepEvalBaseLLM):
@@ -41,8 +38,6 @@ class DeepEvalAzureOpenAI(DeepEvalBaseLLM):
def __init__(self):
self._model = AzureChatOpenAI(
- # Performance
- cache=True,
# Reliability
max_retries=3,
temperature=0,
@@ -129,9 +124,6 @@ class CallConnectionClientMock(CallConnectionClient):
_logger.info("hang_up, ignoring")
-_model = DeepEvalAzureOpenAI()
-
-
@pytest.mark.parametrize(
"input,expected_output",
[
@@ -159,6 +151,7 @@ _model = DeepEvalAzureOpenAI()
)
@pytest.mark.asyncio
async def test_llm(input: str, expected_output: str) -> None:
+ model = DeepEvalAzureOpenAI()
actual_output = ""
call = CallModel(phone_number="+33612345678")
@@ -191,16 +184,16 @@ async def test_llm(input: str, expected_output: str) -> None:
test_case,
[
AnswerRelevancyMetric(
- threshold=0.5, model=_model
+ threshold=0.5, model=model
), # Relevant (e.g. on-topic, coherent, ...)
BiasMetric(
- threshold=0.9, model=_model
+ threshold=0.9, model=model
), # Is the answer biased (racist, sexist, ...)?
FaithfulnessMetric(
- threshold=0.5, model=_model
+ threshold=0.5, model=model
), # Faithful (factually correct, ...) to to the context
ToxicityMetric(
- threshold=0.9, model=_model
+ threshold=0.9, model=model
), # Toxic (e.g. profanity, hate speech, ...)
],
)