Skip to content

Commit

Permalink
Update ContentModerator and ImageAnalyzer configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
heblasco committed Mar 6, 2024
1 parent 04ada90 commit 569d802
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions infra/modules/ca-aihub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 9 additions & 1 deletion src/AIHub/Controllers/ImageAnalyzerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ public async Task<IActionResult> 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
Expand Down
1 change: 1 addition & 0 deletions src/AIHub/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 569d802

Please sign in to comment.