Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: The operation was cancelled because it exceeded the configured timeout of 0:01:40 #3223

Closed
MarkusMeyer13 opened this issue Oct 18, 2023 · 2 comments
Labels
bug Something isn't working follow up Issues that require a follow up from the community. kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Comments

@MarkusMeyer13
Copy link

Describe the bug

I'm using Microsoft.SemanticKernel version="1.0.0-beta2"
The InvokeAsync method raises an exception:

The operation was cancelled because it exceeded the configured timeout of 0:01:40. Network timeout can be adjusted in ClientOptions.Retry.NetworkTimeout.

StackTrace:

at Azure.Core.Pipeline.ResponseBodyPolicy.ThrowIfCancellationRequestedOrTimeout(CancellationToken originalToken, CancellationToken timeoutToken, Exception inner, TimeSpan timeout)
at Azure.Core.Pipeline.ResponseBodyPolicy.d__5.MoveNext()
at Azure.Core.Pipeline.RedirectPolicy.d__7.MoveNext()
at Azure.Core.Pipeline.RetryPolicy.d__5.MoveNext()
at Azure.Core.Pipeline.RetryPolicy.d__5.MoveNext()
at Azure.Core.HttpPipelineExtensions.d__0.MoveNext()
at System.Threading.Tasks.ValueTask1.get_Result() at Azure.AI.OpenAI.OpenAIClient.<GetChatCompletionsAsync>d__17.MoveNext() at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.<RunRequestAsync>d__291.MoveNext()
at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.d__19.MoveNext()
at Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk.ClientBase.d__22.MoveNext()
at Microsoft.SemanticKernel.SemanticFunction.d__36.MoveNext()
at Microsoft.SemanticKernel.SemanticFunction.d__17.MoveNext()

To Reproduce
Steps to reproduce the behavior:

This is the C# code which produces the exception:

static async Task<string?> Summarize(string openAiDeploymentName, string openAiEndPoint, string openAiKey, string prompt, string data)
{
    try
    {
        var builder = new KernelBuilder();
        builder.WithAzureChatCompletionService(openAiDeploymentName, openAiEndPoint, openAiKey);
        var kernel = builder.Build();

        var summarize = kernel.CreateSemanticFunction(prompt, requestSettings: new OpenAIRequestSettings() { Temperature = 0.1 });

        // 'data' has a length of 8993
        var result = await summarize.InvokeAsync(data, kernel).ConfigureAwait(false);

        return result.GetValue<string>();
    }
    catch (Exception e)
    {
        await Console.Out.WriteLineAsync(e.Message);
        throw;
    }
}

Used model:

Model name: gpt-35-turbo-16k
Model version: 0613
Version update policy: Once a new default version is available.
Deployment type: Standard
Content Filter: Default
Tokens per Minute Rate Limit (thousands): 5
Rate limit (Tokens per minute): 5000
Rate limit (Requests per minute): 60

The data to summarize has a length of 8993 characters.
The timeout does not happen if the length is e.g. 4000 characters.

  1. Run code
  2. Wait for the result
  3. TimeOut exception occurs

Expected behavior
InvokeAsync shall return a valid result also for longer strings.

Screenshots

image

Platform

  • OS: Windows
  • IDE: Visual Studio
  • Language: C#

Additional context
Add any other context about the problem here.

@shawncal shawncal added .NET Issue or Pull requests regarding .NET code triage labels Oct 18, 2023
@github-actions github-actions bot changed the title The operation was cancelled because it exceeded the configured timeout of 0:01:40 .Net: The operation was cancelled because it exceeded the configured timeout of 0:01:40 Oct 18, 2023
@evchaki evchaki added bug Something isn't working kernel Issues or pull requests impacting the core kernel labels Oct 19, 2023
@matthewbolanos
Copy link
Member

@MarkusMeyer13, does providing a custom HTTP client to the kernel with a different timeout fix the issue?

@matthewbolanos matthewbolanos added follow up Issues that require a follow up from the community. and removed triage labels Oct 23, 2023
@MarkusMeyer13
Copy link
Author

I solved the timeout issue by increasing the timeout value with OpenAIClientOptions:

var clientOptions = new OpenAIClientOptions();
clientOptions.Retry.MaxRetries = 1;
clientOptions.Retry.NetworkTimeout = TimeSpan.FromMinutes(4);
var openAIClient = new OpenAIClient(new Uri(openAiEndPoint), new AzureKeyCredential(openAiKey), clientOptions);

var builder = new KernelBuilder();
builder.WithAzureChatCompletionService(openAiDeploymentName, openAIClient);
var kernel = builder.Build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working follow up Issues that require a follow up from the community. kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

No branches or pull requests

4 participants