Replies: 2 comments 2 replies
-
You can try with something like this: builder.Services.ConfigureHttpClientDefaults(configure =>
{
configure.AddStandardResilienceHandler(options =>
{
options.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(2);
});
}); |
Beta Was this translation helpful? Give feedback.
1 reply
-
@be-swarm, you can configure the httpClient with adding it ad parameter while adding the text generation service. Example: /// <summary>
/// Use Azure OpenAI to generate text, e.g. answers and summaries.
/// </summary>
/// <param name="builder">Kernel Memory builder</param>
/// <param name="config">Azure OpenAI settings</param>
/// <param name="textTokenizer">Tokenizer used to count tokens used by prompts</param>
/// <param name="httpClient">Custom <see cref="HttpClient"/> for HTTP requests.</param>
/// <returns>KM builder instance</returns>
public static IKernelMemoryBuilder WithAzureOpenAITextGeneration(
this IKernelMemoryBuilder builder,
AzureOpenAIConfig? config = null,
ITextTokenizer? textTokenizer = null,
HttpClient? httpClient = null)
{
builder.Services.AddAzureOpenAITextGeneration(config, textTokenizer, httpClient);
return builder;
} So you can here add your dedicated instance of httpClient with resiliancy options. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Is there a way to configure http client configuration (like semantic kernel config )
ex:
c.ConfigureHttpClient((sp, client) =>
{
client.Timeout = TimeSpan.FromSeconds(120);
});
c.AddStandardResilienceHandler().Configure(o =>
{
o.Retry.ShouldRetryAfterHeader = true;
o.Retry.ShouldHandle = args => ValueTask.FromResult(args.Outcome.Result?.StatusCode is HttpStatusCode.TooManyRequests);
o.Retry.ShouldHandle = args => ValueTask.FromResult(args.Outcome.Result?.StatusCode is HttpStatusCode.GatewayTimeout);
});
Thanks
Beta Was this translation helpful? Give feedback.
All reactions