diff --git a/infra/modules/ca-aihub/main.tf b/infra/modules/ca-aihub/main.tf index 90e2456..10d66ca 100644 --- a/infra/modules/ca-aihub/main.tf +++ b/infra/modules/ca-aihub/main.tf @@ -83,8 +83,8 @@ resource "azapi_resource" "ca_back" { secretRef = "content-safety-key" }, { - name = "ContentModerator__JailbreakDetectionEndpoint", - value = "contentsafety/text:detectJailbreak?api-version=2023-10-15-preview" + name = "ContentModerator__JailbreakDetectionEndpoint", + value = "contentsafety/text:detectJailbreak?api-version=2023-10-15-preview" }, { name = "BrandAnalyzer__BingEndpoint", @@ -132,7 +132,7 @@ resource "azapi_resource" "ca_back" { }, { name = "ImageAnalyzer__DeploymentName", - value = var.chat_gpt_deployment + value = var.chat_gpt4_vision_deployment }, { name = "FormAnalyzer__FormRecogEndpoint", diff --git a/src/AIHub/Controllers/ImageAnalyzerController.cs b/src/AIHub/Controllers/ImageAnalyzerController.cs index b1a862e..79aa384 100644 --- a/src/AIHub/Controllers/ImageAnalyzerController.cs +++ b/src/AIHub/Controllers/ImageAnalyzerController.cs @@ -48,7 +48,15 @@ public async Task DenseCaptionImage(string image_url, string prom using (httpClient = new HttpClient()) { - httpClient.DefaultRequestHeaders.Add("api-key", AOAIsubscriptionKey); + if (string.IsNullOrEmpty(AOAIsubscriptionKey)) + { + var credential = new DefaultAzureCredential(); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", credential.GetToken(new TokenRequestContext(["https://api.openai.com/.default"])).Token); + } + else + { + httpClient.DefaultRequestHeaders.Add("api-key", AOAIsubscriptionKey); + } var payload = new { enhancements = new diff --git a/src/AIHub/GlobalUsings.cs b/src/AIHub/GlobalUsings.cs index 9b4e269..8395264 100644 --- a/src/AIHub/GlobalUsings.cs +++ b/src/AIHub/GlobalUsings.cs @@ -3,6 +3,7 @@ global using MVCWeb.Models; global using Azure.AI.ContentSafety; global using Azure; +global using Azure.Core; global using Azure.Identity; global using Azure.Storage.Blobs; global using Azure.Storage.Blobs.Models;