Skip to content

.Net: feat: Added support for .yml extensions in C# SDK #11324

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public PromptYamlKernelExtensionsTests()
File.WriteAllText(yamlFile1Path, YAML);
File.WriteAllText(yamlFile2Path, YAMLWithCustomSettings);
File.WriteAllText(yamlFile3Path, YAMLNoExecutionSettings);

// Add .yml file to plugin2 to ensure both extensions are supported
string ymlFile1Path = Path.Combine(plugin2Directory, $"{nameof(YAML)}.yml");

File.WriteAllText(ymlFile1Path, YAML);

}
catch (Exception)
{
Expand Down Expand Up @@ -112,7 +118,7 @@ private static void VerifyPluginCounts(Kernel kernel, string expectedPlugin1, st
Assert.NotNull(kernel.Plugins[expectedPlugin2]);

Assert.Equal(2, kernel.Plugins[expectedPlugin1].Count());
Assert.Single(kernel.Plugins[expectedPlugin2]);
Assert.Equal(2, kernel.Plugins[expectedPlugin2].Count());
}

private const string YAML = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ private static KernelPlugin CreatePluginFromPromptDirectoryYaml(
IPromptTemplateFactory? promptTemplateFactory = null,
IServiceProvider? services = null)
{
const string YamlFilePattern = "*.yaml";

Verify.DirectoryExists(pluginDirectory);
pluginName ??= new DirectoryInfo(pluginDirectory).Name;

Expand All @@ -96,7 +94,12 @@ private static KernelPlugin CreatePluginFromPromptDirectoryYaml(
var functions = new List<KernelFunction>();
ILogger logger = loggerFactory.CreateLogger(typeof(Kernel)) ?? NullLogger.Instance;

foreach (string functionFile in Directory.GetFiles(pluginDirectory, YamlFilePattern))
string[] functionFiles = [
..Directory.GetFiles(pluginDirectory, "*.yaml"),
..Directory.GetFiles(pluginDirectory, "*.yml")
];

foreach (string functionFile in functionFiles)
{
var functionName = Path.GetFileName(functionFile);
var functionYaml = File.ReadAllText(functionFile);
Expand Down