diff --git a/src/AIHub/Controllers/AudioTranscriptionController.cs b/src/AIHub/Controllers/AudioTranscriptionController.cs index ee8ff40..d71ef17 100644 --- a/src/AIHub/Controllers/AudioTranscriptionController.cs +++ b/src/AIHub/Controllers/AudioTranscriptionController.cs @@ -1,13 +1,4 @@ namespace MVCWeb.Controllers; -using System; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Microsoft.AspNetCore.Mvc; -using System.Net; -using Newtonsoft.Json.Linq; -using Microsoft.VisualBasic; public class AudioTranscriptionController : Controller { diff --git a/src/AIHub/Controllers/BrandAnalyzerController.cs b/src/AIHub/Controllers/BrandAnalyzerController.cs index e1b745b..8d2cca4 100644 --- a/src/AIHub/Controllers/BrandAnalyzerController.cs +++ b/src/AIHub/Controllers/BrandAnalyzerController.cs @@ -83,9 +83,19 @@ public async Task AnalyzeCompany() try { - OpenAIClient client_oai = new OpenAIClient( - new Uri(AOAIendpoint), - new AzureKeyCredential(AOAIsubscriptionKey)); + OpenAIClient client_oai = null; + if (string.IsNullOrEmpty(AOAIsubscriptionKey)) + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new DefaultAzureCredential()); + } + else + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new AzureKeyCredential(AOAIsubscriptionKey)); + } // ### If streaming is not selected Response responseWithoutStream = await client_oai.GetChatCompletionsAsync( diff --git a/src/AIHub/Controllers/CallCenterController.cs b/src/AIHub/Controllers/CallCenterController.cs index 4257957..52340a8 100644 --- a/src/AIHub/Controllers/CallCenterController.cs +++ b/src/AIHub/Controllers/CallCenterController.cs @@ -37,10 +37,19 @@ public async Task AnalyzeCall() } try { - - OpenAIClient client_oai = new OpenAIClient( - new Uri(endpoint), - new AzureKeyCredential(subscriptionKey)); + OpenAIClient client_oai = null; + if (string.IsNullOrEmpty(subscriptionKey)) + { + client_oai = new OpenAIClient( + new Uri(endpoint), + new DefaultAzureCredential()); + } + else + { + client_oai = new OpenAIClient( + new Uri(endpoint), + new AzureKeyCredential(subscriptionKey)); + } // ### If streaming is not selected Response responseWithoutStream = await client_oai.GetChatCompletionsAsync( diff --git a/src/AIHub/Controllers/FormAnalyzerController.cs b/src/AIHub/Controllers/FormAnalyzerController.cs index 709e277..83043dc 100644 --- a/src/AIHub/Controllers/FormAnalyzerController.cs +++ b/src/AIHub/Controllers/FormAnalyzerController.cs @@ -120,10 +120,19 @@ public async Task AnalyzeForm(string image_url, string prompt) try { - - OpenAIClient client_oai = new OpenAIClient( - new Uri(AOAIendpoint), - new AzureKeyCredential(AOAIsubscriptionKey)); + OpenAIClient client_oai = null; + if (string.IsNullOrEmpty(AOAIsubscriptionKey)) + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new DefaultAzureCredential()); + } + else + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new AzureKeyCredential(AOAIsubscriptionKey)); + } // ### If streaming is not selected Response responseWithoutStream = await client_oai.GetChatCompletionsAsync( diff --git a/src/AIHub/Controllers/ImageAnalyzerController.cs b/src/AIHub/Controllers/ImageAnalyzerController.cs index 7a80c44..64004ae 100644 --- a/src/AIHub/Controllers/ImageAnalyzerController.cs +++ b/src/AIHub/Controllers/ImageAnalyzerController.cs @@ -163,10 +163,19 @@ public async Task DenseCaptionImage(string image_url) //7. Describe Image GPT4 try { - - OpenAIClient client_oai = new OpenAIClient( - new Uri(AOAIendpoint), - new AzureKeyCredential(AOAIsubscriptionKey)); + OpenAIClient client_oai = null; + if (string.IsNullOrEmpty(AOAIsubscriptionKey)) + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new DefaultAzureCredential()); + } + else + { + client_oai = new OpenAIClient( + new Uri(AOAIendpoint), + new AzureKeyCredential(AOAIsubscriptionKey)); + } // ### If streaming is not selected Response responseWithoutStream = await client_oai.GetChatCompletionsAsync( diff --git a/src/AIHub/GlobalUsings.cs b/src/AIHub/GlobalUsings.cs index 4951a6e..e3d4be4 100644 --- a/src/AIHub/GlobalUsings.cs +++ b/src/AIHub/GlobalUsings.cs @@ -3,11 +3,13 @@ global using MVCWeb.Models; global using Azure.AI.ContentSafety; global using Azure; +global using Azure.Identity; global using Azure.Storage.Blobs; global using Azure.Storage.Blobs.Models; global using Azure.AI.OpenAI; global using System.Net.Http.Headers; global using Newtonsoft.Json; +global using Newtonsoft.Json.Linq; global using System.Text; global using System.Text.Json; global using System.Text.Json.Serialization;