Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
quality: Code lint
Clémence Lesné58d091bde2a6
diff --git a/app/helpers/cache.py b/app/helpers/cache.pyindex 1bace6b..bf17492 100644--- a/app/helpers/cache.py+++ b/app/helpers/cache.py@@ -8,7 +8,7 @@ from aiojobs import Scheduler@asynccontextmanager-async def get_scheduler() -> AsyncGenerator[Scheduler, None]:+async def get_scheduler() -> AsyncGenerator[Scheduler]:"""Get the scheduler for async background tasks.diff --git a/app/helpers/call_utils.py b/app/helpers/call_utils.pyindex 77a8fac..c2b568d 100644--- a/app/helpers/call_utils.py+++ b/app/helpers/call_utils.py@@ -115,7 +115,7 @@ class ContextEnum(str, Enum):def tts_sentence_split(text: str, include_last: bool-) -> Generator[tuple[str, int], None, None]:+) -> Generator[tuple[str, int]]:"""Split a text into sentences.@@ -509,7 +509,7 @@ def _context_serializer(contexts: set[ContextEnum | None] | None) -> str | None:@contextmanager-def _detect_hangup() -> Generator[None, None, None]:+def _detect_hangup() -> Generator[None]:"""Catch a call hangup and raise a `CallHangupException` instead of the Call Automation SDK exceptions."""@@ -542,7 +542,7 @@ async def _use_call_client(async def use_tts_client(call: CallStateModel,out: asyncio.Queue[bytes],-) -> AsyncGenerator[SpeechSynthesizer, None]:+) -> AsyncGenerator[SpeechSynthesizer]:"""Use a text-to-speech client for a call.diff --git a/app/helpers/llm_worker.py b/app/helpers/llm_worker.pyindex 3d7e947..86a8a57 100644--- a/app/helpers/llm_worker.py+++ b/app/helpers/llm_worker.py@@ -68,7 +68,7 @@ async def completion_stream(messages: list[MessageModel],system: list[SystemMessage],tools: list[ChatCompletionsToolDefinition] = [],-) -> AsyncGenerator[StreamingChatResponseMessageUpdate, None]:+) -> AsyncGenerator[StreamingChatResponseMessageUpdate]:"""Returns a stream of completions.@@ -124,7 +124,7 @@ async def _completion_stream_worker(messages: list[MessageModel],system: list[SystemMessage],tools: list[ChatCompletionsToolDefinition] = [],-) -> AsyncGenerator[StreamingChatResponseMessageUpdate, None]:+) -> AsyncGenerator[StreamingChatResponseMessageUpdate]:"""Returns a stream of completions."""diff --git a/app/persistence/azure_queue_storage.py b/app/persistence/azure_queue_storage.pyindex acac18e..98e8261 100644--- a/app/persistence/azure_queue_storage.py+++ b/app/persistence/azure_queue_storage.py@@ -63,7 +63,7 @@ class AzureQueueStorage:self,max_messages: int,visibility_timeout: int,- ) -> AsyncGenerator[Message, None]:+ ) -> AsyncGenerator[Message]:async with self._use_client() as client:messages = client.receive_messages(max_messages=max_messages,@@ -175,7 +175,7 @@ class AzureQueueStorage:)@asynccontextmanager- async def _use_client(self) -> AsyncGenerator[QueueClient, None]:+ async def _use_client(self) -> AsyncGenerator[QueueClient]:"""Generate a queue client."""diff --git a/app/persistence/cosmos_db.py b/app/persistence/cosmos_db.pyindex 191854a..9c637dd 100644--- a/app/persistence/cosmos_db.py+++ b/app/persistence/cosmos_db.py@@ -130,7 +130,7 @@ class CosmosDbStore(IStore):self,call: CallStateModel,scheduler: Scheduler,- ) -> AsyncGenerator[None, None]:+ ) -> AsyncGenerator[None]:# Copy and yield the updated objectinit_data = call.model_dump(mode="json", exclude_none=True)yield@@ -397,7 +397,7 @@ class CosmosDbStore(IStore):)@asynccontextmanager- async def _use_client(self) -> AsyncGenerator[ContainerProxy, None]:+ async def _use_client(self) -> AsyncGenerator[ContainerProxy]:"""Generate the container client."""diff --git a/app/persistence/redis.py b/app/persistence/redis.pyindex ef35997..070f1ae 100644--- a/app/persistence/redis.py+++ b/app/persistence/redis.py@@ -144,7 +144,7 @@ class RedisCache(ICache):)@asynccontextmanager- async def _use_client(self) -> AsyncGenerator[Redis, None]:+ async def _use_client(self) -> AsyncGenerator[Redis]:"""Return a Redis connection."""diff --git a/pyproject.toml b/pyproject.tomlindex e296670..8ee7e1e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,71 +1,69 @@[project]description = "AI-powered call center solution with Azure and OpenAI GPT."dynamic = ["version"]-license = {file = "LICENSE"}+license = { file = "LICENSE" }name = "call-center-ai"readme = "README.md"requires-python = ">=3.13"dependencies = [- "aiohttp-retry~=2.9", # Retry middleware for aiohttp, used with Twilio SDK- "aiohttp[speedups]~=3.10", # Async HTTP client for Azure and Twilio SDKs, plus async DNS resolver and async Brotli compression- "aiojobs~=1.3", # Async job scheduler- "azure-ai-inference[opentelemetry]~=1.0.0a0", # Azure AI Foundry LLM inference- "azure-ai-translation-text~=1.0", # Azure Cognitive Services Text Translation- "azure-appconfiguration~=1.7", # Outsourced configuration for live updates- "azure-cognitiveservices-speech~=1.41", # Azure AI Speech- "azure-communication-callautomation~=1.4.0a0", # Azure Communication Services Call Automation- "azure-communication-sms~=1.1", # Azure Communication Services SMS- "azure-cosmos~=4.7", # Azure Cosmos DB- "azure-eventgrid~=4.20", # Azure Event Grid- "azure-identity~=1.19", # Azure identity library- "azure-monitor-opentelemetry~=1.6", # Azure Monitor OpenTelemetry- "azure-search-documents~=11.6.0a0", # Azure AI Search- "azure-storage-queue~=12.12", # Azure Storage Queue- "django-htmlmin~=0.11", # Minify HTML- "fastapi~=0.115", # Web framework- "gunicorn~=23.0", # Application server- "jinja2~=3.1", # Template engine, used for prompts and web views- "json-repair~=0.30", # Repair JSON files from LLM- "mistune~=3.0", # Markdown parser for web views- "noisereduce~=3.0", # Noise reduction- "opentelemetry-instrumentation-aiohttp-client~=0.0a0", # OpenTelemetry instrumentation for aiohttp client- "opentelemetry-instrumentation-redis~=0.0a0", # OpenTelemetry instrumentation for Redis- "opentelemetry-semantic-conventions~=0.0a0", # OpenTelemetry conventions, to standardize telemetry data- "phonenumbers~=8.13", # Phone number parsing and formatting, used with Pydantic- "pydantic-extra-types~=2.9", # Extra types for Pydantic- "pydantic-settings~=2.6", # Application configuration management with Pydantic- "pydantic[email]~=2.9", # Data serialization and validation, plus email validation- "pyjwt~=2.9", # Secure inbound calls from Communication Services- "python-dotenv~=1.0", # Load environment variables from .env file- "python-multipart==0.*", # Form parsing- "pytz~=2024.0", # Time zone handling- "pyyaml~=6.0", # YAML parser- "redis~=5.2", # Redis client- "structlog~=24.4", # Pretty logging- "tenacity~=8.2", # Async retrying library- "tiktoken~=0.8", # Tokenization library for OpenAI models- "twilio~=9.3", # Twilio SDK, used for SMS- "typing-extensions~=4.12", # Typing extensions for Python 3.6+- "uvicorn[standard]~=0.32", # Application middleware+ "aiohttp-retry~=2.9", # Retry middleware for aiohttp, used with Twilio SDK+ "aiohttp[speedups]~=3.10", # Async HTTP client for Azure and Twilio SDKs, plus async DNS resolver and async Brotli compression+ "aiojobs~=1.3", # Async job scheduler+ "azure-ai-inference[opentelemetry]~=1.0.0a0", # Azure AI Foundry LLM inference+ "azure-ai-translation-text~=1.0", # Azure Cognitive Services Text Translation+ "azure-appconfiguration~=1.7", # Outsourced configuration for live updates+ "azure-cognitiveservices-speech~=1.41", # Azure AI Speech+ "azure-communication-callautomation~=1.4.0a0", # Azure Communication Services Call Automation+ "azure-communication-sms~=1.1", # Azure Communication Services SMS+ "azure-cosmos~=4.7", # Azure Cosmos DB+ "azure-eventgrid~=4.20", # Azure Event Grid+ "azure-identity~=1.19", # Azure identity library+ "azure-monitor-opentelemetry~=1.6", # Azure Monitor OpenTelemetry+ "azure-search-documents~=11.6.0a0", # Azure AI Search+ "azure-storage-queue~=12.12", # Azure Storage Queue+ "django-htmlmin~=0.11", # Minify HTML+ "fastapi~=0.115", # Web framework+ "gunicorn~=23.0", # Application server+ "jinja2~=3.1", # Template engine, used for prompts and web views+ "json-repair~=0.30", # Repair JSON files from LLM+ "mistune~=3.0", # Markdown parser for web views+ "noisereduce~=3.0", # Noise reduction+ "opentelemetry-instrumentation-aiohttp-client~=0.0a0", # OpenTelemetry instrumentation for aiohttp client+ "opentelemetry-instrumentation-redis~=0.0a0", # OpenTelemetry instrumentation for Redis+ "opentelemetry-semantic-conventions~=0.0a0", # OpenTelemetry conventions, to standardize telemetry data+ "phonenumbers~=8.13", # Phone number parsing and formatting, used with Pydantic+ "pydantic-extra-types~=2.9", # Extra types for Pydantic+ "pydantic-settings~=2.6", # Application configuration management with Pydantic+ "pydantic[email]~=2.9", # Data serialization and validation, plus email validation+ "pyjwt~=2.9", # Secure inbound calls from Communication Services+ "python-dotenv~=1.0", # Load environment variables from .env file+ "python-multipart==0.*", # Form parsing+ "pytz~=2024.0", # Time zone handling+ "pyyaml~=6.0", # YAML parser+ "redis~=5.2", # Redis client+ "structlog~=24.4", # Pretty logging+ "tenacity~=8.2", # Async retrying library+ "tiktoken~=0.8", # Tokenization library for OpenAI models+ "twilio~=9.3", # Twilio SDK, used for SMS+ "typing-extensions~=4.12", # Typing extensions for Python 3.6++ "uvicorn[standard]~=0.32", # Application middleware][project.optional-dependencies]dev = [- "deepeval~=0.21", # LLM model evaluation- "deptry~=0.20", # Dependency tree testing- "pyright~=1.1", # Static type checker- "pytest-assume~=2.4", # Pytest plugin for conditional tests- "pytest-asyncio~=0.24", # Pytest plugin for async tests- "pytest-repeat~=0.9", # Pytest plugin for repeating tests- "pytest-xdist[psutil]~=3.6", # Pytest plugin for parallel testing- "pytest~=8.3", # Testing framework- "ruff~=0.7", # Linter+ "deepeval~=0.21", # LLM model evaluation+ "deptry~=0.20", # Dependency tree testing+ "pyright~=1.1", # Static type checker+ "pytest-assume~=2.4", # Pytest plugin for conditional tests+ "pytest-asyncio~=0.24", # Pytest plugin for async tests+ "pytest-repeat~=0.9", # Pytest plugin for repeating tests+ "pytest-xdist[psutil]~=3.6", # Pytest plugin for parallel testing+ "pytest~=8.3", # Testing framework+ "ruff~=0.7", # Linter][tool.setuptools]-py-modules = [- "app",-]+py-modules = ["app"][tool.deptry]ignore_notebooks = true@@ -73,7 +71,7 @@ pep621_dev_dependency_groups = ["dev"][tool.deptry.per_rule_ignores]DEP002 = [- "aiodns", # Resolver is required for the AIOHTTP AsyncResolver TCP resolver+ "aiodns", # Resolver is required for the AIOHTTP AsyncResolver TCP resolver][tool.ruff]