Skip to content

Commit

Permalink
.Net: Fixed integration tests (#6130)
Browse files Browse the repository at this point in the history
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Fixed integration tests by updating link to plugins folder based on
changes in this PR:
#6116

### 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 😄
  • Loading branch information
dmytrostruk committed May 6, 2024
1 parent 6ce7e1e commit 9810cc1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private async Task RunExampleAsync(ISemanticTextMemory memory)
Query: Can I build a chat with SK?
Result 1:
URL: : https://github.com/microsoft/semantic-kernel/tree/main/samples/plugins/ChatPlugin/ChatGPT
URL: : https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples/ChatPlugin/ChatGPT
Title : Sample demonstrating how to create a chat plugin interfacing with ChatGPT
Result 2:
Expand Down Expand Up @@ -159,9 +159,9 @@ private async Task StoreMemoryAsync(ISemanticTextMemory memory)
= "README: Installation, getting started, and how to contribute",
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/02-running-prompts-from-file.ipynb"]
= "Jupyter notebook describing how to pass prompts from a file to a semantic plugin or function",
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks//00-getting-started.ipynb"]
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/00-getting-started.ipynb"]
= "Jupyter notebook describing how to get started with the Semantic Kernel",
["https://github.com/microsoft/semantic-kernel/tree/main/samples/plugins/ChatPlugin/ChatGPT"]
["https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples/ChatPlugin/ChatGPT"]
= "Sample demonstrating how to create a chat plugin interfacing with ChatGPT",
["https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Plugins/Plugins.Memory/VolatileMemoryStore.cs"]
= "C# class that defines a volatile embedding store",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
internal static class RepoFiles
{
/// <summary>
/// Scan the local folders from the repo, looking for "samples/plugins" folder.
/// Scan the local folders from the repo, looking for "prompt_template_samples" folder.
/// </summary>
/// <returns>The full path to samples/plugins</returns>
/// <returns>The full path to prompt_template_samples</returns>
public static string SamplePluginsPath()
{
const string Parent = "samples";
const string Folder = "plugins";
const string Folder = "prompt_template_samples";

static bool SearchPath(string pathToFind, out string result, int maxAttempts = 10)
{
Expand All @@ -28,8 +27,7 @@ static bool SearchPath(string pathToFind, out string result, int maxAttempts = 1
return found;
}

if (!SearchPath(Parent + Path.DirectorySeparatorChar + Folder, out string path)
&& !SearchPath(Folder, out path))
if (!SearchPath(Folder, out var path))
{
throw new DirectoryNotFoundException("Plugins directory not found. The app needs the plugins from the repo to work.");
}
Expand Down
6 changes: 4 additions & 2 deletions dotnet/src/IntegrationTests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ namespace SemanticKernel.IntegrationTests;

internal static class TestHelpers
{
private const string PluginsFolder = "../../../../../../prompt_template_samples";

internal static void ImportAllSamplePlugins(Kernel kernel)
{
ImportSamplePromptFunctions(kernel, "../../../../../../samples/plugins",
ImportSamplePromptFunctions(kernel, PluginsFolder,
"ChatPlugin",
"SummarizePlugin",
"WriterPlugin",
Expand All @@ -33,7 +35,7 @@ internal static void ImportAllSampleSkills(Kernel kernel)

internal static IReadOnlyKernelPluginCollection ImportSamplePlugins(Kernel kernel, params string[] pluginNames)
{
return ImportSamplePromptFunctions(kernel, "../../../../../../samples/plugins", pluginNames);
return ImportSamplePromptFunctions(kernel, PluginsFolder, pluginNames);
}

internal static IReadOnlyKernelPluginCollection ImportSamplePromptFunctions(Kernel kernel, string path, params string[] pluginNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
public static class RepoFiles
{
/// <summary>
/// Scan the local folders from the repo, looking for "samples/plugins" folder.
/// Scan the local folders from the repo, looking for "prompt_template_samples" folder.
/// </summary>
/// <returns>The full path to samples/plugins</returns>
/// <returns>The full path to prompt_template_samples folder.</returns>
public static string SamplePluginsPath()
{
const string Parent = "samples";
const string Folder = "plugins";
const string Folder = "prompt_template_samples";

static bool SearchPath(string pathToFind, out string result, int maxAttempts = 10)
{
Expand All @@ -27,8 +26,7 @@ static bool SearchPath(string pathToFind, out string result, int maxAttempts = 1
return found;
}

if (!SearchPath(Parent + Path.DirectorySeparatorChar + Folder, out string path)
&& !SearchPath(Folder, out path))
if (!SearchPath(Folder, out var path))
{
throw new YourAppException("Plugins directory not found. The app needs the plugins from the repo to work.");
}
Expand Down
6 changes: 3 additions & 3 deletions dotnet/src/SemanticKernel.Core/KernelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins
/// |__ config.json # settings (optional file)
/// </code>
/// <para>
/// See https://github.com/microsoft/semantic-kernel/tree/main/samples/plugins for examples in the Semantic Kernel repository.
/// See https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples for examples in the Semantic Kernel repository.
/// </para>
/// </remarks>
/// <param name="kernel">The <see cref="Kernel"/> containing services, plugins, and other state for use throughout the operation.</param>
Expand Down Expand Up @@ -555,7 +555,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins
/// |__ config.json # settings (optional file)
/// </code>
/// <para>
/// See https://github.com/microsoft/semantic-kernel/tree/main/samples/plugins for examples in the Semantic Kernel repository.
/// See https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples for examples in the Semantic Kernel repository.
/// </para>
/// </remarks>
/// <param name="kernel">The <see cref="Kernel"/> containing services, plugins, and other state for use throughout the operation.</param>
Expand Down Expand Up @@ -603,7 +603,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins
/// |__ config.json # settings (optional file)
/// </code>
/// <para>
/// See https://github.com/microsoft/semantic-kernel/tree/main/samples/plugins for examples in the Semantic Kernel repository.
/// See https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples for examples in the Semantic Kernel repository.
/// </para>
/// </remarks>
/// <param name="plugins">The plugin collection to which the new plugin should be added.</param>
Expand Down

0 comments on commit 9810cc1

Please sign in to comment.