diff --git a/.vscode/launch.json b/.vscode/launch.json
index d512a2e56d8c..3e38b1ff0525 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -5,16 +5,16 @@
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (dotnet-kernel-syntax-examples)",
+ "name": "C#: Concept Samples",
"type": "coreclr",
"request": "launch",
- "preLaunchTask": "build (KernelSyntaxExamples)",
+ "preLaunchTask": "build (Concepts)",
// If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/dotnet/samples/KernelSyntaxExamples/bin/Debug/net6.0/KernelSyntaxExamples.dll",
+ "program": "${workspaceFolder}/dotnet/samples/Concepts/bin/Debug/net6.0/Concepts.dll",
"args": [
/*"example0"*/
],
- "cwd": "${workspaceFolder}/dotnet/samples/KernelSyntaxExamples",
+ "cwd": "${workspaceFolder}/dotnet/samples/Concepts",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
@@ -30,16 +30,21 @@
"type": "python",
"request": "launch",
"module": "pytest",
- "args": [
- "${file}"
- ]
+ "args": ["${file}"]
+ },
+ {
+ "name": "C#: HuggingFaceImageToText Demo",
+ "type": "dotnet",
+ "request": "launch",
+ "projectPath": "${workspaceFolder}\\dotnet\\samples\\Demos\\HuggingFaceImageToText.csproj",
+ "launchConfigurationId": "TargetFramework=;HuggingFaceImageToText"
},
{
- "name": "C#: HuggingFaceImageTextExample",
+ "name": "C#: GettingStarted Samples",
"type": "dotnet",
"request": "launch",
- "projectPath": "${workspaceFolder}\\dotnet\\samples\\HuggingFaceImageTextExample\\HuggingFaceImageTextExample.csproj",
- "launchConfigurationId": "TargetFramework=;HuggingFaceImageTextExample"
+ "projectPath": "${workspaceFolder}\\dotnet\\samples\\GettingStarted\\GettingStarted.csproj",
+ "launchConfigurationId": "TargetFramework=;GettingStarted"
}
]
-}
\ No newline at end of file
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 7993d689209a..91ff88105299 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -327,12 +327,12 @@
// ****************
// Kernel Syntax Examples
{
- "label": "build (KernelSyntaxExamples)",
+ "label": "build (Concepts)",
"command": "dotnet",
"type": "process",
"args": [
"build",
- "${workspaceFolder}/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj",
+ "${workspaceFolder}/dotnet/samples/Concepts/Concepts.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"/property:DebugType=portable"
@@ -341,26 +341,26 @@
"group": "build"
},
{
- "label": "watch (KernelSyntaxExamples)",
+ "label": "watch (Concepts)",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
- "${workspaceFolder}/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj"
+ "${workspaceFolder}/dotnet/samples/Concepts/Concepts.csproj"
],
"problemMatcher": "$msCompile",
"group": "build"
},
{
- "label": "run (KernelSyntaxExamples)",
+ "label": "run (Concepts)",
"command": "dotnet",
"type": "process",
"args": [
"run",
"--project",
- "${workspaceFolder}/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj",
+ "${workspaceFolder}/dotnet/samples/Concepts/Concepts.csproj",
"${input:filter}"
],
"problemMatcher": "$msCompile",
@@ -370,7 +370,7 @@
"panel": "shared",
"group": "PR-Validate"
}
- },
+ }
],
"inputs": [
{
diff --git a/docs/decisions/0021-json-serializable-custom-types.md b/docs/decisions/0021-json-serializable-custom-types.md
index d7a0072409a7..08e017db2060 100644
--- a/docs/decisions/0021-json-serializable-custom-types.md
+++ b/docs/decisions/0021-json-serializable-custom-types.md
@@ -15,7 +15,7 @@ This ADR aims to simplify the usage of custom types by allowing developers to us
Standardizing on a JSON-serializable type is necessary to allow functions to be described using a JSON Schema within a planner's function manual. Using a JSON Schema to describe a function's input and output types will allow the planner to validate that the function is being used correctly.
-Today, use of custom types within Semantic Kernel requires developers to implement a custom `TypeConverter` to convert to/from the string representation of the type. This is demonstrated in [Example60_AdvancedNativeFunctions](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/KernelSyntaxExamples/Example60_AdvancedNativeFunctions.cs#L202C44-L202C44) as seen below:
+Today, use of custom types within Semantic Kernel requires developers to implement a custom `TypeConverter` to convert to/from the string representation of the type. This is demonstrated in [Functions/MethodFunctions_Advanced] as seen below:
```csharp
[TypeConverter(typeof(MyCustomTypeConverter))]
diff --git a/docs/decisions/0042-samples-restructure.md b/docs/decisions/0042-samples-restructure.md
index 2284aa040b30..6dcec8e934d5 100644
--- a/docs/decisions/0042-samples-restructure.md
+++ b/docs/decisions/0042-samples-restructure.md
@@ -37,7 +37,7 @@ informed:
| Current Folder | Proposal |
| ------------------------------------ | ------------------------------------------------------------------- |
-| KernelSyntaxExamples/Getting_Started | Move into `Getting Started` |
+| KernelSyntaxExamples/Getting_Started | Move into `GettingStarted` |
| KernelSyntaxExamples/`Examples??_*` | Decompose into `Concepts` on multiple conceptual subfolders |
| AgentSyntaxExamples | Decompose into `Concepts` on `Agents` specific subfolders. |
| DocumentationExamples | Move into `LearnResources` subfolder and rename to `MicrosoftLearn` |
diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 67669cc3273d..2bae3c7aef2a 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -23,6 +23,7 @@
+
@@ -59,6 +60,7 @@
+
diff --git a/dotnet/SK-dotnet.sln b/dotnet/SK-dotnet.sln
index 64534f36dd50..c64294344291 100644
--- a/dotnet/SK-dotnet.sln
+++ b/dotnet/SK-dotnet.sln
@@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{FA37
samples\README.md = samples\README.md
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KernelSyntax", "samples\KernelSyntaxExamples\KernelSyntax.csproj", "{47C6F821-5103-431F-B3B8-A2868A68BB78}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "src\IntegrationTests\IntegrationTests.csproj", "{E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugins.Document", "src\Plugins\Plugins.Document\Plugins.Document.csproj", "{F94D1938-9DB7-4B24-9FF3-166DDFD96330}"
@@ -252,17 +250,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Functions", "Functions", "{
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agents.OpenAI", "src\Agents\OpenAI\Agents.OpenAI.csproj", "{644A2F10-324D-429E-A1A3-887EAE64207F}"
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Concepts", "Concepts", "{A2E102D2-7015-44CD-B8EF-C56758CD37DE}"
- ProjectSection(SolutionItems) = preProject
- samples\Concepts\README.md = samples\Concepts\README.md
- EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{5D4C0700-BBB5-418F-A7B2-F392B9A18263}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearnResources", "samples\LearnResources\LearnResources.csproj", "{B04C26BC-A933-4A53-BE17-7875EB12E012}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AgentSyntax", "samples\Concepts\AgentSyntax\AgentSyntax.csproj", "{37847DE5-C3B0-41ED-8749-98B9F429B9E5}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateChatGptPlugin", "samples\Demos\CreateChatGptPlugin\Solution\CreateChatGptPlugin.csproj", "{E6204E79-EFBF-499E-9743-85199310A455}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HomeAutomation", "samples\Demos\HomeAutomation\HomeAutomation.csproj", "{CBEEF941-AEC6-42A4-A567-B5641CEFBB87}"
@@ -273,11 +265,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryWithAppInsights",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStarted", "samples\GettingStarted\GettingStarted.csproj", "{1D98CF16-5156-40F0-91F0-76294B153DB3}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tutorials", "Tutorials", "{DA5C4B1B-7194-402D-9B13-0A8A9D8FEE81}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GettingStartedWithAgents", "samples\GettingStartedWithAgents\GettingStartedWithAgents.csproj", "{87DA81FE-112E-4AF5-BEFB-0B91B993F749}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{77E141BA-AF5E-4C01-A970-6C07AC3CD55A}"
ProjectSection(SolutionItems) = preProject
- samples\Tutorials\README.md = samples\Tutorials\README.md
+ src\InternalUtilities\samples\ConfigurationNotFoundException.cs = src\InternalUtilities\samples\ConfigurationNotFoundException.cs
+ src\InternalUtilities\samples\EnumerableExtensions.cs = src\InternalUtilities\samples\EnumerableExtensions.cs
+ src\InternalUtilities\samples\Env.cs = src\InternalUtilities\samples\Env.cs
+ src\InternalUtilities\samples\ObjectExtensions.cs = src\InternalUtilities\samples\ObjectExtensions.cs
+ src\InternalUtilities\samples\PlanExtensions.cs = src\InternalUtilities\samples\PlanExtensions.cs
+ src\InternalUtilities\samples\RepoFiles.cs = src\InternalUtilities\samples\RepoFiles.cs
+ src\InternalUtilities\samples\SamplesInternalUtilities.props = src\InternalUtilities\samples\SamplesInternalUtilities.props
+ src\InternalUtilities\samples\TextOutputHelperExtensions.cs = src\InternalUtilities\samples\TextOutputHelperExtensions.cs
+ src\InternalUtilities\samples\XunitLogger.cs = src\InternalUtilities\samples\XunitLogger.cs
+ src\InternalUtilities\samples\YourAppException.cs = src\InternalUtilities\samples\YourAppException.cs
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Concepts", "samples\Concepts\Concepts.csproj", "{925B1185-8B58-4E2D-95C9-4CA0BA9364E5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -291,11 +296,6 @@ Global
{A284C7EB-2248-4A75-B112-F5DCDE65410D}.Publish|Any CPU.Build.0 = Publish|Any CPU
{A284C7EB-2248-4A75-B112-F5DCDE65410D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A284C7EB-2248-4A75-B112-F5DCDE65410D}.Release|Any CPU.Build.0 = Release|Any CPU
- {47C6F821-5103-431F-B3B8-A2868A68BB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {47C6F821-5103-431F-B3B8-A2868A68BB78}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {47C6F821-5103-431F-B3B8-A2868A68BB78}.Publish|Any CPU.ActiveCfg = Release|Any CPU
- {47C6F821-5103-431F-B3B8-A2868A68BB78}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {47C6F821-5103-431F-B3B8-A2868A68BB78}.Release|Any CPU.Build.0 = Release|Any CPU
{E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4}.Publish|Any CPU.ActiveCfg = Release|Any CPU
@@ -614,12 +614,6 @@ Global
{B04C26BC-A933-4A53-BE17-7875EB12E012}.Publish|Any CPU.Build.0 = Debug|Any CPU
{B04C26BC-A933-4A53-BE17-7875EB12E012}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B04C26BC-A933-4A53-BE17-7875EB12E012}.Release|Any CPU.Build.0 = Release|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Publish|Any CPU.Build.0 = Debug|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5}.Release|Any CPU.Build.0 = Release|Any CPU
{E6204E79-EFBF-499E-9743-85199310A455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6204E79-EFBF-499E-9743-85199310A455}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6204E79-EFBF-499E-9743-85199310A455}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
@@ -650,13 +644,24 @@ Global
{1D98CF16-5156-40F0-91F0-76294B153DB3}.Publish|Any CPU.Build.0 = Debug|Any CPU
{1D98CF16-5156-40F0-91F0-76294B153DB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D98CF16-5156-40F0-91F0-76294B153DB3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Publish|Any CPU.Build.0 = Debug|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749}.Release|Any CPU.Build.0 = Release|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Publish|Any CPU.Build.0 = Debug|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A284C7EB-2248-4A75-B112-F5DCDE65410D} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0}
- {47C6F821-5103-431F-B3B8-A2868A68BB78} = {A2E102D2-7015-44CD-B8EF-C56758CD37DE}
{E4B777A1-28E1-41BE-96AE-7F3EC61FD5D4} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0}
{F94D1938-9DB7-4B24-9FF3-166DDFD96330} = {D6D598DF-C17C-46F4-B2B9-CDE82E2DE132}
{689A5041-BAE7-448F-9BDC-4672E96249AA} = {D6D598DF-C17C-46F4-B2B9-CDE82E2DE132}
@@ -733,16 +738,16 @@ Global
{91B8BEAF-4ADC-4014-AC6B-C563F41A8DD1} = {6823CD5E-2ABE-41EB-B865-F86EC13F0CF9}
{4DFB3897-0319-4DF2-BCFE-E6E0648297D2} = {958AD708-F048-4FAF-94ED-D2F2B92748B9}
{644A2F10-324D-429E-A1A3-887EAE64207F} = {6823CD5E-2ABE-41EB-B865-F86EC13F0CF9}
- {A2E102D2-7015-44CD-B8EF-C56758CD37DE} = {FA3720F1-C99A-49B2-9577-A940257098BF}
{5D4C0700-BBB5-418F-A7B2-F392B9A18263} = {FA3720F1-C99A-49B2-9577-A940257098BF}
{B04C26BC-A933-4A53-BE17-7875EB12E012} = {FA3720F1-C99A-49B2-9577-A940257098BF}
- {37847DE5-C3B0-41ED-8749-98B9F429B9E5} = {A2E102D2-7015-44CD-B8EF-C56758CD37DE}
{E6204E79-EFBF-499E-9743-85199310A455} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
{CBEEF941-AEC6-42A4-A567-B5641CEFBB87} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
{E12E15F2-6819-46EA-8892-73E3D60BE76F} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
{5C813F83-9FD8-462A-9B38-865CA01C384C} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
{1D98CF16-5156-40F0-91F0-76294B153DB3} = {FA3720F1-C99A-49B2-9577-A940257098BF}
- {DA5C4B1B-7194-402D-9B13-0A8A9D8FEE81} = {FA3720F1-C99A-49B2-9577-A940257098BF}
+ {87DA81FE-112E-4AF5-BEFB-0B91B993F749} = {FA3720F1-C99A-49B2-9577-A940257098BF}
+ {77E141BA-AF5E-4C01-A970-6C07AC3CD55A} = {4D3DAE63-41C6-4E1C-A35A-E77BDFC40675}
+ {925B1185-8B58-4E2D-95C9-4CA0BA9364E5} = {FA3720F1-C99A-49B2-9577-A940257098BF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}
diff --git a/dotnet/samples/Concepts/AgentSyntax/Configuration/ConfigurationException.cs b/dotnet/samples/Concepts/AgentSyntax/Configuration/ConfigurationException.cs
deleted file mode 100644
index f9d3b1d0f725..000000000000
--- a/dotnet/samples/Concepts/AgentSyntax/Configuration/ConfigurationException.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-
-namespace Configuration;
-
-public sealed class ConfigurationException : Exception
-{
- public string? Section { get; }
- public string? Key { get; }
-
- public ConfigurationException(string section, string key)
- : base($"Configuration key '{section}:{key}' not found")
- {
- this.Section = section;
- this.Key = key;
- }
-
- public ConfigurationException(string section)
- : base($"Configuration section '{section}' not found")
- {
- this.Section = section;
- }
-
- public ConfigurationException() : base()
- {
- }
-
- public ConfigurationException(string? message, Exception? innerException) : base(message, innerException)
- {
- }
-}
diff --git a/dotnet/samples/Concepts/AgentSyntax/Configuration/TestConfiguration.cs b/dotnet/samples/Concepts/AgentSyntax/Configuration/TestConfiguration.cs
deleted file mode 100644
index 5d67a9a511e5..000000000000
--- a/dotnet/samples/Concepts/AgentSyntax/Configuration/TestConfiguration.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.Runtime.CompilerServices;
-using Microsoft.Extensions.Configuration;
-
-namespace Configuration;
-
-public sealed class TestConfiguration
-{
- private readonly IConfigurationRoot _configRoot;
- private static TestConfiguration? s_instance;
-
- private TestConfiguration(IConfigurationRoot configRoot)
- {
- this._configRoot = configRoot;
- }
-
- public static void Initialize(IConfigurationRoot configRoot)
- {
- s_instance = new TestConfiguration(configRoot);
- }
-
- public static OpenAIConfig OpenAI => LoadSection();
- public static AzureOpenAIConfig AzureOpenAI => LoadSection();
-
- private static T LoadSection([CallerMemberName] string? caller = null)
- {
- if (s_instance == null)
- {
- throw new InvalidOperationException(
- "TestConfiguration must be initialized with a call to Initialize(IConfigurationRoot) before accessing configuration values.");
- }
-
- if (string.IsNullOrEmpty(caller))
- {
- throw new ArgumentNullException(nameof(caller));
- }
- return s_instance._configRoot.GetSection(caller).Get() ??
- throw new ConfigurationException(section: caller);
- }
-
- public class OpenAIConfig
- {
- public string ModelId { get; set; } = string.Empty;
- public string ChatModelId { get; set; } = string.Empty;
- public string EmbeddingModelId { get; set; } = string.Empty;
- public string ApiKey { get; set; } = string.Empty;
- }
-
- public class AzureOpenAIConfig
- {
- public string ServiceId { get; set; } = string.Empty;
- public string DeploymentName { get; set; } = string.Empty;
- public string ChatDeploymentName { get; set; } = string.Empty;
- public string Endpoint { get; set; } = string.Empty;
- public string ApiKey { get; set; } = string.Empty;
- }
-}
diff --git a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/EmbeddedResource.cs b/dotnet/samples/Concepts/AgentSyntax/RepoUtils/EmbeddedResource.cs
deleted file mode 100644
index f9d9c7f650dc..000000000000
--- a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/EmbeddedResource.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.IO;
-using System.Reflection;
-using System.Threading.Tasks;
-using Configuration;
-
-namespace Resources;
-
-///
-/// Resource helper to load resources embedded in the assembly. By default we embed only
-/// text files, so the helper is limited to returning text.
-///
-/// You can find information about embedded resources here:
-/// * https://learn.microsoft.com/dotnet/core/extensions/create-resource-files
-/// * https://learn.microsoft.com/dotnet/api/system.reflection.assembly.getmanifestresourcestream?view=net-7.0
-///
-/// To know which resources are embedded, check the csproj file.
-///
-internal static class EmbeddedResource
-{
- private static readonly string? s_namespace = typeof(EmbeddedResource).Namespace;
-
- internal static string Read(string fileName)
- {
- // Get the current assembly. Note: this class is in the same assembly where the embedded resources are stored.
- Assembly assembly =
- typeof(EmbeddedResource).GetTypeInfo().Assembly ??
- throw new ConfigurationException($"[{s_namespace}] {fileName} assembly not found");
-
- // Resources are mapped like types, using the namespace and appending "." (dot) and the file name
- var resourceName = $"{s_namespace}." + fileName;
- using Stream resource =
- assembly.GetManifestResourceStream(resourceName) ??
- throw new ConfigurationException($"{resourceName} resource not found");
-
- // Return the resource content, in text format.
- using var reader = new StreamReader(resource);
- return reader.ReadToEnd();
- }
-
- internal static Stream? ReadStream(string fileName)
- {
- // Get the current assembly. Note: this class is in the same assembly where the embedded resources are stored.
- Assembly assembly =
- typeof(EmbeddedResource).GetTypeInfo().Assembly ??
- throw new ConfigurationException($"[{s_namespace}] {fileName} assembly not found");
-
- // Resources are mapped like types, using the namespace and appending "." (dot) and the file name
- var resourceName = $"{s_namespace}." + fileName;
- return assembly.GetManifestResourceStream(resourceName);
- }
-
- internal async static Task> ReadAllAsync(string fileName)
- {
- await using Stream? resourceStream = ReadStream(fileName);
- using var memoryStream = new MemoryStream();
-
- // Copy the resource stream to the memory stream
- await resourceStream!.CopyToAsync(memoryStream);
-
- // Convert the memory stream's buffer to ReadOnlyMemory
- // Note: ToArray() creates a copy of the buffer, which is fine for converting to ReadOnlyMemory
- return new ReadOnlyMemory(memoryStream.ToArray());
- }
-}
diff --git a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/TextOutputHelperExtensions.cs b/dotnet/samples/Concepts/AgentSyntax/RepoUtils/TextOutputHelperExtensions.cs
deleted file mode 100644
index 965afd76045c..000000000000
--- a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/TextOutputHelperExtensions.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using Xunit.Abstractions;
-
-namespace Examples;
-
-public static class TextOutputHelperExtensions
-{
- public static void WriteLine(this ITestOutputHelper testOutputHelper, object target)
- {
- testOutputHelper.WriteLine(target.ToString());
- }
-
- public static void WriteLine(this ITestOutputHelper testOutputHelper)
- {
- testOutputHelper.WriteLine(string.Empty);
- }
-
- public static void Write(this ITestOutputHelper testOutputHelper)
- {
- testOutputHelper.WriteLine(string.Empty);
- }
-
- ///
- /// Current interface ITestOutputHelper does not have a Write method. This extension method adds it to make it analogous to Console.Write when used in Console apps.
- ///
- /// TestOutputHelper
- /// Target object to write
- public static void Write(this ITestOutputHelper testOutputHelper, object target)
- {
- testOutputHelper.WriteLine(target.ToString());
- }
-}
diff --git a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/XunitLogger.cs b/dotnet/samples/Concepts/AgentSyntax/RepoUtils/XunitLogger.cs
deleted file mode 100644
index 77575ac094c9..000000000000
--- a/dotnet/samples/Concepts/AgentSyntax/RepoUtils/XunitLogger.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
-
-namespace RepoUtils;
-
-///
-/// A logger that writes to the Xunit test output
-///
-internal sealed class XunitLogger(ITestOutputHelper output) : ILoggerFactory, ILogger, IDisposable
-{
- ///
- public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter)
- => output.WriteLine(state?.ToString());
-
- ///
- public bool IsEnabled(LogLevel logLevel) => true;
-
- ///
- public IDisposable BeginScope(TState state) where TState : notnull
- => this;
-
- ///
- public void Dispose()
- {
- // This class is marked as disposable to support the BeginScope method.
- // However, there is no need to dispose anything.
- }
-
- public ILogger CreateLogger(string categoryName) => this;
-
- public void AddProvider(ILoggerProvider provider) => throw new NotSupportedException();
-}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example73_AgentAuthoring.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
similarity index 92%
rename from dotnet/samples/KernelSyntaxExamples/Example73_AgentAuthoring.cs
rename to dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
index 2986f87a577d..785fbb247148 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example73_AgentAuthoring.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
@@ -1,18 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Experimental.Agents;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Showcase hiearchical Open AI Agent interactions using semantic kernel.
///
-public class Example73_AgentAuthoring(ITestOutputHelper output) : BaseTest(output)
+public class Legacy_AgentAuthoring(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and parallel function calling.
@@ -26,7 +21,7 @@ public class Example73_AgentAuthoring(ITestOutputHelper output) : BaseTest(outpu
[Fact(Skip = "This test take more than 2 minutes to execute")]
public async Task RunAgentAsync()
{
- WriteLine("======== Example73_AgentAuthoring ========");
+ WriteLine($"======== {nameof(Legacy_AgentAuthoring)} ========");
try
{
// Initialize the agent with tools
@@ -48,7 +43,7 @@ public async Task RunAgentAsync()
[Fact(Skip = "This test take more than 2 minutes to execute")]
public async Task RunAsPluginAsync()
{
- WriteLine("======== Example73_AgentAuthoring ========");
+ WriteLine($"======== {nameof(Legacy_AgentAuthoring)} ========");
try
{
// Initialize the agent with tools
diff --git a/dotnet/samples/KernelSyntaxExamples/Example85_AgentCharts.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentCharts.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example85_AgentCharts.cs
rename to dotnet/samples/Concepts/Agents/Legacy_AgentCharts.cs
index 683d2f53ca75..ed6ddba37ee2 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example85_AgentCharts.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentCharts.cs
@@ -1,13 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.Diagnostics;
-using System.IO;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Experimental.Agents;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -15,7 +10,7 @@ namespace Examples;
///
/// Showcase usage of code_interpreter and retrieval tools.
///
-public sealed class Example85_AgentCharts(ITestOutputHelper output) : BaseTest(output)
+public sealed class Legacy_AgentCharts(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and parallel function calling.
@@ -28,7 +23,7 @@ public sealed class Example85_AgentCharts(ITestOutputHelper output) : BaseTest(o
/// and are defined.
/// If 'false', Azure takes precedence.
///
- private const bool ForceOpenAI = false;
+ private new const bool ForceOpenAI = false;
///
/// Create a chart and retrieve by file_id.
diff --git a/dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentCollaboration.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs
rename to dotnet/samples/Concepts/Agents/Legacy_AgentCollaboration.cs
index d387d4bfa92c..9a487cd8e9f1 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentCollaboration.cs
@@ -1,19 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Experimental.Agents;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Showcase complex Open AI Agent collaboration using semantic kernel.
///
-public class Example72_AgentCollaboration(ITestOutputHelper output) : BaseTest(output)
+public class Legacy_AgentCollaboration(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and function calling.
diff --git a/dotnet/samples/KernelSyntaxExamples/Example71_AgentDelegation.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentDelegation.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example71_AgentDelegation.cs
rename to dotnet/samples/Concepts/Agents/Legacy_AgentDelegation.cs
index 1a1e8f293b4d..2918caa23652 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example71_AgentDelegation.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentDelegation.cs
@@ -1,21 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Experimental.Agents;
using Plugins;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Showcase complex Open AI Agent interactions using semantic kernel.
///
-public class Example71_AgentDelegation(ITestOutputHelper output) : BaseTest(output)
+public class Legacy_AgentDelegation(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and function calling.
diff --git a/dotnet/samples/KernelSyntaxExamples/Example75_AgentTools.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentTools.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example75_AgentTools.cs
rename to dotnet/samples/Concepts/Agents/Legacy_AgentTools.cs
index c0998c3d5ad6..c6f842401cac 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example75_AgentTools.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentTools.cs
@@ -1,15 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Experimental.Agents;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -17,7 +11,7 @@ namespace Examples;
///
/// Showcase usage of code_interpreter and retrieval tools.
///
-public sealed class Example75_AgentTools(ITestOutputHelper output) : BaseTest(output)
+public sealed class Legacy_AgentTools(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and parallel function calling.
@@ -33,7 +27,7 @@ public sealed class Example75_AgentTools(ITestOutputHelper output) : BaseTest(ou
///
/// NOTE: Retrieval tools is not currently available on Azure.
///
- private const bool ForceOpenAI = true;
+ private new const bool ForceOpenAI = true;
// Track agents for clean-up
private readonly List _agents = [];
diff --git a/dotnet/samples/KernelSyntaxExamples/Example70_Agents.cs b/dotnet/samples/Concepts/Agents/Legacy_Agents.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example70_Agents.cs
rename to dotnet/samples/Concepts/Agents/Legacy_Agents.cs
index 9ded157fff61..b3c5f75e9c9a 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example70_Agents.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_Agents.cs
@@ -1,13 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Experimental.Agents;
using Plugins;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -15,7 +11,7 @@ namespace Examples;
/// Showcase Open AI Agent integration with semantic kernel:
/// https://platform.openai.com/docs/api-reference/agents
///
-public class Example70_Agent(ITestOutputHelper output) : BaseTest(output)
+public class Legacy_Agents(ITestOutputHelper output) : BaseTest(output)
{
///
/// Specific model is required that supports agents and function calling.
@@ -28,7 +24,7 @@ public class Example70_Agent(ITestOutputHelper output) : BaseTest(output)
/// and are defined.
/// If 'false', Azure takes precedence.
///
- private const bool ForceOpenAI = false;
+ private new const bool ForceOpenAI = false;
///
/// Chat using the "Parrot" agent.
@@ -58,14 +54,14 @@ public async Task RunWithMethodFunctionsAsync()
{
WriteLine("======== Run:WithMethodFunctions ========");
- MenuPlugin menuApi = new();
+ LegacyMenuPlugin menuApi = new();
KernelPlugin plugin = KernelPluginFactory.CreateFromObject(menuApi);
// Call the common chat-loop
await ChatAsync(
"Agents.ToolAgent.yaml", // Defined under ./Resources/Agents
plugin,
- arguments: new() { { MenuPlugin.CorrelationIdArgument, 3.141592653 } },
+ arguments: new() { { LegacyMenuPlugin.CorrelationIdArgument, 3.141592653 } },
"Hello",
"What is the special soup?",
"What is the special drink?",
diff --git a/dotnet/samples/KernelSyntaxExamples/Example79_ChatCompletionAgent.cs b/dotnet/samples/Concepts/Agents/Legacy_ChatCompletionAgent.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example79_ChatCompletionAgent.cs
rename to dotnet/samples/Concepts/Agents/Legacy_ChatCompletionAgent.cs
index 06231b66d35e..9f13e548d0fc 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example79_ChatCompletionAgent.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_ChatCompletionAgent.cs
@@ -1,21 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
using Kusto.Cloud.Platform.Utils;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Experimental.Agents;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example79_ChatCompletionAgent(ITestOutputHelper output) : BaseTest(output)
+public class Legacy_ChatCompletionAgent(ITestOutputHelper output) : BaseTest(output)
{
///
/// This example demonstrates a chat with the chat completion agent that utilizes the SK ChatCompletion API to communicate with LLM.
diff --git a/dotnet/samples/Concepts/AgentSyntax/MixedChat_Agents.cs b/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs
similarity index 96%
rename from dotnet/samples/Concepts/AgentSyntax/MixedChat_Agents.cs
rename to dotnet/samples/Concepts/Agents/MixedChat_Agents.cs
index c378078024b0..b4f58964399a 100644
--- a/dotnet/samples/Concepts/AgentSyntax/MixedChat_Agents.cs
+++ b/dotnet/samples/Concepts/Agents/MixedChat_Agents.cs
@@ -1,15 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.Agents.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
diff --git a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Agent.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Agent.cs
similarity index 97%
rename from dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Agent.cs
rename to dotnet/samples/Concepts/Agents/OpenAIAssistant_Agent.cs
index f12793bf99f9..716b12a4746b 100644
--- a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Agent.cs
+++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Agent.cs
@@ -1,12 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
using Plugins;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
diff --git a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_ChartMaker.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs
similarity index 97%
rename from dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_ChartMaker.cs
rename to dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs
index a073b6f2610c..810565440c10 100644
--- a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_ChartMaker.cs
+++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs
@@ -1,12 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
diff --git a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_CodeInterpreter.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs
similarity index 96%
rename from dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_CodeInterpreter.cs
rename to dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs
index 77a72eb94180..606fc6c4a29f 100644
--- a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_CodeInterpreter.cs
+++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_CodeInterpreter.cs
@@ -1,11 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
diff --git a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Retrieval.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs
similarity index 96%
rename from dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Retrieval.cs
rename to dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs
index a58d9cc43aa3..a14e7159d4eb 100644
--- a/dotnet/samples/Concepts/AgentSyntax/OpenAIAssistant_Retrieval.cs
+++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs
@@ -1,14 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.OpenAI;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
diff --git a/dotnet/samples/Concepts/AgentSyntax/README.md b/dotnet/samples/Concepts/Agents/README.md
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/README.md
rename to dotnet/samples/Concepts/Agents/README.md
diff --git a/dotnet/samples/KernelSyntaxExamples/Example82_Audio.cs b/dotnet/samples/Concepts/AudioToText/OpenAI_AudioToText.cs
similarity index 56%
rename from dotnet/samples/KernelSyntaxExamples/Example82_Audio.cs
rename to dotnet/samples/Concepts/AudioToText/OpenAI_AudioToText.cs
index e5cb891e5894..068c11e04d4f 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example82_Audio.cs
+++ b/dotnet/samples/Concepts/AudioToText/OpenAI_AudioToText.cs
@@ -1,58 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AudioToText;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Microsoft.SemanticKernel.TextToAudio;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Represents a class that demonstrates audio processing functionality.
///
-public sealed class Example82_Audio(ITestOutputHelper output) : BaseTest(output)
+public sealed class OpenAI_AudioToText(ITestOutputHelper output) : BaseTest(output)
{
- private const string TextToAudioModel = "tts-1";
private const string AudioToTextModel = "whisper-1";
private const string AudioFilename = "test_audio.wav";
- [Fact(Skip = "Uncomment the line to write the audio file output before running this test.")]
- public async Task TextToAudioAsync()
- {
- // Create a kernel with OpenAI text to audio service
- var kernel = Kernel.CreateBuilder()
- .AddOpenAITextToAudio(
- modelId: TextToAudioModel,
- apiKey: TestConfiguration.OpenAI.ApiKey)
- .Build();
-
- var textToAudioService = kernel.GetRequiredService();
-
- string sampleText = "Hello, my name is John. I am a software engineer. I am working on a project to convert text to audio.";
-
- // Set execution settings (optional)
- OpenAITextToAudioExecutionSettings executionSettings = new()
- {
- Voice = "alloy", // The voice to use when generating the audio.
- // Supported voices are alloy, echo, fable, onyx, nova, and shimmer.
- ResponseFormat = "mp3", // The format to audio in.
- // Supported formats are mp3, opus, aac, and flac.
- Speed = 1.0f // The speed of the generated audio.
- // Select a value from 0.25 to 4.0. 1.0 is the default.
- };
-
- // Convert text to audio
- AudioContent audioContent = await textToAudioService.GetAudioContentAsync(sampleText, executionSettings);
-
- // Save audio content to a file
- // await File.WriteAllBytesAsync(AudioFilePath, audioContent.Data!.ToArray());
- }
-
[Fact(Skip = "Setup and run TextToAudioAsync before running this test.")]
public async Task AudioToTextAsync()
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example98_GeminiFunctionCalling.cs b/dotnet/samples/Concepts/AutoFunctionCalling/Gemini_FunctionCalling.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example98_GeminiFunctionCalling.cs
rename to dotnet/samples/Concepts/AutoFunctionCalling/Gemini_FunctionCalling.cs
index fe73b4e9c762..45a2be4ee3f2 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example98_GeminiFunctionCalling.cs
+++ b/dotnet/samples/Concepts/AutoFunctionCalling/Gemini_FunctionCalling.cs
@@ -1,17 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Google;
using xRetry;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public sealed class Example98_GeminiFunctionCalling(ITestOutputHelper output) : BaseTest(output)
+public sealed class Gemini_FunctionCalling(ITestOutputHelper output) : BaseTest(output)
{
[RetryFact]
public async Task GoogleAIAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example59_OpenAIFunctionCalling.cs b/dotnet/samples/Concepts/AutoFunctionCalling/OpenAI_FunctionCalling.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example59_OpenAIFunctionCalling.cs
rename to dotnet/samples/Concepts/AutoFunctionCalling/OpenAI_FunctionCalling.cs
index 9413b2b0e40e..feb42c42584f 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example59_OpenAIFunctionCalling.cs
+++ b/dotnet/samples/Concepts/AutoFunctionCalling/OpenAI_FunctionCalling.cs
@@ -1,21 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use OpenAI's tool calling capability via the chat completions interface.
-public class Example59_OpenAIFunctionCalling(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_FunctionCalling(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example54_AzureChatCompletionWithData.cs b/dotnet/samples/Concepts/ChatCompletion/AzureOpenAIWithData_ChatCompletion.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example54_AzureChatCompletionWithData.cs
rename to dotnet/samples/Concepts/ChatCompletion/AzureOpenAIWithData_ChatCompletion.cs
index 5ee1b10dbc60..1bd9fc859c2d 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example54_AzureChatCompletionWithData.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/AzureOpenAIWithData_ChatCompletion.cs
@@ -1,12 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using xRetry;
-using Xunit.Abstractions;
namespace Examples;
@@ -28,7 +25,7 @@ namespace Examples;
/// dotnet user-secrets set "AzureAISearch:ApiKey" "{Key from your Search service resource}"
/// dotnet user-secrets set "AzureAISearch:IndexName" "..."
///
-public class Example54_AzureChatCompletionWithData(ITestOutputHelper output) : BaseTest(output)
+public class AzureOpenAIWithData_ChatCompletion(ITestOutputHelper output) : BaseTest(output)
{
[RetryFact(typeof(HttpOperationException))]
public async Task ExampleWithChatCompletionAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example37_CompletionIdentity.cs b/dotnet/samples/Concepts/ChatCompletion/ChatHistoryAuthorName.cs
similarity index 91%
rename from dotnet/samples/KernelSyntaxExamples/Example37_CompletionIdentity.cs
rename to dotnet/samples/Concepts/ChatCompletion/ChatHistoryAuthorName.cs
index d9c274d95a25..8e8a708ea781 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example37_CompletionIdentity.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/ChatHistoryAuthorName.cs
@@ -1,18 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-// The following example shows how to use Semantic Kernel with identity associated with each chat message.
-public class Example37_CompletionIdentity(ITestOutputHelper output) : BaseTest(output)
+// The following example shows how to use Chat History with Author identity associated with each chat message.
+public class ChatHistoryAuthorName(ITestOutputHelper output) : BaseTest(output)
{
///
/// Flag to force usage of OpenAI configuration if both
@@ -22,7 +17,7 @@ public class Example37_CompletionIdentity(ITestOutputHelper output) : BaseTest(o
///
/// NOTE: Retrieval tools is not currently available on Azure.
///
- private const bool ForceOpenAI = true;
+ private new const bool ForceOpenAI = true;
private static readonly OpenAIPromptExecutionSettings s_executionSettings =
new()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example87_ChatHistorySerialization.cs b/dotnet/samples/Concepts/ChatCompletion/ChatHistorySerialization.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example87_ChatHistorySerialization.cs
rename to dotnet/samples/Concepts/ChatCompletion/ChatHistorySerialization.cs
index a740e6b66af6..ff1f47792608 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example87_ChatHistorySerialization.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/ChatHistorySerialization.cs
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example87_ChatHistorySerialization(ITestOutputHelper output) : BaseTest(output)
+public class ChatHistorySerialization(ITestOutputHelper output) : BaseTest(output)
{
private static readonly JsonSerializerOptions s_options = new() { WriteIndented = true };
diff --git a/dotnet/samples/Concepts/ChatCompletion/Connectors_CustomHttpClient.cs b/dotnet/samples/Concepts/ChatCompletion/Connectors_CustomHttpClient.cs
new file mode 100644
index 000000000000..466b1ad1e182
--- /dev/null
+++ b/dotnet/samples/Concepts/ChatCompletion/Connectors_CustomHttpClient.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+
+namespace Examples;
+
+// These examples show how to use a custom HttpClient with SK connectors.
+public class Connectors_CustomHttpClient(ITestOutputHelper output) : BaseTest(output)
+{
+ ///
+ /// Demonstrates the usage of the default HttpClient provided by the SK SDK.
+ ///
+ [Fact]
+ public void UseDefaultHttpClient()
+ {
+ var kernel = Kernel.CreateBuilder()
+ .AddOpenAIChatCompletion(
+ modelId: TestConfiguration.OpenAI.ChatModelId,
+ apiKey: TestConfiguration.OpenAI.ApiKey) // If you need to use the default HttpClient from the SK SDK, simply omit the argument for the httpMessageInvoker parameter.
+ .Build();
+ }
+
+ ///
+ /// Demonstrates the usage of a custom HttpClient.
+ ///
+ [Fact]
+ public void UseCustomHttpClient()
+ {
+ using var httpClient = new HttpClient();
+
+ // If you need to use a custom HttpClient, simply pass it as an argument for the httpClient parameter.
+ var kernel = Kernel.CreateBuilder()
+ .AddOpenAIChatCompletion(
+ modelId: TestConfiguration.OpenAI.ModelId,
+ apiKey: TestConfiguration.OpenAI.ApiKey,
+ httpClient: httpClient)
+ .Build();
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example67_KernelStreaming.cs b/dotnet/samples/Concepts/ChatCompletion/Connectors_KernelStreaming.cs
similarity index 87%
rename from dotnet/samples/KernelSyntaxExamples/Example67_KernelStreaming.cs
rename to dotnet/samples/Concepts/ChatCompletion/Connectors_KernelStreaming.cs
index 665eddb67e41..20b752a4abba 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example67_KernelStreaming.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/Connectors_KernelStreaming.cs
@@ -1,19 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-// This example shows how to use multiple prompt template formats.
-public class Example67_KernelStreaming(ITestOutputHelper output) : BaseTest(output)
+///
+/// This example shows how you can use Streaming with Kernel.
+///
+///
+public class Connectors_KernelStreaming(ITestOutputHelper output) : BaseTest(output)
{
- ///
- /// Show how to combine multiple prompt template factories.
- ///
[Fact]
public async Task RunAsync()
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example61_MultipleLLMs.cs b/dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example61_MultipleLLMs.cs
rename to dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
index f8aeddcfbb7e..fd8412d4d0c9 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example61_MultipleLLMs.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using xRetry;
-using Xunit.Abstractions;
namespace Examples;
-public class Example61_MultipleLLMs(ITestOutputHelper output) : BaseTest(output)
+public class Connectors_WithMultipleLLMs(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to run a prompt function and specify a specific service to use.
diff --git a/dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletion.cs
new file mode 100644
index 000000000000..4d286b938172
--- /dev/null
+++ b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletion.cs
@@ -0,0 +1,126 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.ChatCompletion;
+
+namespace Examples;
+
+public sealed class Google_GeminiChatCompletion(ITestOutputHelper output) : BaseTest(output)
+{
+ [Fact]
+ public async Task GoogleAIAsync()
+ {
+ this.WriteLine("============= Google AI - Gemini Chat Completion =============");
+
+ string geminiApiKey = TestConfiguration.GoogleAI.ApiKey;
+ string geminiModelId = TestConfiguration.GoogleAI.Gemini.ModelId;
+
+ if (geminiApiKey is null || geminiModelId is null)
+ {
+ this.WriteLine("Gemini credentials not found. Skipping example.");
+ return;
+ }
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddGoogleAIGeminiChatCompletion(
+ modelId: geminiModelId,
+ apiKey: geminiApiKey)
+ .Build();
+
+ await RunSampleAsync(kernel);
+ }
+
+ [Fact]
+ public async Task VertexAIAsync()
+ {
+ this.WriteLine("============= Vertex AI - Gemini Chat Completion =============");
+
+ string geminiBearerKey = TestConfiguration.VertexAI.BearerKey;
+ string geminiModelId = TestConfiguration.VertexAI.Gemini.ModelId;
+ string geminiLocation = TestConfiguration.VertexAI.Location;
+ string geminiProject = TestConfiguration.VertexAI.ProjectId;
+
+ if (geminiBearerKey is null || geminiModelId is null || geminiLocation is null || geminiProject is null)
+ {
+ this.WriteLine("Gemini vertex ai credentials not found. Skipping example.");
+ return;
+ }
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddVertexAIGeminiChatCompletion(
+ modelId: geminiModelId,
+ bearerKey: geminiBearerKey,
+ location: geminiLocation,
+ projectId: geminiProject)
+ .Build();
+
+ // To generate bearer key, you need installed google sdk or use google web console with command:
+ //
+ // gcloud auth print-access-token
+ //
+ // Above code pass bearer key as string, it is not recommended way in production code,
+ // especially if IChatCompletionService will be long lived, tokens generated by google sdk lives for 1 hour.
+ // You should use bearer key provider, which will be used to generate token on demand:
+ //
+ // Example:
+ //
+ // Kernel kernel = Kernel.CreateBuilder()
+ // .AddVertexAIGeminiChatCompletion(
+ // modelId: TestConfiguration.VertexAI.Gemini.ModelId,
+ // bearerKeyProvider: () =>
+ // {
+ // // This is just example, in production we recommend using Google SDK to generate your BearerKey token.
+ // // This delegate will be called on every request,
+ // // when providing the token consider using caching strategy and refresh token logic when it is expired or close to expiration.
+ // return GetBearerKey();
+ // },
+ // location: TestConfiguration.VertexAI.Location,
+ // projectId: TestConfiguration.VertexAI.ProjectId);
+
+ await RunSampleAsync(kernel);
+ }
+
+ private async Task RunSampleAsync(Kernel kernel)
+ {
+ await SimpleChatAsync(kernel);
+ }
+
+ private async Task SimpleChatAsync(Kernel kernel)
+ {
+ this.WriteLine("======== Simple Chat ========");
+
+ var chatHistory = new ChatHistory();
+ var chat = kernel.GetRequiredService();
+
+ // First user message
+ chatHistory.AddUserMessage("Hi, I'm looking for new power tools, any suggestion?");
+ await MessageOutputAsync(chatHistory);
+
+ // First bot assistant message
+ var reply = await chat.GetChatMessageContentAsync(chatHistory);
+ chatHistory.Add(reply);
+ await MessageOutputAsync(chatHistory);
+
+ // Second user message
+ chatHistory.AddUserMessage("I'm looking for a drill, a screwdriver and a hammer.");
+ await MessageOutputAsync(chatHistory);
+
+ // Second bot assistant message
+ reply = await chat.GetChatMessageContentAsync(chatHistory);
+ chatHistory.Add(reply);
+ await MessageOutputAsync(chatHistory);
+ }
+
+ ///
+ /// Outputs the last message of the chat history
+ ///
+ private Task MessageOutputAsync(ChatHistory chatHistory)
+ {
+ var message = chatHistory.Last();
+
+ this.WriteLine($"{message.Role}: {message.Content}");
+ this.WriteLine("------------------------");
+
+ return Task.CompletedTask;
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example96_GeminiChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletionStreaming.cs
similarity index 81%
rename from dotnet/samples/KernelSyntaxExamples/Example96_GeminiChatCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletionStreaming.cs
index 7f63adf188e3..8dee33d70928 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example96_GeminiChatCompletion.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiChatCompletionStreaming.cs
@@ -1,17 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public sealed class Example96_GeminiChatCompletion(ITestOutputHelper output) : BaseTest(output)
+public sealed class Google_GeminiChatCompletionStreaming(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task GoogleAIAsync()
@@ -88,7 +83,6 @@ public async Task VertexAIAsync()
private async Task RunSampleAsync(Kernel kernel)
{
- await SimpleChatAsync(kernel);
await StreamingChatAsync(kernel);
}
@@ -118,32 +112,6 @@ private async Task StreamingChatAsync(Kernel kernel)
chatHistory.Add(reply);
}
- private async Task SimpleChatAsync(Kernel kernel)
- {
- this.WriteLine("======== Simple Chat ========");
-
- var chatHistory = new ChatHistory();
- var chat = kernel.GetRequiredService();
-
- // First user message
- chatHistory.AddUserMessage("Hi, I'm looking for new power tools, any suggestion?");
- await MessageOutputAsync(chatHistory);
-
- // First bot assistant message
- var reply = await chat.GetChatMessageContentAsync(chatHistory);
- chatHistory.Add(reply);
- await MessageOutputAsync(chatHistory);
-
- // Second user message
- chatHistory.AddUserMessage("I'm looking for a drill, a screwdriver and a hammer.");
- await MessageOutputAsync(chatHistory);
-
- // Second bot assistant message
- reply = await chat.GetChatMessageContentAsync(chatHistory);
- chatHistory.Add(reply);
- await MessageOutputAsync(chatHistory);
- }
-
///
/// Outputs the last message of the chat history
///
diff --git a/dotnet/samples/KernelSyntaxExamples/Example95_GeminiGetModelResult.cs b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiGetModelResult.cs
similarity index 93%
rename from dotnet/samples/KernelSyntaxExamples/Example95_GeminiGetModelResult.cs
rename to dotnet/samples/Concepts/ChatCompletion/Google_GeminiGetModelResult.cs
index d8fef80ea6b3..52e4f95faff7 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example95_GeminiGetModelResult.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiGetModelResult.cs
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Google;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Represents an example class for Gemini Embedding Generation with volatile memory store.
///
-public sealed class Example95_GeminiGetModelResult(ITestOutputHelper output) : BaseTest(output)
+public sealed class Google_GeminiGetModelResult(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task GetTokenUsageMetadataAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example97_GeminiVision.cs b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiVision.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example97_GeminiVision.cs
rename to dotnet/samples/Concepts/ChatCompletion/Google_GeminiVision.cs
index 38c5ffdadcc6..f4b9253b3249 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example97_GeminiVision.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/Google_GeminiVision.cs
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.IO;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public sealed class Example97_GeminiVision(ITestOutputHelper output) : BaseTest(output)
+public sealed class Google_GeminiVision(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task GoogleAIAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example17_ChatGPT.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example17_ChatGPT.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
index d65d80b1ed86..f59abddc0bce 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example17_ChatGPT.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to use Semantic Kernel with OpenAI ChatGPT API
-public class Example17_ChatGPT(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletion(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task OpenAIChatSampleAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example36_MultiCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionMultipleChoices.cs
similarity index 92%
rename from dotnet/samples/KernelSyntaxExamples/Example36_MultiCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionMultipleChoices.cs
index 92d5c748ff1f..0f155f1a98a3 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example36_MultiCompletion.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionMultipleChoices.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to use Semantic Kernel with streaming Multiple Results Chat Completion.
-public class Example36_MultiCompletion(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletionMultipleChoices(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public Task AzureOpenAIMultiChatCompletionAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example33_StreamingChat.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreaming.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example33_StreamingChat.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreaming.cs
index a0e3bc987757..d618ba0564f2 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example33_StreamingChat.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreaming.cs
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to use Semantic Kernel with streaming Chat Completion
-public class Example33_StreamingChat(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletionStreaming(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public Task OpenAIChatStreamSampleAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example45_MultiStreamingChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreamingMultipleChoices.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example45_MultiStreamingChatCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreamingMultipleChoices.cs
index e1ccaa84436a..ec68868eadda 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example45_MultiStreamingChatCompletion.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreamingMultipleChoices.cs
@@ -1,18 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to use Semantic Kernel with multiple streaming chat completion results.
-public class Example45_MultiStreamingChatCompletion(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletionStreamingMultipleChoices(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public Task AzureOpenAIMultiStreamingChatCompletionAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example68_GPTVision.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionWithVision.cs
similarity index 86%
rename from dotnet/samples/KernelSyntaxExamples/Example68_GPTVision.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionWithVision.cs
index fb98dd7a5423..6ff3e0d025b6 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example68_GPTVision.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionWithVision.cs
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use GPT Vision model with different content types (text and image).
-public class Example68_GPTVision(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletionWithVision(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example52_CustomOpenAIClient.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_CustomAzureOpenAIClient.cs
similarity index 88%
rename from dotnet/samples/KernelSyntaxExamples/Example52_CustomOpenAIClient.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_CustomAzureOpenAIClient.cs
index 1457a32c8268..cc40f8f85cdf 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example52_CustomOpenAIClient.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_CustomAzureOpenAIClient.cs
@@ -1,20 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
using Azure;
using Azure.AI.OpenAI;
using Azure.Core.Pipeline;
using Microsoft.SemanticKernel;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public sealed class Example52_CustomOpenAIClient(ITestOutputHelper output) : BaseTest(output)
+public sealed class OpenAI_CustomAzureOpenAIClient(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example49_LogitBias.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_UsingLogitBias.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example49_LogitBias.cs
rename to dotnet/samples/Concepts/ChatCompletion/OpenAI_UsingLogitBias.cs
index f2ba1ea07223..f850ba023583 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example49_LogitBias.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_UsingLogitBias.cs
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -13,7 +9,7 @@ namespace Examples;
* Logit_bias is an optional parameter that modifies the likelihood of specified tokens appearing in a Completion.
* When using the Token Selection Biases parameter, the bias is added to the logits generated by the model prior to sampling.
*/
-public class Example49_LogitBias(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_UsingLogitBias(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/KernelSyntax.csproj b/dotnet/samples/Concepts/Concepts.csproj
similarity index 82%
rename from dotnet/samples/KernelSyntaxExamples/KernelSyntax.csproj
rename to dotnet/samples/Concepts/Concepts.csproj
index 3cb85526f47e..31be3a10499e 100644
--- a/dotnet/samples/KernelSyntaxExamples/KernelSyntax.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -1,21 +1,24 @@
-
+
+
- 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
-
- KernelSyntax
+ Conceptsnet8.0
- true
+ enablefalse
+ true
- CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101
+ CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
+ false
+
+ runtime; build; native; contentfiles; analyzers; buildtransitiveall
@@ -36,42 +39,57 @@
+
+
+
+
+
+
-
-
+
+
+
+
-
-
+
+
+
+
-
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
-
+ PreserveNewest
@@ -79,6 +97,5 @@
Always
-
-
\ No newline at end of file
+
diff --git a/dotnet/samples/KernelSyntaxExamples/Example41_HttpClientUsage.cs b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Registration.cs
similarity index 63%
rename from dotnet/samples/KernelSyntaxExamples/Example41_HttpClientUsage.cs
rename to dotnet/samples/Concepts/DependencyInjection/HttpClient_Registration.cs
index 5cda7cfe27b8..a5c598ae772c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example41_HttpClientUsage.cs
+++ b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Registration.cs
@@ -1,47 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Net.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// These examples show how to use HttpClient and HttpClientFactory within SK SDK.
-public class Example41_HttpClientUsage(ITestOutputHelper output) : BaseTest(output)
+public class HttpClient_Registration(ITestOutputHelper output) : BaseTest(output)
{
- ///
- /// Demonstrates the usage of the default HttpClient provided by the SK SDK.
- ///
- [Fact]
- public void UseDefaultHttpClient()
- {
- var kernel = Kernel.CreateBuilder()
- .AddOpenAIChatCompletion(
- modelId: TestConfiguration.OpenAI.ChatModelId,
- apiKey: TestConfiguration.OpenAI.ApiKey) // If you need to use the default HttpClient from the SK SDK, simply omit the argument for the httpMessageInvoker parameter.
- .Build();
- }
-
- ///
- /// Demonstrates the usage of a custom HttpClient.
- ///
- [Fact]
- public void UseCustomHttpClient()
- {
- using var httpClient = new HttpClient();
-
- // If you need to use a custom HttpClient, simply pass it as an argument for the httpClient parameter.
- var kernel = Kernel.CreateBuilder()
- .AddOpenAIChatCompletion(
- modelId: TestConfiguration.OpenAI.ModelId,
- apiKey: TestConfiguration.OpenAI.ApiKey,
- httpClient: httpClient)
- .Build();
- }
-
///
/// Demonstrates the "basic usage" approach for HttpClientFactory.
///
diff --git a/dotnet/samples/KernelSyntaxExamples/Example08_RetryHandler.cs b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
similarity index 85%
rename from dotnet/samples/KernelSyntaxExamples/Example08_RetryHandler.cs
rename to dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
index 9658574ff343..eb4e26c7cb48 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example08_RetryHandler.cs
+++ b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
@@ -1,20 +1,19 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.Net;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-// This example shows how to use a retry handler within a Semantic Kernel
-public class Example08_RetryHandler(ITestOutputHelper output) : BaseTest(output)
+// These examples show how to use HttpClient and HttpClientFactory within SK SDK.
+public class HttpClient_Resiliency(ITestOutputHelper output) : BaseTest(output)
{
+ ///
+ /// Demonstrates the usage of the HttpClientFactory with a custom resilience policy.
+ ///
[Fact]
public async Task RunAsync()
{
@@ -32,7 +31,7 @@ public async Task RunAsync()
builder.Services.AddOpenAIChatCompletion("gpt-4", "BAD_KEY"); // OpenAI settings - you can set the OpenAI.ApiKey to an invalid value to see the retry policy in play
Kernel kernel = builder.Build();
- var logger = kernel.LoggerFactory.CreateLogger(typeof(Example08_RetryHandler));
+ var logger = kernel.LoggerFactory.CreateLogger(typeof(HttpClient_Resiliency));
const string Question = "How do I add a standard resilience handler in IHttpClientBuilder??";
logger.LogInformation("Question: {Question}", Question);
diff --git a/dotnet/samples/KernelSyntaxExamples/Example42_KernelBuilder.cs b/dotnet/samples/Concepts/DependencyInjection/Kernel_Building.cs
similarity index 79%
rename from dotnet/samples/KernelSyntaxExamples/Example42_KernelBuilder.cs
rename to dotnet/samples/Concepts/DependencyInjection/Kernel_Building.cs
index d58f1f61f9a8..ac5a5b252fdb 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example42_KernelBuilder.cs
+++ b/dotnet/samples/Concepts/DependencyInjection/Kernel_Building.cs
@@ -9,27 +9,11 @@
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example42_KernelBuilder(ITestOutputHelper output) : BaseTest(output)
+public class Kernel_Building(ITestOutputHelper output) : BaseTest(output)
{
- [Fact]
- public void BuildKernelWithAzureChatCompletion()
- {
- // KernelBuilder provides a simple way to configure a Kernel. This constructs a kernel
- // with logging and an Azure OpenAI chat completion service configured.
- Kernel kernel1 = Kernel.CreateBuilder()
- .AddAzureOpenAIChatCompletion(
- deploymentName: TestConfiguration.AzureOpenAI.ChatDeploymentName,
- endpoint: TestConfiguration.AzureOpenAI.Endpoint,
- apiKey: TestConfiguration.AzureOpenAI.ApiKey,
- modelId: TestConfiguration.AzureOpenAI.ChatModelId)
- .Build();
- }
-
[Fact]
public void BuildKernelUsingServiceCollection()
{
@@ -46,15 +30,6 @@ public void BuildKernelUsingServiceCollection()
Kernel kernel2 = builder.Build();
}
- [Fact]
- public void BuildKernelWithPlugins()
- {
- // Plugins may also be configured via the corresponding Plugins property.
- var builder = Kernel.CreateBuilder();
- builder.Plugins.AddFromType();
- Kernel kernel3 = builder.Build();
- }
-
[Fact]
public void BuildKernelUsingServiceProvider()
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example40_DIContainer.cs b/dotnet/samples/Concepts/DependencyInjection/Kernel_Injecting.cs
similarity index 89%
rename from dotnet/samples/KernelSyntaxExamples/Example40_DIContainer.cs
rename to dotnet/samples/Concepts/DependencyInjection/Kernel_Injecting.cs
index 8c8f13f7717d..c2a0456a4510 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example40_DIContainer.cs
+++ b/dotnet/samples/Concepts/DependencyInjection/Kernel_Injecting.cs
@@ -1,24 +1,19 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.IO;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following examples show how to use SK SDK in applications using DI/IoC containers.
-public class Example40_DIContainer(ITestOutputHelper output) : BaseTest(output)
+public class Kernel_Injecting(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
{
var collection = new ServiceCollection();
- collection.AddSingleton(ConsoleLogger.LoggerFactory);
+ collection.AddLogging(c => c.AddConsole().SetMinimumLevel(LogLevel.Information));
collection.AddOpenAITextGeneration(TestConfiguration.OpenAI.ModelId, TestConfiguration.OpenAI.ApiKey);
collection.AddSingleton();
diff --git a/dotnet/samples/KernelSyntaxExamples/Example76_Filters.cs b/dotnet/samples/Concepts/Filtering/Filters.cs
similarity index 98%
rename from dotnet/samples/KernelSyntaxExamples/Example76_Filters.cs
rename to dotnet/samples/Concepts/Filtering/Filters.cs
index 5a1ea57829b5..906a91874836 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example76_Filters.cs
+++ b/dotnet/samples/Concepts/Filtering/Filters.cs
@@ -1,20 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example76_Filters(ITestOutputHelper output) : BaseTest(output)
+public class Filters(ITestOutputHelper output) : BaseTest(output)
{
///
/// Shows how to use function and prompt filters in Kernel.
diff --git a/dotnet/samples/KernelSyntaxExamples/Example57_KernelHooks.cs b/dotnet/samples/Concepts/Filtering/Legacy_KernelHooks.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example57_KernelHooks.cs
rename to dotnet/samples/Concepts/Filtering/Legacy_KernelHooks.cs
index d0e33e991d83..73b4cf9246b4 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example57_KernelHooks.cs
+++ b/dotnet/samples/Concepts/Filtering/Legacy_KernelHooks.cs
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Text.RegularExpressions;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
#pragma warning disable CS0618 // Events are deprecated
-public class Example57_KernelHooks : BaseTest
+public class Legacy_KernelHooks : BaseTest
{
///
/// Demonstrate using kernel invocation-hooks to monitor usage:
@@ -268,7 +264,7 @@ public async Task AfterInvokeCancellationAsync()
private readonly string? _openAIModelId;
private readonly string? _openAIApiKey;
- public Example57_KernelHooks(ITestOutputHelper output) : base(output)
+ public Legacy_KernelHooks(ITestOutputHelper output) : base(output)
{
this._openAIModelId = TestConfiguration.OpenAI.ChatModelId;
this._openAIApiKey = TestConfiguration.OpenAI.ApiKey;
diff --git a/dotnet/samples/KernelSyntaxExamples/Example03_Arguments.cs b/dotnet/samples/Concepts/Functions/Arguments.cs
similarity index 70%
rename from dotnet/samples/KernelSyntaxExamples/Example03_Arguments.cs
rename to dotnet/samples/Concepts/Functions/Arguments.cs
index 4a58545edd82..f08d3b78fbe5 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example03_Arguments.cs
+++ b/dotnet/samples/Concepts/Functions/Arguments.cs
@@ -1,16 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
+using System.ComponentModel;
using System.Globalization;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Plugins;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use kernel arguments when invoking functions.
-public class Example03_Arguments(ITestOutputHelper output) : BaseTest(output)
+public class Arguments(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
@@ -42,4 +38,17 @@ public async Task RunAsync()
// FunctionResult.ToString() automatically converts the result to string
this.WriteLine($"FunctionResult.ToString() -> {functionResult}");
}
+
+ public sealed class StaticTextPlugin
+ {
+ [KernelFunction, Description("Change all string chars to uppercase")]
+ public static string Uppercase([Description("Text to uppercase")] string input) =>
+ input.ToUpperInvariant();
+
+ [KernelFunction, Description("Append the day variable")]
+ public static string AppendDay(
+ [Description("Text to append to")] string input,
+ [Description("Value of the day to append")] string day) =>
+ input + day;
+ }
}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example43_GetModelResult.cs b/dotnet/samples/Concepts/Functions/FunctionResult_Metadata.cs
similarity index 93%
rename from dotnet/samples/KernelSyntaxExamples/Example43_GetModelResult.cs
rename to dotnet/samples/Concepts/Functions/FunctionResult_Metadata.cs
index 83feac650734..205c3e71ebe3 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example43_GetModelResult.cs
+++ b/dotnet/samples/Concepts/Functions/FunctionResult_Metadata.cs
@@ -1,14 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example43_GetModelResult(ITestOutputHelper output) : BaseTest(output)
+public class FunctionResult_Metadata(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task GetTokenUsageMetadataAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example77_StronglyTypedFunctionResult.cs b/dotnet/samples/Concepts/Functions/FunctionResult_StronglyTyped.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example77_StronglyTypedFunctionResult.cs
rename to dotnet/samples/Concepts/Functions/FunctionResult_StronglyTyped.cs
index 637ad36b7d30..883b978c8df4 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example77_StronglyTypedFunctionResult.cs
+++ b/dotnet/samples/Concepts/Functions/FunctionResult_StronglyTyped.cs
@@ -1,20 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json;
-using System.Threading.Tasks;
using Azure.AI.OpenAI;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to receive the results from the kernel in a strongly typed object
// which stores the usage in tokens and converts the JSON result to a strongly typed object, where a validation can also
// be performed
-public class Example77_StronglyTypedFunctionResult(ITestOutputHelper output) : BaseTest(output)
+public class FunctionResult_StronglyTyped(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example01_MethodFunctions.cs b/dotnet/samples/Concepts/Functions/MethodFunctions.cs
similarity index 74%
rename from dotnet/samples/KernelSyntaxExamples/Example01_MethodFunctions.cs
rename to dotnet/samples/Concepts/Functions/MethodFunctions.cs
index 16c0afe8a383..a25970c4bef3 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example01_MethodFunctions.cs
+++ b/dotnet/samples/Concepts/Functions/MethodFunctions.cs
@@ -1,13 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example01_MethodFunctions(ITestOutputHelper output) : BaseTest(output)
+public class MethodFunctions(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example60_AdvancedMethodFunctions.cs b/dotnet/samples/Concepts/Functions/MethodFunctions_Advanced.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example60_AdvancedMethodFunctions.cs
rename to dotnet/samples/Concepts/Functions/MethodFunctions_Advanced.cs
index 5581b8ce6cf8..83581875d093 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example60_AdvancedMethodFunctions.cs
+++ b/dotnet/samples/Concepts/Functions/MethodFunctions_Advanced.cs
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
using System.Globalization;
using System.Text.Json;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows different ways how to define and execute method functions using custom and primitive types.
-public class Example60_AdvancedMethodFunctions(ITestOutputHelper output) : BaseTest(output)
+public class MethodFunctions_Advanced(ITestOutputHelper output) : BaseTest(output)
{
#region Method Functions Chaining
diff --git a/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs b/dotnet/samples/Concepts/Functions/MethodFunctions_Types.cs
similarity index 98%
rename from dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs
rename to dotnet/samples/Concepts/Functions/MethodFunctions_Types.cs
index 2c25f30bd250..c45550e75b4e 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs
+++ b/dotnet/samples/Concepts/Functions/MethodFunctions_Types.cs
@@ -1,22 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
using System.Globalization;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example09_FunctionTypes(ITestOutputHelper output) : BaseTest(output)
+public class MethodFunctions_Types(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example05_InlineFunctionDefinition.cs b/dotnet/samples/Concepts/Functions/PromptFunctions_Inline.cs
similarity index 92%
rename from dotnet/samples/KernelSyntaxExamples/Example05_InlineFunctionDefinition.cs
rename to dotnet/samples/Concepts/Functions/PromptFunctions_Inline.cs
index 01795f90dcaf..bc2e0df6d05a 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example05_InlineFunctionDefinition.cs
+++ b/dotnet/samples/Concepts/Functions/PromptFunctions_Inline.cs
@@ -1,15 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example05_InlineFunctionDefinition(ITestOutputHelper output) : BaseTest(output)
+public class PromptFunctions_Inline(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example56_TemplateMethodFunctionsWithMultipleArguments.cs b/dotnet/samples/Concepts/Functions/PromptFunctions_MultipleArguments.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example56_TemplateMethodFunctionsWithMultipleArguments.cs
rename to dotnet/samples/Concepts/Functions/PromptFunctions_MultipleArguments.cs
index a587493601aa..f934ec6ede9c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example56_TemplateMethodFunctionsWithMultipleArguments.cs
+++ b/dotnet/samples/Concepts/Functions/PromptFunctions_MultipleArguments.cs
@@ -1,17 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example56_TemplateMethodFunctionsWithMultipleArguments(ITestOutputHelper output) : BaseTest(output)
+public class PromptFunctions_MultipleArguments(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to invoke a Method Function written in C# with multiple arguments
diff --git a/dotnet/samples/KernelSyntaxExamples/Example86_ImageToText.cs b/dotnet/samples/Concepts/ImageToText/HuggingFace_ImageToText.cs
similarity index 89%
rename from dotnet/samples/KernelSyntaxExamples/Example86_ImageToText.cs
rename to dotnet/samples/Concepts/ImageToText/HuggingFace_ImageToText.cs
index 254fa99dbb64..93ff9c30978c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example86_ImageToText.cs
+++ b/dotnet/samples/Concepts/ImageToText/HuggingFace_ImageToText.cs
@@ -1,20 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.HuggingFace;
using Microsoft.SemanticKernel.ImageToText;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Represents a class that demonstrates image-to-text functionality.
///
-public sealed class Example86_ImageToText(ITestOutputHelper output) : BaseTest(output)
+public sealed class HuggingFace_ImageToText(ITestOutputHelper output) : BaseTest(output)
{
private const string ImageToTextModel = "Salesforce/blip-image-captioning-base";
private const string ImageFilePath = "test_image.jpg";
diff --git a/dotnet/samples/Concepts/Kernel/BuildingKernel.cs b/dotnet/samples/Concepts/Kernel/BuildingKernel.cs
new file mode 100644
index 000000000000..b0ce23d5689f
--- /dev/null
+++ b/dotnet/samples/Concepts/Kernel/BuildingKernel.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+// ==========================================================================================================
+// The easier way to instantiate the Semantic Kernel is to use KernelBuilder.
+// You can access the builder using Kernel.CreateBuilder().
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Plugins.Core;
+
+namespace Examples;
+
+public class BuildingKernel(ITestOutputHelper output) : BaseTest(output)
+{
+ [Fact]
+ public void BuildKernelWithAzureChatCompletion()
+ {
+ // KernelBuilder provides a simple way to configure a Kernel. This constructs a kernel
+ // with logging and an Azure OpenAI chat completion service configured.
+ Kernel kernel1 = Kernel.CreateBuilder()
+ .AddAzureOpenAIChatCompletion(
+ deploymentName: TestConfiguration.AzureOpenAI.ChatDeploymentName,
+ endpoint: TestConfiguration.AzureOpenAI.Endpoint,
+ apiKey: TestConfiguration.AzureOpenAI.ApiKey,
+ modelId: TestConfiguration.AzureOpenAI.ChatModelId)
+ .Build();
+ }
+
+ [Fact]
+ public void BuildKernelWithPlugins()
+ {
+ // Plugins may also be configured via the corresponding Plugins property.
+ var builder = Kernel.CreateBuilder();
+ builder.Plugins.AddFromType();
+ Kernel kernel3 = builder.Build();
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example58_ConfigureExecutionSettings.cs b/dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
similarity index 93%
rename from dotnet/samples/KernelSyntaxExamples/Example58_ConfigureExecutionSettings.cs
rename to dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
index 618856ef134e..79f3fd06e36f 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example58_ConfigureExecutionSettings.cs
+++ b/dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Text.Json;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public sealed class Example58_ConfigureExecutionSettings(ITestOutputHelper output) : BaseTest(output)
+public sealed class ConfigureExecutionSettings(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to configure model execution settings
@@ -17,7 +14,7 @@ public sealed class Example58_ConfigureExecutionSettings(ITestOutputHelper outpu
[Fact]
public async Task RunAsync()
{
- this.WriteLine("======== Example58_ConfigureExecutionSettings ========");
+ this.WriteLine("======== ConfigureExecutionSettings ========");
string serviceId = TestConfiguration.AzureOpenAI.ServiceId;
string apiKey = TestConfiguration.AzureOpenAI.ApiKey;
diff --git a/dotnet/samples/KernelSyntaxExamples/Example62_CustomAIServiceSelector.cs b/dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
similarity index 92%
rename from dotnet/samples/KernelSyntaxExamples/Example62_CustomAIServiceSelector.cs
rename to dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
index 155c7aa3aab0..bbba5274ccdd 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example62_CustomAIServiceSelector.cs
+++ b/dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.Diagnostics.CodeAnalysis;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Services;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example62_CustomAIServiceSelector(ITestOutputHelper output) : BaseTest(output)
+public class CustomAIServiceSelector(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to use a custom AI service selector to select a specific model
@@ -20,7 +16,7 @@ public class Example62_CustomAIServiceSelector(ITestOutputHelper output) : BaseT
[Fact]
public async Task RunAsync()
{
- WriteLine("======== Example62_CustomAIServiceSelector ========");
+ WriteLine($"======== {nameof(CustomAIServiceSelector)} ========");
// Build a kernel with multiple chat completion services
var builder = Kernel.CreateBuilder()
diff --git a/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs b/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs
new file mode 100644
index 000000000000..97bcfb1c07e2
--- /dev/null
+++ b/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs
@@ -0,0 +1,89 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.ChatCompletion;
+
+#pragma warning disable format // Format item can be simplified
+#pragma warning disable CA1861 // Avoid constant arrays as arguments
+
+namespace Examples;
+
+// The following example shows how to use Semantic Kernel with HuggingFace API.
+public class HuggingFace_ChatCompletionWithTGI(ITestOutputHelper output) : BaseTest(output)
+{
+ ///
+ /// Follow steps in to setup HuggingFace local Text Generation Inference HTTP server.
+ ///
+ [Fact(Skip = "Requires TGI (text generation inference) deployment")]
+ public async Task RunTGI_ChatCompletionAsync()
+ {
+ WriteLine("\n======== HuggingFace - TGI Chat Completion ========\n");
+
+ // This example was run against one of the chat completion (Message API) supported models from HuggingFace, listed in here:
+ // Starting a Local Docker i.e:
+ // docker run --gpus all --shm-size 1g -p 8080:80 -v "F:\temp\huggingface:/data" ghcr.io/huggingface/text-generation-inference:1.4 --model-id teknium/OpenHermes-2.5-Mistral-7B
+
+ // HuggingFace local HTTP server endpoint
+ var endpoint = new Uri("http://localhost:8080");
+
+ const string Model = "teknium/OpenHermes-2.5-Mistral-7B";
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceChatCompletion(
+ model: Model,
+ endpoint: endpoint)
+ .Build();
+
+ var chatCompletion = kernel.GetRequiredService();
+ var chatHistory = new ChatHistory("You are a helpful assistant.")
+ {
+ new ChatMessageContent(AuthorRole.User, "What is deep learning?")
+ };
+
+ var result = await chatCompletion.GetChatMessageContentAsync(chatHistory);
+
+ WriteLine(result.Role);
+ WriteLine(result.Content);
+ }
+
+ ///
+ /// Follow steps in to setup HuggingFace local Text Generation Inference HTTP server.
+ ///
+ [Fact(Skip = "Requires TGI (text generation inference) deployment")]
+ public async Task RunTGI_StreamingChatCompletionAsync()
+ {
+ WriteLine("\n======== HuggingFace - TGI Chat Completion Streaming ========\n");
+
+ // This example was run against one of the chat completion (Message API) supported models from HuggingFace, listed in here:
+ // Starting a Local Docker i.e:
+ // docker run --gpus all --shm-size 1g -p 8080:80 -v "F:\temp\huggingface:/data" ghcr.io/huggingface/text-generation-inference:1.4 --model-id teknium/OpenHermes-2.5-Mistral-7B
+
+ // HuggingFace local HTTP server endpoint
+ var endpoint = new Uri("http://localhost:8080");
+
+ const string Model = "teknium/OpenHermes-2.5-Mistral-7B";
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceChatCompletion(
+ model: Model,
+ endpoint: endpoint)
+ .Build();
+
+ var chatCompletion = kernel.GetRequiredService();
+ var chatHistory = new ChatHistory("You are a helpful assistant.")
+ {
+ new ChatMessageContent(AuthorRole.User, "What is deep learning?")
+ };
+
+ AuthorRole? role = null;
+ await foreach (var chatMessageChunk in chatCompletion.GetStreamingChatMessageContentsAsync(chatHistory))
+ {
+ if (role is null)
+ {
+ role = chatMessageChunk.Role;
+ Write(role);
+ }
+ Write(chatMessageChunk.Content);
+ }
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example88_CustomMessageAPIEndpoint.cs b/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example88_CustomMessageAPIEndpoint.cs
rename to dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
index 11414bce43c2..73dcecdb068c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example88_CustomMessageAPIEndpoint.cs
+++ b/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -32,7 +28,7 @@ namespace Examples;
/// 2. docker run -ti -p 8080:8080 localai/localai:v2.12.3-ffmpeg-core phi-2
/// 3. Run the LocalAI examples.
///
-public class Example88_CustomMessageAPIEndpoint : BaseTest
+public class MultipleProviders_ChatCompletion(ITestOutputHelper output) : BaseTest(output)
{
[Theory(Skip = "Manual configuration needed")]
[InlineData("LMStudio", "http://localhost:1234", "llama2")] // Setup Llama2 as the model in LM Studio UI and start the Message API Server on http://localhost:1234
@@ -96,8 +92,4 @@ Sign the mail as AI Assistant.
this.WriteLine(word);
};
}
-
- public Example88_CustomMessageAPIEndpoint(ITestOutputHelper output) : base(output)
- {
- }
}
diff --git a/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs b/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs
new file mode 100644
index 000000000000..d960d707cf46
--- /dev/null
+++ b/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs
@@ -0,0 +1,33 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Embeddings;
+using xRetry;
+
+#pragma warning disable format // Format item can be simplified
+#pragma warning disable CA1861 // Avoid constant arrays as arguments
+
+namespace Examples;
+
+// The following example shows how to use Semantic Kernel with HuggingFace API.
+public class HuggingFace_EmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
+{
+ [RetryFact(typeof(HttpOperationException))]
+ public async Task RunInferenceApiEmbeddingAsync()
+ {
+ this.WriteLine("\n======= Hugging Face Inference API - Embedding Example ========\n");
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceTextEmbeddingGeneration(
+ model: TestConfiguration.HuggingFace.EmbeddingModelId,
+ apiKey: TestConfiguration.HuggingFace.ApiKey)
+ .Build();
+
+ var embeddingGenerator = kernel.GetRequiredService();
+
+ // Generate embeddings for each chunk.
+ var embeddings = await embeddingGenerator.GenerateEmbeddingsAsync(["John: Hello, how are you?\nRoger: Hey, I'm Roger!"]);
+
+ this.WriteLine($"Generated {embeddings.Count} embeddings for the provided text");
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example25_ReadOnlyMemoryStore.cs b/dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example25_ReadOnlyMemoryStore.cs
rename to dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
index def7cbd96bca..c6e7c2791176 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example25_ReadOnlyMemoryStore.cs
+++ b/dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
@@ -1,17 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Numerics.Tensors;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Memory;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -22,7 +15,7 @@ namespace Examples;
/// of has a single collection, and thus does not need to be named.
/// It also assumes that the JSON formatted data can be deserialized into objects.
///
-public class Example25_ReadOnlyMemoryStore(ITestOutputHelper output) : BaseTest(output)
+public class MemoryStore_CustomReadOnly(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example14_SemanticMemory.cs b/dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example14_SemanticMemory.cs
rename to dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
index 14691b06f9cd..00a318533137 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example14_SemanticMemory.cs
+++ b/dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
@@ -1,13 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.AzureAISearch;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -19,7 +14,7 @@ namespace Examples;
* Semantic Memory allows to store your data like traditional DBs,
* adding the ability to query it using natural language.
*/
-public class Example14_SemanticMemory(ITestOutputHelper output) : BaseTest(output)
+public class SemanticTextMemory_Building(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "SKGitHub";
diff --git a/dotnet/samples/KernelSyntaxExamples/Example55_TextChunker.cs b/dotnet/samples/Concepts/Memory/TextChunkerUsage.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example55_TextChunker.cs
rename to dotnet/samples/Concepts/Memory/TextChunkerUsage.cs
index 93ef5e90b8e8..b4f8eb65f763 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example55_TextChunker.cs
+++ b/dotnet/samples/Concepts/Memory/TextChunkerUsage.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.ML.Tokenizers;
using Microsoft.SemanticKernel.Text;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example55_TextChunker(ITestOutputHelper output) : BaseTest(output)
+public class TextChunkerUsage(ITestOutputHelper output) : BaseTest(output)
{
private static readonly Tokenizer s_tokenizer = Tokenizer.CreateTiktokenForModel("gpt-4");
diff --git a/dotnet/samples/KernelSyntaxExamples/Example81_TextEmbedding.cs b/dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example81_TextEmbedding.cs
rename to dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
index f8c5c51d0ddf..46dc60815827 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example81_TextEmbedding.cs
+++ b/dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
@@ -1,17 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.ML.Tokenizers;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Text;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example81_TextEmbedding(ITestOutputHelper output) : BaseTest(output)
+public class TextChunkingAndEmbedding(ITestOutputHelper output) : BaseTest(output)
{
private const string EmbeddingModelName = "text-embedding-ada-002";
private static readonly Tokenizer s_tokenizer = Tokenizer.CreateTiktokenForModel(EmbeddingModelName);
diff --git a/dotnet/samples/KernelSyntaxExamples/Example99_GeminiEmbeddingGeneration.cs b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
similarity index 89%
rename from dotnet/samples/KernelSyntaxExamples/Example99_GeminiEmbeddingGeneration.cs
rename to dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
index 6ee9b43ba44c..c577b8ea7bab 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example99_GeminiEmbeddingGeneration.cs
+++ b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
@@ -1,20 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Google;
using Microsoft.SemanticKernel.Embeddings;
using Microsoft.SemanticKernel.Memory;
-using Microsoft.SemanticKernel.Plugins.Memory;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Represents an example class for Gemini Embedding Generation with volatile memory store.
///
-public sealed class Example99_GeminiEmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
+public sealed class TextMemoryPlugin_GeminiEmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "aboutMe";
@@ -139,7 +135,7 @@ private async Task RunTextMemoryPluginSampleAsync(Kernel kernel)
// The combination of the text embedding generator and the memory store makes up the 'SemanticTextMemory' object used to
// store and retrieve memories.
- SemanticTextMemory textMemory = new(memoryStore, embeddingGenerator);
+ Microsoft.SemanticKernel.Memory.SemanticTextMemory textMemory = new(memoryStore, embeddingGenerator);
/////////////////////////////////////////////////////////////////////////////////////////////////////
// PART 1: Store and retrieve memories using the ISemanticTextMemory (textMemory) object.
@@ -171,15 +167,15 @@ private async Task RunTextMemoryPluginSampleAsync(Kernel kernel)
WriteLine("== PART 2: Saving Memories through the Kernel with TextMemoryPlugin and the 'Save' function ==");
// Import the TextMemoryPlugin into the Kernel for other functions
- var memoryPlugin = kernel.ImportPluginFromObject(new TextMemoryPlugin(textMemory));
+ var memoryPlugin = kernel.ImportPluginFromObject(new Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin(textMemory));
// Save a memory with the Kernel
WriteLine("Saving memory with key 'info5': \"My family is from New York\"");
await kernel.InvokeAsync(memoryPlugin["Save"], new()
{
- [TextMemoryPlugin.InputParam] = "My family is from New York",
- [TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
- [TextMemoryPlugin.KeyParam] = "info5",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.InputParam] = "My family is from New York",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.KeyParam] = "info5",
});
this.WriteLine();
@@ -214,10 +210,10 @@ private async Task RunTextMemoryPluginSampleAsync(Kernel kernel)
var result = await kernel.InvokeAsync(memoryPlugin["Recall"], new()
{
- [TextMemoryPlugin.InputParam] = "Ask: my family is from?",
- [TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
- [TextMemoryPlugin.LimitParam] = "2",
- [TextMemoryPlugin.RelevanceParam] = "0.79",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.InputParam] = "Ask: my family is from?",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.LimitParam] = "2",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.RelevanceParam] = "0.79",
});
WriteLine($"Answer: {result.GetValue()}");
@@ -252,10 +248,10 @@ END FACTS
result = await kernel.InvokePromptAsync(RecallFunctionDefinition, new(new GeminiPromptExecutionSettings { MaxTokens = 1000 })
{
- [TextMemoryPlugin.InputParam] = "Where are my family from?",
- [TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
- [TextMemoryPlugin.LimitParam] = "2",
- [TextMemoryPlugin.RelevanceParam] = "0.79",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.InputParam] = "Where are my family from?",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.CollectionParam] = MemoryCollectionName,
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.LimitParam] = "2",
+ [Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.RelevanceParam] = "0.79",
});
WriteLine("Ask: Where are my family from?");
diff --git a/dotnet/samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs
rename to dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
index 45076a49ff83..d5ac6ff9053b 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs
+++ b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
@@ -1,6 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.AzureAISearch;
using Microsoft.SemanticKernel.Connectors.Chroma;
@@ -17,14 +16,11 @@
using Microsoft.SemanticKernel.Memory;
using Microsoft.SemanticKernel.Plugins.Memory;
using Npgsql;
-using RepoUtils;
using StackExchange.Redis;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example15_TextMemoryPlugin(ITestOutputHelper output) : BaseTest(output)
+public class TextMemoryPlugin_MultipleMemoryStore(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "aboutMe";
@@ -106,19 +102,19 @@ private IMemoryStore CreateSampleAzureAISearchMemoryStore()
private IMemoryStore CreateSampleChromaMemoryStore()
{
- IMemoryStore store = new ChromaMemoryStore(TestConfiguration.Chroma.Endpoint, ConsoleLogger.LoggerFactory);
+ IMemoryStore store = new ChromaMemoryStore(TestConfiguration.Chroma.Endpoint, this.LoggerFactory);
return store;
}
private IMemoryStore CreateSampleQdrantMemoryStore()
{
- IMemoryStore store = new QdrantMemoryStore(TestConfiguration.Qdrant.Endpoint, 1536, ConsoleLogger.LoggerFactory);
+ IMemoryStore store = new QdrantMemoryStore(TestConfiguration.Qdrant.Endpoint, 1536, this.LoggerFactory);
return store;
}
private IMemoryStore CreateSamplePineconeMemoryStore()
{
- IMemoryStore store = new PineconeMemoryStore(TestConfiguration.Pinecone.Environment, TestConfiguration.Pinecone.ApiKey, ConsoleLogger.LoggerFactory);
+ IMemoryStore store = new PineconeMemoryStore(TestConfiguration.Pinecone.Environment, TestConfiguration.Pinecone.ApiKey, this.LoggerFactory);
return store;
}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example66_FunctionCallingStepwisePlanner.cs b/dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
similarity index 88%
rename from dotnet/samples/KernelSyntaxExamples/Example66_FunctionCallingStepwisePlanner.cs
rename to dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
index 7337ca00bb28..25bf9dec642d 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example66_FunctionCallingStepwisePlanner.cs
+++ b/dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Planning;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example66_FunctionCallingStepwisePlanner(ITestOutputHelper output) : BaseTest(output)
+public class FunctionCallStepwisePlanning(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
@@ -28,7 +25,7 @@ public async Task RunAsync()
MaxIterations = 15,
MaxTokens = 4000,
};
- var planner = new FunctionCallingStepwisePlanner(options);
+ var planner = new Microsoft.SemanticKernel.Planning.FunctionCallingStepwisePlanner(options);
foreach (var question in questions)
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example65_HandlebarsPlanner.cs b/dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
similarity index 98%
rename from dotnet/samples/KernelSyntaxExamples/Example65_HandlebarsPlanner.cs
rename to dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
index d1ffff5439cb..479279e4497c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example65_HandlebarsPlanner.cs
+++ b/dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
@@ -1,25 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Planning.Handlebars;
using Microsoft.SemanticKernel.Plugins.OpenApi;
using Plugins.DictionaryPlugin;
-using RepoUtils;
using Resources;
using xRetry;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use the Handlebars sequential planner.
-public class Example65_HandlebarsPlanner(ITestOutputHelper output) : BaseTest(output)
+public class HandlebarsPlanning(ITestOutputHelper output) : BaseTest(output)
{
private static int s_sampleIndex;
diff --git a/dotnet/samples/KernelSyntaxExamples/Example83_ApiManifest.cs b/dotnet/samples/Concepts/Plugins/ApiManifestBasedPlugins.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example83_ApiManifest.cs
rename to dotnet/samples/Concepts/Plugins/ApiManifestBasedPlugins.cs
index 3c596233325f..2325b46d9e17 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example83_ApiManifest.cs
+++ b/dotnet/samples/Concepts/Plugins/ApiManifestBasedPlugins.cs
@@ -1,24 +1,16 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
using System.Net.Http.Headers;
-using System.Threading;
-using System.Threading.Tasks;
using System.Web;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.MsGraph.Connectors.CredentialManagers;
using Microsoft.SemanticKernel.Plugins.OpenApi;
using Microsoft.SemanticKernel.Plugins.OpenApi.Extensions;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use the ApiManifest based plugins
-public class Example83_ApiManifest(ITestOutputHelper output) : BaseTest(output)
+public class ApiManifestBasedPlugins(ITestOutputHelper output) : BaseTest(output)
{
public static readonly IEnumerable
[Fact(Skip = "Setup credentials")]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example23_OpenAPIPlugin.cs b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Github.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example23_OpenAPIPlugin.cs
rename to dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Github.cs
index 954cd5c9f7ee..d0394ac69144 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example23_OpenAPIPlugin.cs
+++ b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Github.cs
@@ -1,20 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.OpenApi;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// Examples to show how to create plugins from OpenAPI specs.
///
-public class Example23_OpenAPIPlugin(ITestOutputHelper output) : BaseTest(output)
+public class CreatePluginFromOpenApiSpec_Github(ITestOutputHelper output) : BaseTest(output)
{
///
/// Example to show how to consume operation extensions and other metadata from an OpenAPI spec.
diff --git a/dotnet/samples/KernelSyntaxExamples/Example24_OpenApiPlugin_Jira.cs b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example24_OpenApiPlugin_Jira.cs
rename to dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
index ec0711db1316..cd632e4db33d 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example24_OpenApiPlugin_Jira.cs
+++ b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
@@ -1,23 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Identity.Client;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.OpenApi;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example24_OpenApiPlugin_Jira(ITestOutputHelper output) : BaseTest(output)
+public class CreatePluginFromOpenApiSpec_Jira(ITestOutputHelper output) : BaseTest(output)
{
private static readonly JsonSerializerOptions s_jsonOptionsCache = new()
{
@@ -39,7 +31,7 @@ public class Example24_OpenApiPlugin_Jira(ITestOutputHelper output) : BaseTest(o
/// 3. You can find your domain under the "Products" tab in your account management page.
/// To go to your account management page, click on your profile picture in the top right corner of your Jira
/// instance then select "Manage account".
- /// 4. Configure the secrets as described by the ReadMe.md in the dotnet/samples/KernelSyntaxExamples folder.
+ /// 4. Configure the secrets as described by the ReadMe.md in the dotnet/samples/Concepts folder.
///
[Fact(Skip = "Setup credentials")]
public async Task RunAsync()
@@ -62,7 +54,7 @@ public async Task RunAsync()
bool useLocalFile = true;
if (useLocalFile)
{
- var apiPluginFile = "./../../../Plugins/JiraPlugin/openapi.json";
+ var apiPluginFile = "./../../../../Plugins/JiraPlugin/openapi.json";
jiraFunctions = await kernel.ImportPluginFromOpenApiAsync(
"jiraPlugin",
apiPluginFile,
diff --git a/dotnet/samples/KernelSyntaxExamples/Example69_MutableKernelPlugin.cs b/dotnet/samples/Concepts/Plugins/CustomMutablePlugin.cs
similarity index 89%
rename from dotnet/samples/KernelSyntaxExamples/Example69_MutableKernelPlugin.cs
rename to dotnet/samples/Concepts/Plugins/CustomMutablePlugin.cs
index c38ec2af6206..4b6016ed0aea 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example69_MutableKernelPlugin.cs
+++ b/dotnet/samples/Concepts/Plugins/CustomMutablePlugin.cs
@@ -1,21 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-// This example shows how to create a mutable .
-public class Example69_MutableKernelPlugin(ITestOutputHelper output) : BaseTest(output)
+///
+/// This example shows how to create a mutable .
+///
+public class CustomMutablePlugin(ITestOutputHelper output) : BaseTest(output)
{
- ///
- /// Show how to create a mutable .
- ///
[Fact]
public async Task RunAsync()
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example10_DescribeAllPluginsAndFunctions.cs b/dotnet/samples/Concepts/Plugins/DescribeAllPluginsAndFunctions.cs
similarity index 96%
rename from dotnet/samples/KernelSyntaxExamples/Example10_DescribeAllPluginsAndFunctions.cs
rename to dotnet/samples/Concepts/Plugins/DescribeAllPluginsAndFunctions.cs
index b098c5468b2a..19047d2869cc 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example10_DescribeAllPluginsAndFunctions.cs
+++ b/dotnet/samples/Concepts/Plugins/DescribeAllPluginsAndFunctions.cs
@@ -1,18 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.IO;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Plugins.Core;
using Plugins;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example10_DescribeAllPluginsAndFunctions(ITestOutputHelper output) : BaseTest(output)
+public class DescribeAllPluginsAndFunctions(ITestOutputHelper output) : BaseTest(output)
{
///
/// Print a list of all the functions imported into the kernel, including function descriptions,
diff --git a/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs b/dotnet/samples/Concepts/Plugins/GroundednessChecks.cs
similarity index 98%
rename from dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs
rename to dotnet/samples/Concepts/Plugins/GroundednessChecks.cs
index ecde8ebe71c0..837646f0c7f6 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example48_GroundednessChecks.cs
+++ b/dotnet/samples/Concepts/Plugins/GroundednessChecks.cs
@@ -1,19 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.IO;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Planning.Handlebars;
using Microsoft.SemanticKernel.Plugins.Core;
-using RepoUtils;
using xRetry;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example48_GroundednessChecks(ITestOutputHelper output) : BaseTest(output)
+public class GroundednessChecks(ITestOutputHelper output) : BaseTest(output)
{
[RetryFact(typeof(HttpOperationException))]
public async Task GroundednessCheckingAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example35_GrpcPlugins.cs b/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
similarity index 87%
rename from dotnet/samples/KernelSyntaxExamples/Example35_GrpcPlugins.cs
rename to dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
index 57e368fc0d67..a924bf042386 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example35_GrpcPlugins.cs
+++ b/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Grpc;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use gRPC plugins.
-public class Example35_GrpcPlugins(ITestOutputHelper output) : BaseTest(output)
+public class ImportPluginFromGrpc(ITestOutputHelper output) : BaseTest(output)
{
[Fact(Skip = "Setup crendentials")]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example21_OpenAIPlugins.cs b/dotnet/samples/Concepts/Plugins/OpenAIPlugins.cs
similarity index 91%
rename from dotnet/samples/KernelSyntaxExamples/Example21_OpenAIPlugins.cs
rename to dotnet/samples/Concepts/Plugins/OpenAIPlugins.cs
index b17f6647cc8b..b6e3bd4148c8 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example21_OpenAIPlugins.cs
+++ b/dotnet/samples/Concepts/Plugins/OpenAIPlugins.cs
@@ -1,16 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Net.Http;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.OpenApi;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example21_OpenAIPlugins(ITestOutputHelper output) : BaseTest(output)
+public class OpenAIPlugins(ITestOutputHelper output) : BaseTest(output)
{
///
/// Generic template on how to call OpenAI plugins
diff --git a/dotnet/samples/KernelSyntaxExamples/Example63_ChatCompletionPrompts.cs b/dotnet/samples/Concepts/PromptTemplates/ChatCompletionPrompts.cs
similarity index 91%
rename from dotnet/samples/KernelSyntaxExamples/Example63_ChatCompletionPrompts.cs
rename to dotnet/samples/Concepts/PromptTemplates/ChatCompletionPrompts.cs
index 1c365679cf7f..933fad3443a1 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example63_ChatCompletionPrompts.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/ChatCompletionPrompts.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use chat completion standardized prompts.
-public class Example63_ChatCompletionPrompts(ITestOutputHelper output) : BaseTest(output)
+public class ChatCompletionPrompts(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs b/dotnet/samples/Concepts/PromptTemplates/ChatWithPrompts.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs
rename to dotnet/samples/Concepts/PromptTemplates/ChatWithPrompts.cs
index 5060b4892900..66bf64514b27 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/ChatWithPrompts.cs
@@ -1,14 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.Globalization;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Plugins.Core;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -35,7 +31,7 @@ namespace Examples;
/// Out of scope and not in the example: if needed, one could go further and use a semantic
/// function (with extra cost) asking AI to generate the text to send to the Chat model.
///
-public class Example30_ChatWithPrompts(ITestOutputHelper output) : BaseTest(output)
+public class ChatWithPrompts(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs b/dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
similarity index 90%
rename from dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs
rename to dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
index c55bc70cba1e..716a7777ef97 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
@@ -1,16 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
using xRetry;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// This example shows how to use multiple prompt template formats.
-public class Example64_MultiplePromptTemplates(ITestOutputHelper output) : BaseTest(output)
+public class MultiplePromptTemplates(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to combine multiple prompt template factories.
@@ -20,7 +17,7 @@ public class Example64_MultiplePromptTemplates(ITestOutputHelper output) : BaseT
[InlineData("handlebars", "Hello AI, my name is {{name}}. What is the origin of my name?")]
public Task RunAsync(string templateFormat, string prompt)
{
- WriteLine("======== Example64_MultiplePromptTemplates ========");
+ WriteLine($"======== {nameof(MultiplePromptTemplates)} ========");
Kernel kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
diff --git a/dotnet/samples/KernelSyntaxExamples/Example27_PromptFunctionsUsingChatGPT.cs b/dotnet/samples/Concepts/PromptTemplates/PromptFunctionsWithChatGPT.cs
similarity index 87%
rename from dotnet/samples/KernelSyntaxExamples/Example27_PromptFunctionsUsingChatGPT.cs
rename to dotnet/samples/Concepts/PromptTemplates/PromptFunctionsWithChatGPT.cs
index 041c64d8d39d..2252d4ecb05e 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example27_PromptFunctionsUsingChatGPT.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/PromptFunctionsWithChatGPT.cs
@@ -1,16 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
///
/// This example shows how to use GPT3.5 Chat model for prompts and prompt functions.
///
-public class Example27_PromptFunctionsUsingChatGPT(ITestOutputHelper output) : BaseTest(output)
+public class PromptFunctionsWithChatGPT(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs b/dotnet/samples/Concepts/PromptTemplates/TemplateLanguage.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs
rename to dotnet/samples/Concepts/PromptTemplates/TemplateLanguage.cs
index 92a5784ad236..271fc859e352 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/TemplateLanguage.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example06_TemplateLanguage(ITestOutputHelper output) : BaseTest(output)
+public class TemplateLanguage(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to invoke a Method Function written in C#
diff --git a/dotnet/samples/KernelSyntaxExamples/Example80_FunctionCallingPlannerWithRAG.cs b/dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
similarity index 92%
rename from dotnet/samples/KernelSyntaxExamples/Example80_FunctionCallingPlannerWithRAG.cs
rename to dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
index 6889974684fd..234e28279783 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example80_FunctionCallingPlannerWithRAG.cs
+++ b/dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
using System.ComponentModel;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Planning;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example80_FunctionCallingPlannerWithRAG(ITestOutputHelper output) : BaseTest(output)
+public class WithFunctionCallingStepwisePlanner(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
@@ -29,7 +26,7 @@ public async Task RunAsync()
MaxIterations = 15,
MaxTokens = 4000,
};
- var planner = new FunctionCallingStepwisePlanner(options);
+ var planner = new Microsoft.SemanticKernel.Planning.FunctionCallingStepwisePlanner(options);
foreach (var question in questions)
{
diff --git a/dotnet/samples/KernelSyntaxExamples/Example78_RAG.cs b/dotnet/samples/Concepts/RAG/WithPlugins.cs
similarity index 90%
rename from dotnet/samples/KernelSyntaxExamples/Example78_RAG.cs
rename to dotnet/samples/Concepts/RAG/WithPlugins.cs
index 4de74d750130..3eb965a8c53e 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example78_RAG.cs
+++ b/dotnet/samples/Concepts/RAG/WithPlugins.cs
@@ -1,22 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Text.Json;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Chroma;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
-using Microsoft.SemanticKernel.Plugins.Memory;
using Microsoft.SemanticKernel.Plugins.OpenApi;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example78_RAG(ITestOutputHelper output) : BaseTest(output)
+public class WithPlugins(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RAGWithCustomPluginAsync()
@@ -33,7 +28,7 @@ public async Task RAGWithCustomPluginAsync()
}
///
- /// Shows how to use RAG pattern with .
+ /// Shows how to use RAG pattern with .
///
[Fact(Skip = "Requires Chroma server up and running")]
public async Task RAGWithTextMemoryPluginAsync()
@@ -47,7 +42,7 @@ public async Task RAGWithTextMemoryPluginAsync()
.AddOpenAIChatCompletion(TestConfiguration.OpenAI.ChatModelId, TestConfiguration.OpenAI.ApiKey)
.Build();
- kernel.ImportPluginFromObject(new TextMemoryPlugin(memory));
+ kernel.ImportPluginFromObject(new Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin(memory));
var result = await kernel.InvokePromptAsync("{{recall 'budget by year' collection='finances'}} What is my budget for 2024?");
diff --git a/dotnet/samples/Concepts/README.md b/dotnet/samples/Concepts/README.md
index 42a9f499fab0..63f4878727ea 100644
--- a/dotnet/samples/Concepts/README.md
+++ b/dotnet/samples/Concepts/README.md
@@ -4,23 +4,22 @@ This section contains code snippets that demonstrate the usage of Semantic Kerne
| Features | Description |
| -------- | ----------- |
+| Kernel | Using [`Kernel`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/Kernel.cs) Features |
| Functions | Invoking [`Method`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Core/Functions/KernelFunctionFromMethod.cs) or [`Prompt`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Core/Functions/KernelFunctionFromPrompt.cs) functions with [`Kernel`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/Kernel.cs) |
-| Chat Completion | Using [`ChatCompletion`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/IChatCompletionService.cs) messaging capable service with models |
-| Text Generation | Using [`TextGeneration`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextGeneration/ITextGenerationService.cs) capable service with models |
-| Text to Image | Using [`TextToImage`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextToImage/ITextToImageService.cs) services to generate images |
-| Image to Text | Using [`ImageToText`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/ImageToText/IImageToTextService.cs) services to describe images |
-| Text to Audio | Using [`TextToAudio`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextToAudio/ITextToAudioService.cs) services to generate audio |
-| Audio to Text | Using [`AudioToText`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/AudioToText/IAudioToTextService.cs) services to describe audio |
+| ChatCompletion | Using [`ChatCompletion`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/IChatCompletionService.cs) messaging capable service with models |
+| TextGeneration | Using [`TextGeneration`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextGeneration/ITextGenerationService.cs) capable service with models |
+| TextToImage | Using [`TextToImage`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextToImage/ITextToImageService.cs) services to generate images |
+| ImageToText | Using [`ImageToText`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/ImageToText/IImageToTextService.cs) services to describe images |
+| TextToAudio | Using [`TextToAudio`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/TextToAudio/ITextToAudioService.cs) services to generate audio |
+| AudioToText | Using [`AudioToText`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/AudioToText/IAudioToTextService.cs) services to describe audio |
| Telemetry | Code examples how to setup and use [`Telemetry`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/docs/TELEMETRY.md) |
-| Logging | Code examples how to setup and use [`Logging`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/docs/TELEMETRY.md#logging) |
-| Dependency Injection | Examples on using `DI Container` with SK |
+| DependencyInjection | Examples on using `DI Container` with SK |
| Plugins | Different ways of creating and using [`Plugins`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/Functions/KernelPlugin.cs) |
-| Auto Function Calling | Using `Auto Function Calling` to allow function call capable models to invoke Kernel Functions automatically |
+| AutoFunctionCalling | Using `Auto Function Calling` to allow function call capable models to invoke Kernel Functions automatically |
| Filters | Different ways of filtering with Kernel |
| Memory | Using [`Memory`](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/SemanticKernel.Abstractions/Memory) AI concepts |
| Search | Using search services information |
-| Templates | Using [`Templates`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/PromptTemplate/IPromptTemplate.cs) with parametrization for `Prompt` rendering |
+| PromptTemplates | Using [`Templates`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/PromptTemplate/IPromptTemplate.cs) with parametrization for `Prompt` rendering |
| RAG | Different ways of `RAG` (Retrieval-Augmented Generation) |
-| Local Models | Using services against `LocalModels` to run models locally |
-| Agents | Different ways of using [`Agents`](./AgentSyntax/README.md) |
-| AgentSyntax | ⚠️ Work in progress: Moving into [`Agents`](./AgentSyntax/README.md). |
\ No newline at end of file
+| LocalModels | Using services against `LocalModels` to run models locally |
+| Agents | Different ways of using [`Agents`](./Agents/README.md) |
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/22-ai-plugin.json b/dotnet/samples/Concepts/Resources/22-ai-plugin.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/22-ai-plugin.json
rename to dotnet/samples/Concepts/Resources/22-ai-plugin.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/22-openapi.json b/dotnet/samples/Concepts/Resources/22-openapi.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/22-openapi.json
rename to dotnet/samples/Concepts/Resources/22-openapi.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/30-system-prompt.txt b/dotnet/samples/Concepts/Resources/30-system-prompt.txt
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/30-system-prompt.txt
rename to dotnet/samples/Concepts/Resources/30-system-prompt.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/30-user-context.txt b/dotnet/samples/Concepts/Resources/30-user-context.txt
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/30-user-context.txt
rename to dotnet/samples/Concepts/Resources/30-user-context.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/30-user-prompt.txt b/dotnet/samples/Concepts/Resources/30-user-prompt.txt
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/30-user-prompt.txt
rename to dotnet/samples/Concepts/Resources/30-user-prompt.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/65-prompt-override.handlebars b/dotnet/samples/Concepts/Resources/65-prompt-override.handlebars
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/65-prompt-override.handlebars
rename to dotnet/samples/Concepts/Resources/65-prompt-override.handlebars
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/Agents/ParrotAgent.yaml b/dotnet/samples/Concepts/Resources/Agents/ParrotAgent.yaml
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/Agents/ParrotAgent.yaml
rename to dotnet/samples/Concepts/Resources/Agents/ParrotAgent.yaml
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/Agents/ToolAgent.yaml b/dotnet/samples/Concepts/Resources/Agents/ToolAgent.yaml
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/Agents/ToolAgent.yaml
rename to dotnet/samples/Concepts/Resources/Agents/ToolAgent.yaml
diff --git a/dotnet/samples/Concepts/AgentSyntax/Resources/travelinfo.txt b/dotnet/samples/Concepts/Resources/Agents/travelinfo.txt
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Resources/travelinfo.txt
rename to dotnet/samples/Concepts/Resources/Agents/travelinfo.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/dict.txt b/dotnet/samples/Concepts/Resources/EnglishRoberta/dict.txt
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/dict.txt
rename to dotnet/samples/Concepts/Resources/EnglishRoberta/dict.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/encoder.json b/dotnet/samples/Concepts/Resources/EnglishRoberta/encoder.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/encoder.json
rename to dotnet/samples/Concepts/Resources/EnglishRoberta/encoder.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/vocab.bpe b/dotnet/samples/Concepts/Resources/EnglishRoberta/vocab.bpe
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/EnglishRoberta/vocab.bpe
rename to dotnet/samples/Concepts/Resources/EnglishRoberta/vocab.bpe
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/GenerateStory.yaml b/dotnet/samples/Concepts/Resources/GenerateStory.yaml
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/GenerateStory.yaml
rename to dotnet/samples/Concepts/Resources/GenerateStory.yaml
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/GenerateStoryHandlebars.yaml b/dotnet/samples/Concepts/Resources/GenerateStoryHandlebars.yaml
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/GenerateStoryHandlebars.yaml
rename to dotnet/samples/Concepts/Resources/GenerateStoryHandlebars.yaml
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/CalendarPlugin/apimanifest.json b/dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/CalendarPlugin/apimanifest.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/CalendarPlugin/apimanifest.json
rename to dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/CalendarPlugin/apimanifest.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/ContactsPlugin/apimanifest.json b/dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/ContactsPlugin/apimanifest.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/ContactsPlugin/apimanifest.json
rename to dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/ContactsPlugin/apimanifest.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/DriveItemPlugin/apimanifest.json b/dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/DriveItemPlugin/apimanifest.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/DriveItemPlugin/apimanifest.json
rename to dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/DriveItemPlugin/apimanifest.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/MessagesPlugin/apimanifest.json b/dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/MessagesPlugin/apimanifest.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/ApiManifestPlugins/MessagesPlugin/apimanifest.json
rename to dotnet/samples/Concepts/Resources/Plugins/ApiManifestPlugins/MessagesPlugin/apimanifest.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs
similarity index 91%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs
index afb7d0a5cf55..65e44ab2b78b 100644
--- a/dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs
+++ b/dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/ComplexParamsDictionaryPlugin.cs
@@ -1,10 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
-using System.Linq;
using System.Security.Cryptography;
using System.Text.Json;
using Microsoft.SemanticKernel;
@@ -18,14 +15,14 @@ public sealed class ComplexParamsDictionaryPlugin
{
public const string PluginName = nameof(ComplexParamsDictionaryPlugin);
- private readonly List _dictionary =
- [
+ private readonly List _dictionary = new()
+ {
new DictionaryEntry("apple", "a round fruit with red, green, or yellow skin and a white flesh"),
new DictionaryEntry("book", "a set of printed or written pages bound together along one edge"),
new DictionaryEntry("cat", "a small furry animal with whiskers and a long tail that is often kept as a pet"),
new DictionaryEntry("dog", "a domesticated animal with four legs, a tail, and a keen sense of smell that is often used for hunting or companionship"),
new DictionaryEntry("elephant", "a large gray mammal with a long trunk, tusks, and ears that lives in Africa and Asia")
- ];
+ };
[KernelFunction, Description("Gets a random word from a dictionary of common words and their definitions.")]
public DictionaryEntry GetRandomEntry()
@@ -62,10 +59,16 @@ public string GetDefinition([Description("Word to get definition for.")] string
/// It's possible to choose any format (e.g. XML, JSON, YAML) to represent your object.
///
[TypeConverter(typeof(DictionaryEntryConverter))]
-public sealed class DictionaryEntry(string word, string definition)
+public sealed class DictionaryEntry
{
- public string Word { get; set; } = word;
- public string Definition { get; set; } = definition;
+ public string Word { get; set; } = string.Empty;
+ public string Definition { get; set; } = string.Empty;
+
+ public DictionaryEntry(string word, string definition)
+ {
+ this.Word = word;
+ this.Definition = definition;
+ }
}
///
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs
index 7849a77d4a3c..1cfdcd20f4d9 100644
--- a/dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs
+++ b/dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/StringParamsDictionaryPlugin.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
using System.Security.Cryptography;
using Microsoft.SemanticKernel;
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/openapi.json b/dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/openapi.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/DictionaryPlugin/openapi.json
rename to dotnet/samples/Concepts/Resources/Plugins/DictionaryPlugin/openapi.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/EmailPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/EmailPlugin.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/EmailPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/EmailPlugin.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/JiraPlugin/README.md b/dotnet/samples/Concepts/Resources/Plugins/JiraPlugin/README.md
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/JiraPlugin/README.md
rename to dotnet/samples/Concepts/Resources/Plugins/JiraPlugin/README.md
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/JiraPlugin/openapi.json b/dotnet/samples/Concepts/Resources/Plugins/JiraPlugin/openapi.json
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/JiraPlugin/openapi.json
rename to dotnet/samples/Concepts/Resources/Plugins/JiraPlugin/openapi.json
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/MenuPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
similarity index 93%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/MenuPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
index fa721c0ea22f..7111e873cf4c 100644
--- a/dotnet/samples/KernelSyntaxExamples/Plugins/MenuPlugin.cs
+++ b/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
@@ -1,12 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.SemanticKernel;
namespace Plugins;
-public sealed class MenuPlugin
+public sealed class LegacyMenuPlugin
{
public const string CorrelationIdArgument = "correlationId";
@@ -37,7 +36,7 @@ public string[] GetSpecials(KernelArguments? arguments)
[KernelFunction, Description("Provides the price of the requested menu item.")]
public string GetItemPrice(
[Description("The name of the menu item.")]
- string menuItem,
+ string menuItem,
KernelArguments? arguments)
{
CaptureCorrelationId(arguments, nameof(GetItemPrice));
@@ -51,9 +50,9 @@ public string GetItemPrice(
[KernelFunction, Description("Returns true if the kitchen has ran out of the item.")]
public bool IsItem86d(
[Description("The name of the menu item.")]
- string menuItem,
+ string menuItem,
[Description("The number of items requested.")]
- int count,
+ int count,
KernelArguments? arguments)
{
CaptureCorrelationId(arguments, nameof(IsItem86d));
diff --git a/dotnet/samples/Concepts/AgentSyntax/Plugins/MenuPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/MenuPlugin.cs
similarity index 76%
rename from dotnet/samples/Concepts/AgentSyntax/Plugins/MenuPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/MenuPlugin.cs
index e29627e047ad..be82177eda5d 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Plugins/MenuPlugin.cs
+++ b/dotnet/samples/Concepts/Resources/Plugins/MenuPlugin.cs
@@ -7,6 +7,12 @@ namespace Plugins;
public sealed class MenuPlugin
{
+ public const string CorrelationIdArgument = "correlationId";
+
+ private readonly List _correlationIds = [];
+
+ public IReadOnlyList CorrelationIds => this._correlationIds;
+
[KernelFunction, Description("Provides a list of specials from the menu.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1024:Use properties where appropriate", Justification = "Too smart")]
public string GetSpecials()
@@ -21,7 +27,7 @@ public string GetSpecials()
[KernelFunction, Description("Provides the price of the requested menu item.")]
public string GetItemPrice(
[Description("The name of the menu item.")]
- string menuItem)
+ string menuItem)
{
return "$9.99";
}
diff --git a/dotnet/samples/KernelSyntaxExamples/Plugins/StaticTextPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/StaticTextPlugin.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Plugins/StaticTextPlugin.cs
rename to dotnet/samples/Concepts/Resources/Plugins/StaticTextPlugin.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/chat-gpt-retrieval-plugin-open-api.yaml b/dotnet/samples/Concepts/Resources/chat-gpt-retrieval-plugin-open-api.yaml
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/chat-gpt-retrieval-plugin-open-api.yaml
rename to dotnet/samples/Concepts/Resources/chat-gpt-retrieval-plugin-open-api.yaml
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/sample_image.jpg b/dotnet/samples/Concepts/Resources/sample_image.jpg
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/sample_image.jpg
rename to dotnet/samples/Concepts/Resources/sample_image.jpg
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/test_audio.wav b/dotnet/samples/Concepts/Resources/test_audio.wav
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/test_audio.wav
rename to dotnet/samples/Concepts/Resources/test_audio.wav
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/test_image.jpg b/dotnet/samples/Concepts/Resources/test_image.jpg
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/test_image.jpg
rename to dotnet/samples/Concepts/Resources/test_image.jpg
diff --git a/dotnet/samples/KernelSyntaxExamples/Resources/travelinfo.txt b/dotnet/samples/Concepts/Resources/travelinfo.txt
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Resources/travelinfo.txt
rename to dotnet/samples/Concepts/Resources/travelinfo.txt
diff --git a/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs b/dotnet/samples/Concepts/Search/BingAndGooglePlugins.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs
rename to dotnet/samples/Concepts/Search/BingAndGooglePlugins.cs
index 6c6ec43e75b6..77308e4b489f 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs
+++ b/dotnet/samples/Concepts/Search/BingAndGooglePlugins.cs
@@ -1,14 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Plugins.Web;
using Microsoft.SemanticKernel.Plugins.Web.Bing;
using Microsoft.SemanticKernel.Plugins.Web.Google;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
@@ -17,7 +13,7 @@ namespace Examples;
/// you might want to import into your system, e.g. providing AI prompts with
/// recent information, or for AI to generate recent information to display to users.
///
-public class Example07_BingAndGooglePlugins(ITestOutputHelper output) : BaseTest(output)
+public class BingAndGooglePlugins(ITestOutputHelper output) : BaseTest(output)
{
[Fact(Skip = "Setup Credentials")]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example84_AzureAISearchPlugin.cs b/dotnet/samples/Concepts/Search/MyAzureAISearchPlugin.cs
similarity index 94%
rename from dotnet/samples/KernelSyntaxExamples/Example84_AzureAISearchPlugin.cs
rename to dotnet/samples/Concepts/Search/MyAzureAISearchPlugin.cs
index 0289bf3c33f1..eeb9c4e55592 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example84_AzureAISearchPlugin.cs
+++ b/dotnet/samples/Concepts/Search/MyAzureAISearchPlugin.cs
@@ -1,12 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
-using System.Threading;
-using System.Threading.Tasks;
using Azure;
using Azure.Search.Documents;
using Azure.Search.Documents.Indexes;
@@ -14,12 +9,10 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Embeddings;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example84_AzureAISearchPlugin(ITestOutputHelper output) : BaseTest(output)
+public class AzureAISearchPlugin(ITestOutputHelper output) : BaseTest(output)
{
///
/// Shows how to register Azure AI Search service as a plugin and work with custom index schema.
@@ -47,7 +40,7 @@ public async Task AzureAISearchPluginAsync()
kernelBuilder.AddOpenAIChatCompletion("gpt-4", TestConfiguration.OpenAI.ApiKey);
// Register Azure AI Search Plugin
- kernelBuilder.Plugins.AddFromType();
+ kernelBuilder.Plugins.AddFromType();
// Create kernel
var kernel = kernelBuilder.Build();
@@ -166,9 +159,9 @@ private sealed class AzureAISearchService(SearchIndexClient indexClient) : IAzur
/// It uses to convert string query to vector.
/// It uses to perform a request to Azure AI Search.
///
- private sealed class AzureAISearchPlugin(
+ private sealed class MyAzureAISearchPlugin(
ITextEmbeddingGenerationService textEmbeddingGenerationService,
- Example84_AzureAISearchPlugin.IAzureAISearchService searchService)
+ Examples.AzureAISearchPlugin.IAzureAISearchService searchService)
{
private readonly ITextEmbeddingGenerationService _textEmbeddingGenerationService = textEmbeddingGenerationService;
private readonly IAzureAISearchService _searchService = searchService;
diff --git a/dotnet/samples/KernelSyntaxExamples/Example11_WebSearchQueries.cs b/dotnet/samples/Concepts/Search/WebSearchQueriesPlugin.cs
similarity index 85%
rename from dotnet/samples/KernelSyntaxExamples/Example11_WebSearchQueries.cs
rename to dotnet/samples/Concepts/Search/WebSearchQueriesPlugin.cs
index 9ed150a4b0c9..32bd6b413a99 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example11_WebSearchQueries.cs
+++ b/dotnet/samples/Concepts/Search/WebSearchQueriesPlugin.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Web;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
-public class Example11_WebSearchQueries(ITestOutputHelper output) : BaseTest(output)
+public class WebSearchQueriesPlugin(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/KernelSyntaxExamples/Example16_CustomLLM.cs b/dotnet/samples/Concepts/TextGeneration/Custom_TextGenerationService.cs
similarity index 95%
rename from dotnet/samples/KernelSyntaxExamples/Example16_CustomLLM.cs
rename to dotnet/samples/Concepts/TextGeneration/Custom_TextGenerationService.cs
index bbc53fbefeda..8150df873a69 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example16_CustomLLM.cs
+++ b/dotnet/samples/Concepts/TextGeneration/Custom_TextGenerationService.cs
@@ -1,20 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.TextGeneration;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
/**
- * The following example shows how to plug a custom text generation model into SK.
+ * The following example shows how to plug a custom text generation service in SK.
*
* To do this, this example uses a text generation service stub (MyTextGenerationService) and
* no actual model.
@@ -28,7 +22,7 @@ namespace Examples;
*
* Refer to example 33 for streaming chat completion.
*/
-public class Example16_CustomLLM(ITestOutputHelper output) : BaseTest(output)
+public class Custom_TextGenerationService(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task CustomTextGenerationWithKernelFunctionAsync()
diff --git a/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
new file mode 100644
index 000000000000..49faef919bae
--- /dev/null
+++ b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
@@ -0,0 +1,105 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Connectors.HuggingFace;
+using xRetry;
+
+#pragma warning disable format // Format item can be simplified
+#pragma warning disable CA1861 // Avoid constant arrays as arguments
+
+namespace Examples;
+
+// The following example shows how to use Semantic Kernel with HuggingFace API.
+public class HuggingFace_TextGeneration(ITestOutputHelper helper) : BaseTest(helper)
+{
+ private const string DefaultModel = "HuggingFaceH4/zephyr-7b-beta";
+ ///
+ /// This example uses HuggingFace Inference API to access hosted models.
+ /// More information here:
+ ///
+ [Fact]
+ public async Task RunInferenceApiExampleAsync()
+ {
+ WriteLine("\n======== HuggingFace Inference API example ========\n");
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceTextGeneration(
+ model: TestConfiguration.HuggingFace.ModelId ?? DefaultModel,
+ apiKey: TestConfiguration.HuggingFace.ApiKey)
+ .Build();
+
+ var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:");
+
+ var result = await kernel.InvokeAsync(questionAnswerFunction, new() { ["input"] = "What is New York?" });
+
+ WriteLine(result.GetValue());
+ }
+
+ ///
+ /// Some Hugging Face models support streaming responses, configure using the HuggingFace ModelId setting.
+ ///
+ ///
+ /// Tested with HuggingFaceH4/zephyr-7b-beta model.
+ ///
+ [RetryFact(typeof(HttpOperationException))]
+ public async Task RunStreamingExampleAsync()
+ {
+ string model = TestConfiguration.HuggingFace.ModelId ?? DefaultModel;
+
+ WriteLine($"\n======== HuggingFace {model} streaming example ========\n");
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceTextGeneration(
+ model: model,
+ apiKey: TestConfiguration.HuggingFace.ApiKey)
+ .Build();
+
+ var settings = new HuggingFacePromptExecutionSettings { UseCache = false };
+
+ var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:", new HuggingFacePromptExecutionSettings
+ {
+ UseCache = false
+ });
+
+ await foreach (string text in kernel.InvokePromptStreamingAsync("Question: {{$input}}; Answer:", new(settings) { ["input"] = "What is New York?" }))
+ {
+ this.Write(text);
+ }
+ }
+
+ ///
+ /// This example uses HuggingFace Llama 2 model and local HTTP server from Semantic Kernel repository.
+ /// How to setup local HTTP server: .
+ ///
+ /// Additional access is required to download Llama 2 model and run it locally.
+ /// How to get access:
+ /// 1. Visit and complete request access form.
+ /// 2. Visit and complete form "Access Llama 2 on Hugging Face".
+ /// Note: Your Hugging Face account email address MUST match the email you provide on the Meta website, or your request will not be approved.
+ ///
+ ///
+ [Fact(Skip = "Requires local model or Huggingface Pro subscription")]
+ public async Task RunLlamaExampleAsync()
+ {
+ WriteLine("\n======== HuggingFace Llama 2 example ========\n");
+
+ // HuggingFace Llama 2 model: https://huggingface.co/meta-llama/Llama-2-7b-hf
+ const string Model = "meta-llama/Llama-2-7b-hf";
+
+ // HuggingFace local HTTP server endpoint
+ // const string Endpoint = "http://localhost:5000/completions";
+
+ Kernel kernel = Kernel.CreateBuilder()
+ .AddHuggingFaceTextGeneration(
+ model: Model,
+ //endpoint: Endpoint,
+ apiKey: TestConfiguration.HuggingFace.ApiKey)
+ .Build();
+
+ var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:");
+
+ var result = await kernel.InvokeAsync(questionAnswerFunction, new() { ["input"] = "What is New York?" });
+
+ WriteLine(result.GetValue());
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example32_StreamingCompletion.cs b/dotnet/samples/Concepts/TextGeneration/OpenAI_TextGenerationStreaming.cs
similarity index 86%
rename from dotnet/samples/KernelSyntaxExamples/Example32_StreamingCompletion.cs
rename to dotnet/samples/Concepts/TextGeneration/OpenAI_TextGenerationStreaming.cs
index af284e67b3c5..88506e9c31ad 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example32_StreamingCompletion.cs
+++ b/dotnet/samples/Concepts/TextGeneration/OpenAI_TextGenerationStreaming.cs
@@ -1,15 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.TextGeneration;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
/**
- * The following example shows how to use Semantic Kernel with streaming text completion.
+ * The following example shows how to use Semantic Kernel with streaming text generation.
*
* This example will NOT work with regular chat completion models. It will only work with
* text completion models.
@@ -18,12 +15,12 @@ namespace Examples;
*
* Refer to example 33 for streaming chat completion.
*/
-public class Example32_StreamingCompletion(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_TextGenerationStreaming(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public Task AzureOpenAITextGenerationStreamAsync()
{
- WriteLine("======== Azure OpenAI - Text Completion - Raw Streaming ========");
+ WriteLine("======== Azure OpenAI - Text Generation - Raw Streaming ========");
var textGeneration = new AzureOpenAITextGenerationService(
deploymentName: TestConfiguration.AzureOpenAI.DeploymentName,
@@ -37,7 +34,7 @@ public Task AzureOpenAITextGenerationStreamAsync()
[Fact]
public Task OpenAITextGenerationStreamAsync()
{
- WriteLine("======== Open AI - Text Completion - Raw Streaming ========");
+ WriteLine("======== Open AI - Text Generation - Raw Streaming ========");
var textGeneration = new OpenAITextGenerationService("gpt-3.5-turbo-instruct", TestConfiguration.OpenAI.ApiKey);
diff --git a/dotnet/samples/Concepts/TextToAudio/OpenAI_TextToAudio.cs b/dotnet/samples/Concepts/TextToAudio/OpenAI_TextToAudio.cs
new file mode 100644
index 000000000000..07e42427f8e4
--- /dev/null
+++ b/dotnet/samples/Concepts/TextToAudio/OpenAI_TextToAudio.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Connectors.OpenAI;
+using Microsoft.SemanticKernel.TextToAudio;
+
+namespace Examples;
+
+///
+/// Represents a class that demonstrates audio processing functionality.
+///
+public sealed class OpenAI_TextToAudio(ITestOutputHelper output) : BaseTest(output)
+{
+ private const string TextToAudioModel = "tts-1";
+
+ [Fact(Skip = "Uncomment the line to write the audio file output before running this test.")]
+ public async Task TextToAudioAsync()
+ {
+ // Create a kernel with OpenAI text to audio service
+ var kernel = Kernel.CreateBuilder()
+ .AddOpenAITextToAudio(
+ modelId: TextToAudioModel,
+ apiKey: TestConfiguration.OpenAI.ApiKey)
+ .Build();
+
+ var textToAudioService = kernel.GetRequiredService();
+
+ string sampleText = "Hello, my name is John. I am a software engineer. I am working on a project to convert text to audio.";
+
+ // Set execution settings (optional)
+ OpenAITextToAudioExecutionSettings executionSettings = new()
+ {
+ Voice = "alloy", // The voice to use when generating the audio.
+ // Supported voices are alloy, echo, fable, onyx, nova, and shimmer.
+ ResponseFormat = "mp3", // The format to audio in.
+ // Supported formats are mp3, opus, aac, and flac.
+ Speed = 1.0f // The speed of the generated audio.
+ // Select a value from 0.25 to 4.0. 1.0 is the default.
+ };
+
+ // Convert text to audio
+ AudioContent audioContent = await textToAudioService.GetAudioContentAsync(sampleText, executionSettings);
+
+ // Save audio content to a file
+ // await File.WriteAllBytesAsync(AudioFilePath, audioContent.Data!.ToArray());
+ }
+}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example18_DallE.cs b/dotnet/samples/Concepts/TextToImage/OpenAI_TextToImageDalle3.cs
similarity index 97%
rename from dotnet/samples/KernelSyntaxExamples/Example18_DallE.cs
rename to dotnet/samples/Concepts/TextToImage/OpenAI_TextToImageDalle3.cs
index 36bf026ed24f..a1fd5e4cee44 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example18_DallE.cs
+++ b/dotnet/samples/Concepts/TextToImage/OpenAI_TextToImageDalle3.cs
@@ -1,19 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.TextToImage;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
// The following example shows how to use Semantic Kernel with OpenAI DALL-E 2 to create images
-public class Example18_DallE(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_TextToImageDalle3(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task OpenAIDallEAsync()
diff --git a/dotnet/samples/GettingStarted/BaseTest.cs b/dotnet/samples/GettingStarted/BaseTest.cs
deleted file mode 100644
index b2559c03ae6f..000000000000
--- a/dotnet/samples/GettingStarted/BaseTest.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
-using RepoUtils;
-using Xunit.Abstractions;
-
-namespace Examples;
-
-public abstract class BaseTest
-{
- protected ITestOutputHelper Output { get; }
-
- protected ILoggerFactory LoggerFactory { get; }
-
- protected BaseTest(ITestOutputHelper output)
- {
- this.Output = output;
- this.LoggerFactory = new XunitLogger(output);
-
- LoadUserSecrets();
- }
-
- private static void LoadUserSecrets()
- {
- IConfigurationRoot configRoot = new ConfigurationBuilder()
- .AddJsonFile("appsettings.Development.json", true)
- .AddEnvironmentVariables()
- .AddUserSecrets()
- .Build();
-
- TestConfiguration.Initialize(configRoot);
- }
-
- ///
- /// This method can be substituted by Console.WriteLine when used in Console apps.
- ///
- /// Target object to write
- protected void WriteLine(object? target = null)
- {
- this.Output.WriteLine(target ?? string.Empty);
- }
-
- ///
- /// Current interface ITestOutputHelper does not have a Write method. This extension method adds it to make it analogous to Console.Write when used in Console apps.
- ///
- /// Target object to write
- protected void Write(object? target = null)
- {
- this.Output.WriteLine(target ?? string.Empty);
- }
-}
diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/GettingStarted.csproj
index 7193bceda98b..496b1baf6e4b 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -1,16 +1,15 @@
-
+
- 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
-
- QuickStart
+ GettingStarted
+ enablenet8.0truefalseCS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
@@ -24,6 +23,7 @@
+ runtime; build; native; contentfiles; analyzers; buildtransitiveall
@@ -46,6 +46,9 @@
+
+
+
@@ -55,4 +58,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/dotnet/samples/GettingStarted/README.md b/dotnet/samples/GettingStarted/README.md
index 300251e22dcb..e295461597e4 100644
--- a/dotnet/samples/GettingStarted/README.md
+++ b/dotnet/samples/GettingStarted/README.md
@@ -15,7 +15,7 @@ You can also use environment variables if you prefer.
To set your secrets with Secret Manager:
```
-cd dotnet/samples/KernelSyntaxExamples
+cd dotnet/samples/Concepts
dotnet user-secrets init
diff --git a/dotnet/samples/GettingStarted/RepoUtils/ConfigurationException.cs b/dotnet/samples/GettingStarted/RepoUtils/ConfigurationException.cs
deleted file mode 100644
index c1ea16a9b02c..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/ConfigurationException.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-
-namespace RepoUtils;
-
-public class ConfigurationException : Exception
-{
- public ConfigurationException()
- {
- }
-
- public ConfigurationException(string message) : base(message)
- {
- }
-
- public ConfigurationException(string message, Exception innerException) : base(message, innerException)
- {
- }
-}
diff --git a/dotnet/samples/GettingStarted/RepoUtils/ObjectExtensions.cs b/dotnet/samples/GettingStarted/RepoUtils/ObjectExtensions.cs
deleted file mode 100644
index 144074f96116..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/ObjectExtensions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System.Text.Json;
-
-namespace RepoUtils;
-
-public static class ObjectExtensions
-{
- private static readonly JsonSerializerOptions s_jsonOptionsCache = new() { WriteIndented = true };
-
- public static string AsJson(this object obj)
- {
- return JsonSerializer.Serialize(obj, s_jsonOptionsCache);
- }
-}
diff --git a/dotnet/samples/GettingStarted/RepoUtils/TextOutputHelperExtensions.cs b/dotnet/samples/GettingStarted/RepoUtils/TextOutputHelperExtensions.cs
deleted file mode 100644
index 965afd76045c..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/TextOutputHelperExtensions.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using Xunit.Abstractions;
-
-namespace Examples;
-
-public static class TextOutputHelperExtensions
-{
- public static void WriteLine(this ITestOutputHelper testOutputHelper, object target)
- {
- testOutputHelper.WriteLine(target.ToString());
- }
-
- public static void WriteLine(this ITestOutputHelper testOutputHelper)
- {
- testOutputHelper.WriteLine(string.Empty);
- }
-
- public static void Write(this ITestOutputHelper testOutputHelper)
- {
- testOutputHelper.WriteLine(string.Empty);
- }
-
- ///
- /// Current interface ITestOutputHelper does not have a Write method. This extension method adds it to make it analogous to Console.Write when used in Console apps.
- ///
- /// TestOutputHelper
- /// Target object to write
- public static void Write(this ITestOutputHelper testOutputHelper, object target)
- {
- testOutputHelper.WriteLine(target.ToString());
- }
-}
diff --git a/dotnet/samples/GettingStarted/RepoUtils/XunitLogger.cs b/dotnet/samples/GettingStarted/RepoUtils/XunitLogger.cs
deleted file mode 100644
index 77575ac094c9..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/XunitLogger.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
-
-namespace RepoUtils;
-
-///
-/// A logger that writes to the Xunit test output
-///
-internal sealed class XunitLogger(ITestOutputHelper output) : ILoggerFactory, ILogger, IDisposable
-{
- ///
- public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter)
- => output.WriteLine(state?.ToString());
-
- ///
- public bool IsEnabled(LogLevel logLevel) => true;
-
- ///
- public IDisposable BeginScope(TState state) where TState : notnull
- => this;
-
- ///
- public void Dispose()
- {
- // This class is marked as disposable to support the BeginScope method.
- // However, there is no need to dispose anything.
- }
-
- public ILogger CreateLogger(string categoryName) => this;
-
- public void AddProvider(ILoggerProvider provider) => throw new NotSupportedException();
-}
diff --git a/dotnet/samples/GettingStarted/RepoUtils/YourAppException.cs b/dotnet/samples/GettingStarted/RepoUtils/YourAppException.cs
deleted file mode 100644
index 28794dbb1b04..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/YourAppException.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-
-namespace RepoUtils;
-
-public class YourAppException : Exception
-{
- public YourAppException() : base()
- {
- }
-
- public YourAppException(string message) : base(message)
- {
- }
-
- public YourAppException(string message, Exception innerException) : base(message, innerException)
- {
- }
-}
diff --git a/dotnet/samples/GettingStarted/Resources/EmbeddedResource.cs b/dotnet/samples/GettingStarted/Resources/EmbeddedResource.cs
deleted file mode 100644
index 44b49a7bd78f..000000000000
--- a/dotnet/samples/GettingStarted/Resources/EmbeddedResource.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.IO;
-using System.Reflection;
-using System.Threading.Tasks;
-using RepoUtils;
-
-namespace Resources;
-
-///
-/// Resource helper to load resources embedded in the assembly. By default we embed only
-/// text files, so the helper is limited to returning text.
-///
-/// You can find information about embedded resources here:
-/// * https://learn.microsoft.com/dotnet/core/extensions/create-resource-files
-/// * https://learn.microsoft.com/dotnet/api/system.reflection.assembly.getmanifestresourcestream?view=net-7.0
-///
-/// To know which resources are embedded, check the csproj file.
-///
-internal static class EmbeddedResource
-{
- private static readonly string? s_namespace = typeof(EmbeddedResource).Namespace;
-
- internal static string Read(string fileName)
- {
- // Get the current assembly. Note: this class is in the same assembly where the embedded resources are stored.
- Assembly assembly =
- typeof(EmbeddedResource).GetTypeInfo().Assembly ??
- throw new ConfigurationException($"[{s_namespace}] {fileName} assembly not found");
-
- // Resources are mapped like types, using the namespace and appending "." (dot) and the file name
- var resourceName = $"{s_namespace}." + fileName;
- using Stream resource =
- assembly.GetManifestResourceStream(resourceName) ??
- throw new ConfigurationException($"{resourceName} resource not found");
-
- // Return the resource content, in text format.
- using var reader = new StreamReader(resource);
- return reader.ReadToEnd();
- }
-
- internal static Stream? ReadStream(string fileName)
- {
- // Get the current assembly. Note: this class is in the same assembly where the embedded resources are stored.
- Assembly assembly =
- typeof(EmbeddedResource).GetTypeInfo().Assembly ??
- throw new ConfigurationException($"[{s_namespace}] {fileName} assembly not found");
-
- // Resources are mapped like types, using the namespace and appending "." (dot) and the file name
- var resourceName = $"{s_namespace}." + fileName;
- return assembly.GetManifestResourceStream(resourceName);
- }
-
- internal static async Task> ReadAllAsync(string fileName)
- {
- await using Stream? resourceStream = ReadStream(fileName);
- using var memoryStream = new MemoryStream();
-
- // Copy the resource stream to the memory stream
- await resourceStream!.CopyToAsync(memoryStream);
-
- // Convert the memory stream's buffer to ReadOnlyMemory
- // Note: ToArray() creates a copy of the buffer, which is fine for converting to ReadOnlyMemory
- return new ReadOnlyMemory(memoryStream.ToArray());
- }
-}
diff --git a/dotnet/samples/GettingStarted/Step1_Create_Kernel.cs b/dotnet/samples/GettingStarted/Step1_Create_Kernel.cs
index 3ad56548b9d4..d6eaac6f7886 100644
--- a/dotnet/samples/GettingStarted/Step1_Create_Kernel.cs
+++ b/dotnet/samples/GettingStarted/Step1_Create_Kernel.cs
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step2_Add_Plugins.cs b/dotnet/samples/GettingStarted/Step2_Add_Plugins.cs
index 5ff7e4d0aa47..c8abeb46b01b 100644
--- a/dotnet/samples/GettingStarted/Step2_Add_Plugins.cs
+++ b/dotnet/samples/GettingStarted/Step2_Add_Plugins.cs
@@ -1,16 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
-using System.Linq;
using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.OpenApi.Extensions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step3_Yaml_Prompt.cs b/dotnet/samples/GettingStarted/Step3_Yaml_Prompt.cs
index e3c06eb71807..e12acacdfdb0 100644
--- a/dotnet/samples/GettingStarted/Step3_Yaml_Prompt.cs
+++ b/dotnet/samples/GettingStarted/Step3_Yaml_Prompt.cs
@@ -1,12 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step4_Dependency_Injection.cs b/dotnet/samples/GettingStarted/Step4_Dependency_Injection.cs
index 28544e490b67..8028ecc5fa71 100644
--- a/dotnet/samples/GettingStarted/Step4_Dependency_Injection.cs
+++ b/dotnet/samples/GettingStarted/Step4_Dependency_Injection.cs
@@ -1,15 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step5_Chat_Prompt.cs b/dotnet/samples/GettingStarted/Step5_Chat_Prompt.cs
index 4c3a1b002b51..d8b45173c085 100644
--- a/dotnet/samples/GettingStarted/Step5_Chat_Prompt.cs
+++ b/dotnet/samples/GettingStarted/Step5_Chat_Prompt.cs
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs b/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs
index 8e5a36a48c91..5768761f6bbd 100644
--- a/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs
+++ b/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs
@@ -1,12 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step7_Observability.cs b/dotnet/samples/GettingStarted/Step7_Observability.cs
index a844c2596f9c..1373eda671e4 100644
--- a/dotnet/samples/GettingStarted/Step7_Observability.cs
+++ b/dotnet/samples/GettingStarted/Step7_Observability.cs
@@ -1,15 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using RepoUtils;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/Step8_Pipelining.cs b/dotnet/samples/GettingStarted/Step8_Pipelining.cs
index 9c7d26c8eb40..53d8528865cc 100644
--- a/dotnet/samples/GettingStarted/Step8_Pipelining.cs
+++ b/dotnet/samples/GettingStarted/Step8_Pipelining.cs
@@ -1,17 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStarted/TestConfiguration.cs b/dotnet/samples/GettingStarted/TestConfiguration.cs
deleted file mode 100644
index 1ff9418fc991..000000000000
--- a/dotnet/samples/GettingStarted/TestConfiguration.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.Runtime.CompilerServices;
-using Microsoft.Extensions.Configuration;
-using RepoUtils;
-
-public sealed class TestConfiguration
-{
- private readonly IConfigurationRoot _configRoot;
- private static TestConfiguration? s_instance;
-
- private TestConfiguration(IConfigurationRoot configRoot)
- {
- this._configRoot = configRoot;
- }
-
- public static void Initialize(IConfigurationRoot configRoot)
- {
- s_instance = new TestConfiguration(configRoot);
- }
-
- public static OpenAIConfig OpenAI => LoadSection();
-
- private static T LoadSection([CallerMemberName] string? caller = null)
- {
- if (s_instance == null)
- {
- throw new InvalidOperationException(
- "TestConfiguration must be initialized with a call to Initialize(IConfigurationRoot) before accessing configuration values.");
- }
-
- if (string.IsNullOrEmpty(caller))
- {
- throw new ArgumentNullException(nameof(caller));
- }
-
- return s_instance._configRoot.GetSection(caller).Get() ??
- throw new ConfigurationNotFoundException(section: caller);
- }
-
-#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor.
- public class OpenAIConfig
- {
- public string ModelId { get; set; }
- public string ChatModelId { get; set; }
- public string EmbeddingModelId { get; set; }
- public string ApiKey { get; set; }
- }
-}
diff --git a/dotnet/samples/Concepts/AgentSyntax/AgentSyntax.csproj b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
similarity index 51%
rename from dotnet/samples/Concepts/AgentSyntax/AgentSyntax.csproj
rename to dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
index 6d01d451fefe..0ac7baf6baf9 100644
--- a/dotnet/samples/Concepts/AgentSyntax/AgentSyntax.csproj
+++ b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
@@ -1,27 +1,20 @@
-
+
+
- 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
-
- AgentSyntax
-
- net6.0
- LatestMajor
- true
+ GettingStartedWithAgents
+ net8.0
+ enable
+ enablefalse
+ true
+
- IDE0009,VSTHRD111,CS0612,CS1591,CS8618,CA1050,CA1051,CA1707,CA2007,CA5394,RCS1110,SKEXP0001,SKEXP0010,SKEXP0110
+ CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
+
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
@@ -33,19 +26,25 @@
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
- Always
-
-
+
+
-
\ No newline at end of file
+
+
diff --git a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step1_Agent.cs b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
similarity index 91%
rename from dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step1_Agent.cs
rename to dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
index eb2826de82c9..475999d2f86a 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step1_Agent.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
@@ -30,7 +26,7 @@ public async Task RunAsync()
Kernel = this.CreateKernelWithChatCompletion(),
};
- // Create a chat for agent interaction. For more, see: Example03_Chat.
+ /// Create a chat for agent interaction. For more, .
AgentGroupChat chat = new();
// Respond to user input
diff --git a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step2_Plugins.cs b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
similarity index 72%
rename from dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step2_Plugins.cs
rename to dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
index ea99b955ee04..0661155ae7d2 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step2_Plugins.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
@@ -1,13 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
-using Examples;
+using System.ComponentModel;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Plugins;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
@@ -37,7 +33,7 @@ public async Task RunAsync()
KernelPlugin plugin = KernelPluginFactory.CreateFromType();
agent.Kernel.Plugins.Add(plugin);
- // Create a chat for agent interaction. For more, see: Example03_Chat.
+ /// Create a chat for agent interaction. For more, .
AgentGroupChat chat = new();
// Respond to user input, invoking functions where appropriate.
@@ -58,4 +54,26 @@ async Task InvokeAgentAsync(string input)
}
}
}
+
+ public sealed class MenuPlugin
+ {
+ [KernelFunction, Description("Provides a list of specials from the menu.")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1024:Use properties where appropriate", Justification = "Too smart")]
+ public string GetSpecials()
+ {
+ return @"
+Special Soup: Clam Chowder
+Special Salad: Cobb Salad
+Special Drink: Chai Tea
+";
+ }
+
+ [KernelFunction, Description("Provides the price of the requested menu item.")]
+ public string GetItemPrice(
+ [Description("The name of the menu item.")]
+ string menuItem)
+ {
+ return "$9.99";
+ }
+ }
}
diff --git a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step3_Chat.cs b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
similarity index 96%
rename from dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step3_Chat.cs
rename to dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
index db356f9a5135..0c7075314fa2 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step3_Chat.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
@@ -1,15 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step4_KernelFunctionStrategies.cs b/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs
similarity index 98%
rename from dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step4_KernelFunctionStrategies.cs
rename to dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs
index 5c26354c57e1..1c7a0661286c 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step4_KernelFunctionStrategies.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs
@@ -1,13 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step5_JsonResult.cs b/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs
similarity index 95%
rename from dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step5_JsonResult.cs
rename to dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs
index acdcf90ba2f0..fd90a965a14c 100644
--- a/dotnet/samples/Concepts/AgentSyntax/Getting_Started/Step5_JsonResult.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs
@@ -1,15 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
using Resources;
-using Xunit;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/KernelSyntaxExamples/BaseTest.cs b/dotnet/samples/KernelSyntaxExamples/BaseTest.cs
deleted file mode 100644
index b2559c03ae6f..000000000000
--- a/dotnet/samples/KernelSyntaxExamples/BaseTest.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
-using RepoUtils;
-using Xunit.Abstractions;
-
-namespace Examples;
-
-public abstract class BaseTest
-{
- protected ITestOutputHelper Output { get; }
-
- protected ILoggerFactory LoggerFactory { get; }
-
- protected BaseTest(ITestOutputHelper output)
- {
- this.Output = output;
- this.LoggerFactory = new XunitLogger(output);
-
- LoadUserSecrets();
- }
-
- private static void LoadUserSecrets()
- {
- IConfigurationRoot configRoot = new ConfigurationBuilder()
- .AddJsonFile("appsettings.Development.json", true)
- .AddEnvironmentVariables()
- .AddUserSecrets()
- .Build();
-
- TestConfiguration.Initialize(configRoot);
- }
-
- ///
- /// This method can be substituted by Console.WriteLine when used in Console apps.
- ///
- /// Target object to write
- protected void WriteLine(object? target = null)
- {
- this.Output.WriteLine(target ?? string.Empty);
- }
-
- ///
- /// Current interface ITestOutputHelper does not have a Write method. This extension method adds it to make it analogous to Console.Write when used in Console apps.
- ///
- /// Target object to write
- protected void Write(object? target = null)
- {
- this.Output.WriteLine(target ?? string.Empty);
- }
-}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example20_HuggingFace.cs b/dotnet/samples/KernelSyntaxExamples/Example20_HuggingFace.cs
deleted file mode 100644
index d886a6c3b6e0..000000000000
--- a/dotnet/samples/KernelSyntaxExamples/Example20_HuggingFace.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.SemanticKernel;
-using Microsoft.SemanticKernel.ChatCompletion;
-using Microsoft.SemanticKernel.Connectors.HuggingFace;
-using Microsoft.SemanticKernel.Embeddings;
-using xRetry;
-using Xunit;
-using Xunit.Abstractions;
-
-#pragma warning disable format // Format item can be simplified
-#pragma warning disable CA1861 // Avoid constant arrays as arguments
-
-namespace Examples;
-
-// The following example shows how to use Semantic Kernel with HuggingFace API.
-public class Example20_HuggingFace : BaseTest
-{
- ///
- /// This example uses HuggingFace Inference API to access hosted models.
- /// More information here:
- ///
- [Fact]
- public async Task RunInferenceApiExampleAsync()
- {
- WriteLine("\n======== HuggingFace Inference API example ========\n");
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceTextGeneration(
- model: TestConfiguration.HuggingFace.ModelId,
- apiKey: TestConfiguration.HuggingFace.ApiKey)
- .Build();
-
- var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:");
-
- var result = await kernel.InvokeAsync(questionAnswerFunction, new() { ["input"] = "What is New York?" });
-
- WriteLine(result.GetValue());
- }
-
- [RetryFact(typeof(HttpOperationException))]
- public async Task RunInferenceApiEmbeddingAsync()
- {
- this.WriteLine("\n======= Hugging Face Inference API - Embedding Example ========\n");
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceTextEmbeddingGeneration(
- model: TestConfiguration.HuggingFace.EmbeddingModelId,
- apiKey: TestConfiguration.HuggingFace.ApiKey)
- .Build();
-
- var embeddingGenerator = kernel.GetRequiredService();
-
- // Generate embeddings for each chunk.
- var embeddings = await embeddingGenerator.GenerateEmbeddingsAsync(["John: Hello, how are you?\nRoger: Hey, I'm Roger!"]);
-
- this.WriteLine($"Generated {embeddings.Count} embeddings for the provided text");
- }
-
- [RetryFact(typeof(HttpOperationException))]
- public async Task RunStreamingExampleAsync()
- {
- WriteLine("\n======== HuggingFace zephyr-7b-beta streaming example ========\n");
-
- const string Model = "HuggingFaceH4/zephyr-7b-beta";
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceTextGeneration(
- model: Model,
- apiKey: TestConfiguration.HuggingFace.ApiKey)
- .Build();
-
- var settings = new HuggingFacePromptExecutionSettings { UseCache = false };
-
- var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:", new HuggingFacePromptExecutionSettings
- {
- UseCache = false
- });
-
- await foreach (string text in kernel.InvokePromptStreamingAsync("Question: {{$input}}; Answer:", new(settings) { ["input"] = "What is New York?" }))
- {
- this.Write(text);
- }
- }
-
- ///
- /// This example uses HuggingFace Llama 2 model and local HTTP server from Semantic Kernel repository.
- /// How to setup local HTTP server: .
- ///
- /// Additional access is required to download Llama 2 model and run it locally.
- /// How to get access:
- /// 1. Visit and complete request access form.
- /// 2. Visit and complete form "Access Llama 2 on Hugging Face".
- /// Note: Your Hugging Face account email address MUST match the email you provide on the Meta website, or your request will not be approved.
- ///
- ///
- [Fact(Skip = "Requires local model or Huggingface Pro subscription")]
- public async Task RunLlamaExampleAsync()
- {
- WriteLine("\n======== HuggingFace Llama 2 example ========\n");
-
- // HuggingFace Llama 2 model: https://huggingface.co/meta-llama/Llama-2-7b-hf
- const string Model = "meta-llama/Llama-2-7b-hf";
-
- // HuggingFace local HTTP server endpoint
- // const string Endpoint = "http://localhost:5000/completions";
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceTextGeneration(
- model: Model,
- //endpoint: Endpoint,
- apiKey: TestConfiguration.HuggingFace.ApiKey)
- .Build();
-
- var questionAnswerFunction = kernel.CreateFunctionFromPrompt("Question: {{$input}}; Answer:");
-
- var result = await kernel.InvokeAsync(questionAnswerFunction, new() { ["input"] = "What is New York?" });
-
- WriteLine(result.GetValue());
- }
-
- ///
- /// Follow steps in to setup HuggingFace local Text Generation Inference HTTP server.
- ///
- [Fact(Skip = "Requires TGI (text generation inference) deployment")]
- public async Task RunTGI_ChatCompletionAsync()
- {
- WriteLine("\n======== HuggingFace - TGI Chat Completion ========\n");
-
- // This example was run against one of the chat completion (Message API) supported models from HuggingFace, listed in here:
- // Starting a Local Docker i.e:
- // docker run --gpus all --shm-size 1g -p 8080:80 -v "F:\temp\huggingface:/data" ghcr.io/huggingface/text-generation-inference:1.4 --model-id teknium/OpenHermes-2.5-Mistral-7B
-
- // HuggingFace local HTTP server endpoint
- var endpoint = new Uri("http://localhost:8080");
-
- const string Model = "teknium/OpenHermes-2.5-Mistral-7B";
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceChatCompletion(
- model: Model,
- endpoint: endpoint)
- .Build();
-
- var chatCompletion = kernel.GetRequiredService();
- var chatHistory = new ChatHistory("You are a helpful assistant.")
- {
- new ChatMessageContent(AuthorRole.User, "What is deep learning?")
- };
-
- var result = await chatCompletion.GetChatMessageContentAsync(chatHistory);
-
- WriteLine(result.Role);
- WriteLine(result.Content);
- }
-
- ///
- /// Follow steps in to setup HuggingFace local Text Generation Inference HTTP server.
- ///
- [Fact(Skip = "Requires TGI (text generation inference) deployment")]
- public async Task RunTGI_StreamingChatCompletionAsync()
- {
- WriteLine("\n======== HuggingFace - TGI Chat Completion Streaming ========\n");
-
- // This example was run against one of the chat completion (Message API) supported models from HuggingFace, listed in here:
- // Starting a Local Docker i.e:
- // docker run --gpus all --shm-size 1g -p 8080:80 -v "F:\temp\huggingface:/data" ghcr.io/huggingface/text-generation-inference:1.4 --model-id teknium/OpenHermes-2.5-Mistral-7B
-
- // HuggingFace local HTTP server endpoint
- var endpoint = new Uri("http://localhost:8080");
-
- const string Model = "teknium/OpenHermes-2.5-Mistral-7B";
-
- Kernel kernel = Kernel.CreateBuilder()
- .AddHuggingFaceChatCompletion(
- model: Model,
- endpoint: endpoint)
- .Build();
-
- var chatCompletion = kernel.GetRequiredService();
- var chatHistory = new ChatHistory("You are a helpful assistant.")
- {
- new ChatMessageContent(AuthorRole.User, "What is deep learning?")
- };
-
- AuthorRole? role = null;
- await foreach (var chatMessageChunk in chatCompletion.GetStreamingChatMessageContentsAsync(chatHistory))
- {
- if (role is null)
- {
- role = chatMessageChunk.Role;
- Write(role);
- }
- Write(chatMessageChunk.Content);
- }
- }
-
- public Example20_HuggingFace(ITestOutputHelper output) : base(output)
- {
- }
-}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example26_AADAuth.cs b/dotnet/samples/KernelSyntaxExamples/Example26_AADAuth.cs
deleted file mode 100644
index 9c47490105a8..000000000000
--- a/dotnet/samples/KernelSyntaxExamples/Example26_AADAuth.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System.Threading.Tasks;
-using Azure.Identity;
-using Microsoft.SemanticKernel;
-using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Examples;
-
-///
-/// This example shows how to connect your app to Azure OpenAI using
-/// Azure Active Directory(AAD) authentication, as opposed to API keys.
-///
-/// The example uses , which you can configure to support
-/// multiple authentication strategies:
-///
-/// -Env vars present in Azure VMs
-/// -Azure Managed Identities
-/// -Shared tokens
-/// -etc.
-///
-public class Example26_AADAuth(ITestOutputHelper output) : BaseTest(output)
-{
- [Fact(Skip = "Setup credentials")]
- public async Task RunAsync()
- {
- WriteLine("======== SK with AAD Auth ========");
-
- // Optional: choose which authentication to support
- var authOptions = new DefaultAzureCredentialOptions
- {
- ExcludeEnvironmentCredential = true,
- ExcludeManagedIdentityCredential = true,
- ExcludeSharedTokenCacheCredential = true,
- ExcludeAzureCliCredential = true,
- ExcludeVisualStudioCredential = true,
- ExcludeVisualStudioCodeCredential = true,
- ExcludeInteractiveBrowserCredential = false,
- ExcludeAzureDeveloperCliCredential = true,
- ExcludeWorkloadIdentityCredential = true,
- ExcludeAzurePowerShellCredential = true
- };
-
- Kernel kernel = Kernel.CreateBuilder()
- // Add Azure OpenAI chat completion service using DefaultAzureCredential AAD auth
- .AddAzureOpenAIChatCompletion(
- deploymentName: TestConfiguration.AzureOpenAI.ChatDeploymentName,
- endpoint: TestConfiguration.AzureOpenAI.Endpoint,
- credentials: new DefaultAzureCredential(authOptions))
- .Build();
-
- IChatCompletionService chatGPT = kernel.GetRequiredService();
- var chatHistory = new ChatHistory();
-
- // User message
- chatHistory.AddUserMessage("Tell me a joke about hourglasses");
-
- // Bot reply
- var reply = await chatGPT.GetChatMessageContentAsync(chatHistory);
- WriteLine(reply);
-
- /* Output: Why did the hourglass go to the doctor? Because it was feeling a little run down! */
- }
-}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example44_MultiChatCompletion.cs b/dotnet/samples/KernelSyntaxExamples/Example44_MultiChatCompletion.cs
deleted file mode 100644
index 280341790a17..000000000000
--- a/dotnet/samples/KernelSyntaxExamples/Example44_MultiChatCompletion.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.SemanticKernel.ChatCompletion;
-using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Examples;
-
-// The following example shows how to use Semantic Kernel with Multiple Results Text Completion as streaming
-public class Example44_MultiChatCompletion(ITestOutputHelper output) : BaseTest(output)
-{
- [Fact]
- public Task AzureOpenAIMultiChatCompletionAsync()
- {
- WriteLine("======== Azure OpenAI - Multiple Chat Completion ========");
-
- AzureOpenAIChatCompletionService chatCompletionService = new(
- deploymentName: TestConfiguration.AzureOpenAI.ChatDeploymentName,
- endpoint: TestConfiguration.AzureOpenAI.Endpoint,
- apiKey: TestConfiguration.AzureOpenAI.ApiKey,
- modelId: TestConfiguration.AzureOpenAI.ChatModelId);
-
- return RunChatAsync(chatCompletionService);
- }
-
- [Fact]
- public Task OpenAIMultiChatCompletionAsync()
- {
- WriteLine("======== Open AI - Multiple Chat Completion ========");
-
- OpenAIChatCompletionService chatCompletionService = new(modelId: TestConfiguration.OpenAI.ChatModelId, TestConfiguration.OpenAI.ApiKey);
-
- return RunChatAsync(chatCompletionService);
- }
-
- private async Task RunChatAsync(IChatCompletionService chatCompletionService)
- {
- var chatHistory = new ChatHistory("You are a librarian, expert about books");
-
- // First user message
- chatHistory.AddUserMessage("Hi, I'm looking for book 3 different book suggestions about sci-fi");
- await MessageOutputAsync(chatHistory);
-
- var chatExecutionSettings = new OpenAIPromptExecutionSettings()
- {
- MaxTokens = 1024,
- ResultsPerPrompt = 2,
- Temperature = 1,
- TopP = 0.5,
- FrequencyPenalty = 0,
- };
-
- // First bot assistant message
- foreach (var chatMessageChoice in await chatCompletionService.GetChatMessageContentsAsync(chatHistory, chatExecutionSettings))
- {
- chatHistory.Add(chatMessageChoice!);
- await MessageOutputAsync(chatHistory);
- }
-
- WriteLine();
- }
-
- ///
- /// Outputs the last message of the chat history
- ///
- private Task MessageOutputAsync(ChatHistory chatHistory)
- {
- var message = chatHistory.Last();
-
- WriteLine($"{message.Role}: {message.Content}");
- WriteLine("------------------------");
-
- return Task.CompletedTask;
- }
-}
diff --git a/dotnet/samples/KernelSyntaxExamples/Example74_FlowOrchestrator.cs b/dotnet/samples/KernelSyntaxExamples/Example74_FlowOrchestrator.cs
deleted file mode 100644
index aa53585772f1..000000000000
--- a/dotnet/samples/KernelSyntaxExamples/Example74_FlowOrchestrator.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Text.Json;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.SemanticKernel;
-using Microsoft.SemanticKernel.ChatCompletion;
-using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Microsoft.SemanticKernel.Experimental.Orchestration;
-using Microsoft.SemanticKernel.Memory;
-using Microsoft.SemanticKernel.Plugins.Core;
-using Microsoft.SemanticKernel.Plugins.Web;
-using Microsoft.SemanticKernel.Plugins.Web.Bing;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Examples;
-
-// This example shows how to use FlowOrchestrator to execute a given flow with interaction with client.
-public class Example74_FlowOrchestrator(ITestOutputHelper output) : BaseTest(output)
-{
- private static readonly Flow s_flow = FlowSerializer.DeserializeFromYaml(@"
-name: FlowOrchestrator_Example_Flow
-goal: answer question and send email
-steps:
- - goal: What is the tallest mountain in Asia? How tall is it divided by 2?
- plugins:
- - WebSearchEnginePlugin
- - LanguageCalculatorPlugin
- provides:
- - answer
- - goal: Collect email address
- plugins:
- - ChatPlugin
- completionType: AtLeastOnce
- transitionMessage: do you want to send it to another email address?
- provides:
- - email_addresses
-
- - goal: Send email
- plugins:
- - EmailPluginV2
- requires:
- - email_addresses
- - answer
- provides:
- - email
-
-provides:
- - email
-");
-
- [Fact(Skip = "Can take more than 1 minute")]
- public async Task RunAsync()
- {
- var bingConnector = new BingConnector(TestConfiguration.Bing.ApiKey);
- var webSearchEnginePlugin = new WebSearchEnginePlugin(bingConnector);
-
- Dictionary