microsoft / semantic-kernel

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

.Net: Bug: Microsoft.SemanticKernel.Yaml is incompatible with current YamlDotNet, causing TypeLoadException at runtime #9051

Open jphorv-bdo opened 1 week ago

jphorv-bdo commented 1 week ago

Describe the bug Using KernelFunctionYaml.FromPromptYaml() to deserialize YAML to an SK function in an existing codebase, with an existing dependency on YamlDotNet latest version (16.1.3).

The call to KernelFunctionYaml.FromPromptYaml() results in a TypeLoadException with the message:

Method 'ReadYaml' in type 'Microsoft.SemanticKernel.PromptExecutionSettingsTypeConverter' from assembly 'Microsoft.SemanticKernel.Yaml, Version=1.20.0.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3' does not have an implementation.

It appears to be a breaking change with YamlDotNet 16.0.0, released 7/14/2024, specifically a change to the method signature of IYamlTypeConverter.ReadYaml()

To Reproduce Steps to reproduce the behavior:

  1. Have a project that references YamlDotNet 16.1.3 and Microsoft.SemanticKernel.Yaml
  2. Call KernelFunctionYaml.FromPromptYaml() with valid (or invalid) YAML.
  3. The TypeLoadException is thrown.

Expected behavior The call to KernelFunctionYaml.FromPromptYaml() should parse the YAML and if it is valid, return a valid KernelFunction object.

Screenshots N/A

Platform

Additional context The problem occurred while using Microsoft.SemanticKernel.Yaml < 1.20.0 but was not investigated until now.

evchaki commented 1 week ago

@jphorv-bdo thanks for reporting this. @markwallace-microsoft will take a look.