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: Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception #2953

Closed
WeihanLi opened this issue Sep 24, 2023 · 0 comments · Fixed by #2985
Closed

.Net: Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception #2953

WeihanLi opened this issue Sep 24, 2023 · 0 comments · Fixed by #2985
Labels
.NET Issue or Pull requests regarding .NET code triage

Comments

@WeihanLi
Copy link
Contributor

WeihanLi commented Sep 24, 2023

Describe the bug

Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception when using the redis memory storage

To Reproduce

var apiEndpoint = Guard.NotNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_OPENAI_API_ENDPOINT"));
var apiKey = Guard.NotNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY"));
var kernelBuilder = new KernelBuilder();
kernelBuilder.WithAzureChatCompletionService("gpt-35-turbo", apiEndpoint, apiKey);
kernelBuilder.WithAzureTextEmbeddingGenerationService("text-embedding-ada-002", apiEndpoint, apiKey);
// kernelBuilder.WithMemoryStorage(new VolatileMemoryStore());
kernelBuilder.WithMemoryStorage(new RedisMemoryStore("localhost:6379"));
var kernel = kernelBuilder.Build();
var collectionName = "Products";
await using var fs = File.OpenRead("text-sample.json");
var list = await JsonSerializer.DeserializeAsync<Product[]>(fs);
Guard.NotNull(list);
foreach (var product in list)
{
    await kernel.Memory.SaveInformationAsync(collectionName, product.Description, product.Title, product.Description, product.Category);
}


file sealed class Product
{
    [JsonPropertyName("id")]
    public required string Id { get; set; }
    
    [JsonPropertyName("category")]
    public required string Category { get; set; }
    
    [JsonPropertyName("title")]
    public required string Title { get; set; }
    
    [JsonPropertyName("content")]
    public required string Description { get; set; }
}

Running on a console targeted at net8.0 and with .NET 8 RC1 SDK

Expected behavior

success without exception

Screenshots

image

Platform

  • OS: Windows
  • IDE: VS Code
  • Language: C#
  • Source:
<PackageVersion Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Memory.Redis" Version="0.24.230918.1-preview" />

Additional context

Without exception when using the memory storage such as VolatileMemoryStore

workaround solution: add a reference for Microsoft.Bcl.AsyncInterfaces

@shawncal shawncal added .NET Issue or Pull requests regarding .NET code triage labels Sep 24, 2023
@github-actions github-actions bot changed the title Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception .Net: Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception Sep 24, 2023
github-merge-queue bot pushed a commit that referenced this issue Sep 29, 2023
### Motivation and Context
Fix #2953

### Description
Looks like, since #1799, there's been a problem. However, due to
references from other projects, tests and samples have not shown the
problem.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
SOE-YoungS pushed a commit to SOE-YoungS/semantic-kernel that referenced this issue Nov 1, 2023
### Motivation and Context
Fix microsoft#2953

### Description
Looks like, since microsoft#1799, there's been a problem. However, due to
references from other projects, tests and samples have not shown the
problem.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants