Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/custom-skills/Functions/OpenAiRedactionFunction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.ML.Tokenizers;
using Microsoft.SemanticKernel;
Expand All @@ -17,10 +16,12 @@ namespace PhiDeidPortal.CustomFunctions.Functions
public class OpenAIRedactionFunction
{
private readonly ILogger<OpenAIRedactionFunction> _logger;
private readonly IHttpClientFactory _httpClientFactory;

public OpenAIRedactionFunction(ILogger<OpenAIRedactionFunction> logger)
public OpenAIRedactionFunction(ILogger<OpenAIRedactionFunction> logger, IHttpClientFactory httpClientFactory)
{
_logger = logger;
_httpClientFactory = httpClientFactory;
}

[Function("OpenAiRedactionFunction")]
Expand Down Expand Up @@ -48,7 +49,7 @@ public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "
_logger.LogInformation($"Deployment Name: {Environment.GetEnvironmentVariable(EnvironmentVariables.OpenAiDeploymentName)}");
_logger.LogInformation($"End Point: {Environment.GetEnvironmentVariable(EnvironmentVariables.OpenAiEndpoint)}");

var client = new HttpClient() { Timeout = TimeSpan.FromMinutes(5) };
var client = _httpClientFactory.CreateClient("OpenAI");

kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
Expand Down
1 change: 1 addition & 0 deletions src/custom-skills/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
.ConfigureServices(services => {
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddHttpClient("OpenAI", client => { client.Timeout = TimeSpan.FromMinutes(5); });
})
.Build();

Expand Down