[Bug] HttpClient.Timeout with ImportDocumentAsync
aitrailblazer opened this issue · 4 comments
Context / Scenario
Importing file with:
using var memoryStream = new MemoryStream();
using Stream fileStream = File.OpenRead(filePath);
await fileStream.CopyToAsync(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
then:
var docId = await memory.ImportDocumentAsync(
content: memoryStream,
documentId: memoryKey,
fileName: fileName,
index: indexName,
steps: Microsoft.KernelMemory.Constants.PipelineWithSummary,
tags: tagsCollection,
context: context);
the file is 200KB
What happened?
Received a timeout
Importance
I cannot use Kernel Memory
Platform, Language, Versions
Azure, Blazor
Relevant log output
Error reading file: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
var httpClient = new HttpClient();
//timeout
httpClient.Timeout = TimeSpan.FromMinutes(5);
var memoryBuild = new KernelMemoryBuilder()
.WithOpenAITextGeneration(new OpenAIConfig()
{
APIKey = ModelKey,
TextModel = ModelName
}, null, httpClient)
.WithOpenAITextGeneration(new OpenAIConfig()
{
APIKey = ModelKey,
TextModel = ModelName
}, null, httpClient);
Maybe you can increase the timeout
Similar issue in .Net console app. Timeout in ImportDocumentAsync() for a 7MB pdf file. Options?
If you are using the Serverless client, which is synchronous, the solution is usually using the Async memory option, which runs in the background and retries in case of errors. You should also investigate the reason for the 100 secs timeout, e.g. in case you're using an external service that is throttling your requests. That's often the case with embedding generation, but could be something else.
Assuming this has been resolved or was a one-off transient issue, and closing the ticket