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é275569135514
diff --git a/helpers/identity.py b/helpers/identity.py
index ecd3d58..80893f7 100644
--- a/helpers/identity.py
+++ b/helpers/identity.py
@@ -8,7 +8,7 @@ _client: DefaultAzureCredential | None = None
async def credential() -> DefaultAzureCredential:
- global _client
+ global _client # noqa: PLW0603
if not _client:
_client = DefaultAzureCredential(
# Performance
diff --git a/helpers/llm_tools.py b/helpers/llm_tools.py
index 3f8f238..65d316c 100644
--- a/helpers/llm_tools.py
+++ b/helpers/llm_tools.py
@@ -2,12 +2,11 @@ import asyncio
from collections.abc import Awaitable, Callable
from html import escape
from inspect import getmembers, isfunction
-from typing import Annotated, Literal
+from typing import Annotated, Literal, TypedDict
from azure.communication.callautomation.aio import CallAutomationClient
from openai.types.chat import ChatCompletionToolParam
from pydantic import ValidationError
-from typing_extensions import TypedDict
from helpers.call_utils import ContextEnum as CallContextEnum, handle_play_text
from helpers.config import CONFIG
diff --git a/main.py b/main.py
index b7434a5..9778233 100644
--- a/main.py
+++ b/main.py
@@ -105,7 +105,7 @@ logger.info("Using call event URL %s", _COMMUNICATIONSERVICES_CALLABACK_TPL)
@asynccontextmanager
-async def lifespan(app: FastAPI):
+async def lifespan(app: FastAPI): # noqa: ARG001
call_task = asyncio.create_task(
_call_queue.trigger(
arg="call",
@@ -843,7 +843,7 @@ async def twilio_sms_post(
@api.exception_handler(StarletteHTTPException)
-async def http_exception_handler(request: Request, exc: StarletteHTTPException):
+async def http_exception_handler(request: Request, exc: StarletteHTTPException): # noqa: ARG001
"""
Handle HTTP exceptions and return the error in a standard format.
"""
@@ -854,7 +854,7 @@ async def http_exception_handler(request: Request, exc: StarletteHTTPException):
@api.exception_handler(RequestValidationError)
-async def validation_exception_handler(request: Request, exc: RequestValidationError):
+async def validation_exception_handler(request: Request, exc: RequestValidationError): # noqa: ARG001
"""
Handle validation exceptions and return the error in a standard format.
"""
diff --git a/tests/cache.py b/tests/cache.py
index 86c86dd..31f5813 100644
--- a/tests/cache.py
+++ b/tests/cache.py
@@ -1,5 +1,5 @@
import pytest
-from pytest import assume
+from pytest_assume.plugin import assume
from helpers.config import CONFIG
from helpers.config_models.cache import ModeEnum as CacheModeEnum
diff --git a/tests/llm.py b/tests/llm.py
index c9aca40..287e56e 100644
--- a/tests/llm.py
+++ b/tests/llm.py
@@ -15,7 +15,7 @@ from deepeval.metrics import (
from deepeval.models.gpt_model import GPTModel
from deepeval.test_case import LLMTestCase
from pydantic import TypeAdapter
-from pytest import assume
+from pytest_assume.plugin import assume
from helpers.call_events import (
on_call_connected,
@@ -274,6 +274,9 @@ async def test_llm( # noqa: PLR0913
await on_call_connected(
call=call,
client=automation_client,
+ post_callback=_post_callback,
+ server_call_id="dummy",
+ training_callback=_training_callback,
)
# First IVR
diff --git a/tests/local.py b/tests/local.py
index 098885b..803de29 100644
--- a/tests/local.py
+++ b/tests/local.py
@@ -56,6 +56,9 @@ async def main() -> None:
await on_call_connected(
call=call,
client=automation_client,
+ post_callback=_post_callback,
+ server_call_id="dummy",
+ training_callback=_training_callback,
)
# First IVR
diff --git a/tests/search.py b/tests/search.py
index 9d01836..86a253c 100644
--- a/tests/search.py
+++ b/tests/search.py
@@ -7,7 +7,7 @@ from deepeval.metrics import BaseMetric
from deepeval.models.gpt_model import GPTModel
from deepeval.test_case import LLMTestCase
from pydantic import TypeAdapter
-from pytest import assume
+from pytest_assume.plugin import assume
from helpers.config import CONFIG
from helpers.logging import logger
diff --git a/tests/store.py b/tests/store.py
index dd17113..7ad5f85 100644
--- a/tests/store.py
+++ b/tests/store.py
@@ -1,5 +1,5 @@
import pytest
-from pytest import assume
+from pytest_assume.plugin import assume
from helpers.config import CONFIG
from helpers.config_models.database import ModeEnum as DatabaseModeEnum