microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.82k stars 3.25k forks source link

.Net: AzureAISearchMemoryStore issue with SearchClientOptions (version = 3) #4099

Open vkynchev opened 10 months ago

vkynchev commented 10 months ago

Describe the bug There's a runtime validation error regarding SearchClientOptions API version parameter. This param is not passed into the constructor of SearchClientOptions, however somehow it's being set to 3 at runtime (which is not a valid value).

To Reproduce Steps to reproduce the behavior:

  1. Try to initialize AzureAISearchMemoryStore like so: new AzureAISearchMemoryStore(asConfig.Endpoint, asConfig.APIKey);

Expected behavior SearchClientOptions should be the default value = 2, and the exception should not be thrown.

Screenshots

Screenshot 2023-12-08 at 13 56 39 Screenshot 2023-12-08 at 13 24 46 Screenshot 2023-12-08 at 13 25 08 Screenshot 2023-12-08 at 13 25 30

Platform

Additional context After debugging I've noticed that this constructor gets executed twice with the correct version (2) on DI initialization. However after the first http request to the app it gets called with version=3, thus causing the exception.

vkynchev commented 10 months ago

Issue is caused by a Azure.Search.Documents package referenced by SemanticKernel https://github.com/microsoft/semantic-kernel/blob/cb73546bc04d39df2dd8610a6b6fbdc66e7708b4/dotnet/Directory.Packages.props#L11

When there's a different version used in the project it's causing issues on runtime.

vkynchev commented 10 months ago

@matthewbolanos Not sure if you're the right person to tag, but I resolved it locally by cloning the AzureAISearchMemoryStore class and forcing the API version. Another option would be to update the package in SemanticKernel repo to latest (11.5.1) since the enum option 3 is gone since the stable release of 11.5.0.

Screenshot 2023-12-12 at 17 44 56