Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
perf: Remove AAD managed identities
Clémence Lesnéf0c1c4f616f7
diff --git a/bicep/app.bicep b/bicep/app.bicepindex 0e99d2a..5b10eaa 100644--- a/bicep/app.bicep+++ b/bicep/app.bicep@@ -73,6 +73,7 @@ var config = {fast: {mode: 'azure_openai'azure_openai: {+ api_key: cognitiveOpenai.listKeys().key1context: llmFastContextdeployment: llmFast.nameendpoint: cognitiveOpenai.properties.endpoint@@ -83,6 +84,7 @@ var config = {slow: {mode: 'azure_openai'azure_openai: {+ api_key: cognitiveOpenai.listKeys().key1context: llmSlowContextdeployment: llmSlow.nameendpoint: cognitiveOpenai.properties.endpoint@@ -440,21 +442,6 @@ resource cognitiveCommunication 'Microsoft.CognitiveServices/accounts@2024-06-01}}-// Cognitive Services OpenAI Contributor-resource roleOpenaiContributor 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {- name: 'a001fd3d-188f-4b5d-821b-7da978bf7442'-}--resource assignmentsFunctionAppOpenaiContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {- name: guid(subscription().id, prefix, cognitiveOpenai.name, 'assignmentsFunctionAppOpenaiContributor')- scope: cognitiveOpenai- properties: {- principalId: functionApp.identity.principalId- principalType: 'ServicePrincipal'- roleDefinitionId: roleOpenaiContributor.id- }-}-resource cognitiveOpenai 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' = {name: '${prefix}-${openaiLocation}-openai'location: openaiLocationdiff --git a/helpers/config_models/llm.py b/helpers/config_models/llm.pyindex d3b8a56..35679ef 100644--- a/helpers/config_models/llm.py+++ b/helpers/config_models/llm.py@@ -1,7 +1,6 @@from enum import Enumfrom typing import Any-from azure.identity import ManagedIdentityCredential, get_bearer_token_providerfrom openai import AsyncAzureOpenAI, AsyncOpenAIfrom pydantic import BaseModel, Field, SecretStr, ValidationInfo, field_validator@@ -24,21 +23,12 @@ class AbstractPlatformModel(BaseModel):class AzureOpenaiPlatformModel(AbstractPlatformModel):_client: AsyncAzureOpenAI | None = None- api_key: SecretStr | None = None+ api_key: SecretStrdeployment: strendpoint: strdef instance(self) -> tuple[AsyncAzureOpenAI, AbstractPlatformModel]:if not self._client:- api_key = self.api_key.get_secret_value() if self.api_key else None- token_func = (- get_bearer_token_provider(- ManagedIdentityCredential(),- "https://cognitiveservices.azure.com/.default",- )- if not self.api_key- else None- )self._client = AsyncAzureOpenAI(**self._client_kwargs,# Deployment@@ -46,8 +36,7 @@ class AzureOpenaiPlatformModel(AbstractPlatformModel):azure_deployment=self.deployment,azure_endpoint=self.endpoint,# Authentication- api_key=api_key,- azure_ad_token_provider=token_func,+ api_key=self.api_key.get_secret_value(),)return self._client, selfdiff --git a/tests/conftest.py b/tests/conftest.pyindex d6e9dca..b26093d 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -15,7 +15,6 @@ from azure.communication.callautomation.aio import (CallAutomationClient,CallConnectionClient,)-from azure.identity import ManagedIdentityCredential, get_bearer_token_providerfrom deepeval.models.gpt_model import GPTModelfrom langchain_openai import AzureChatOpenAIfrom pydantic import BaseModel, ValidationError@@ -147,18 +146,8 @@ class DeepEvalAzureOpenAI(GPTModel):"azure_deployment": platform.deployment,"azure_endpoint": platform.endpoint,"model": platform.model,- # Authentication, either RBAC or API- "api_key": (- platform.api_key.get_secret_value() if platform.api_key else None- ), # pyright: ignore- "azure_ad_token_provider": (- get_bearer_token_provider(- ManagedIdentityCredential(),- "https://cognitiveservices.azure.com/.default",- )- if not platform.api_key- else None- ),+ # Authentication+ "api_key": platform.api_key.get_secret_value(),# DeepEval**kwargs,}