From 3dd55f4e0e1a4db1a6b0f39f9e997158de900252 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Tue, 16 Jan 2024 10:44:42 +0000
Subject: [PATCH 01/24] Preparing 1.1 release
---
dotnet/nuget/nuget-package.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dotnet/nuget/nuget-package.props b/dotnet/nuget/nuget-package.props
index 41dec908c035..bd20f4cd3f05 100644
--- a/dotnet/nuget/nuget-package.props
+++ b/dotnet/nuget/nuget-package.props
@@ -1,7 +1,7 @@
- 1.0.2
+ 1.1.0
$(VersionPrefix)-$(VersionSuffix)
$(VersionPrefix)
From 6f663541791f0d58fa3e3a01e19cefeb0576a63b Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Wed, 24 Apr 2024 17:02:30 +0100
Subject: [PATCH 02/24] Restructure WIP
---
.../Example01_Agent.cs | 0
.../Example02_Plugins.cs | 0
.../{AgentSyntax => Agents}/Example03_Chat.cs | 0
.../Example11_OpenAIAssistant.cs | 0
.../Example12_OpenAIAssistant_Plugins.cs | 0
...ample13_OpenAIAssistant_CodeInterpreter.cs | 0
.../Example14_OpenAIAssistant_Retrieval.cs | 0
.../Example15_OpenAIAssistant_ChartMaker.cs | 0
.../Example16_MixedChat.cs | 0
.../Agents}/Example70_Agents.cs | 0
.../Agents}/Example71_AgentDelegation.cs | 0
.../Agents}/Example72_AgentCollaboration.cs | 0
.../Agents}/Example73_AgentAuthoring.cs | 0
.../Agents}/Example75_AgentTools.cs | 0
.../Agents}/Example79_ChatCompletionAgent.cs | 0
.../Agents}/Example85_AgentCharts.cs | 0
.../{AgentSyntax => Agents}/README.md | 0
.../AudioToText}/Example82_Audio.cs | 32 -----
.../Example59_OpenAIFunctionCalling.cs | 0
.../Example98_GeminiFunctionCalling.cs | 0
.../ChatCompletion}/Example17_ChatGPT.cs | 0
.../Example33_StreamingChat.cs | 0
.../Example36_MultiCompletion.cs | 0
.../Example37_CompletionIdentity.cs | 0
.../Example44_MultiChatCompletion.cs | 0
.../Example45_MultiStreamingChatCompletion.cs | 0
.../ChatCompletion}/Example49_LogitBias.cs | 0
.../Example52_CustomOpenAIClient.cs | 0
.../Example54_AzureChatCompletionWithData.cs | 0
.../ChatCompletion}/Example61_MultipleLLMs.cs | 0
.../Example67_KernelStreaming.cs | 0
.../ChatCompletion}/Example68_GPTVision.cs | 0
.../Example87_ChatHistorySerialization.cs | 0
.../Example95_GeminiGetModelResult.cs | 0
.../Example96_GeminiChatCompletion.cs | 0
.../ChatCompletion}/Example97_GeminiVision.cs | 0
.../Example08_RetryHandler.cs | 0
.../Example40_DIContainer.cs | 0
.../Example41_HttpClientUsage.cs | 0
.../Example42_KernelBuilder.cs | 0
.../Filtering}/Example57_KernelHooks.cs | 0
.../Filtering/Example76_Filters copy 2.cs} | 0
.../Concepts/Filtering/Example76_Filters.cs | 123 ++++++++++++++++++
.../Filtering/Example76_PromptFilter.cs | 123 ++++++++++++++++++
.../Functions}/Example01_MethodFunctions.cs | 0
.../Functions}/Example03_Arguments.cs | 0
.../Example05_InlineFunctionDefinition.cs | 0
.../Functions}/Example09_FunctionTypes.cs | 0
.../Functions}/Example43_GetModelResult.cs | 0
...ateMethodFunctionsWithMultipleArguments.cs | 0
.../Example60_AdvancedMethodFunctions.cs | 0
.../Example77_StronglyTypedFunctionResult.cs | 0
.../ImageToText}/Example86_ImageToText.cs | 0
.../Kernel/Example42_KernelBuilder.cs | 103 +++++++++++++++
.../Example58_ConfigureExecutionSettings.cs | 0
.../Example62_CustomAIServiceSelector.cs | 0
.../LocalModels}/Example16_CustomLLM.cs | 0
.../LocalModels}/Example20_HuggingFace.cs | 0
.../Example88_CustomMessageAPIEndpoint.cs | 0
.../Memory}/Example14_SemanticMemory.cs | 0
.../Memory}/Example15_TextMemoryPlugin.cs | 0
.../Memory}/Example25_ReadOnlyMemoryStore.cs | 0
.../Memory}/Example55_TextChunker.cs | 0
.../Memory}/Example81_TextEmbedding.cs | 0
.../Example99_GeminiEmbeddingGeneration.cs | 0
.../Planners}/Example65_HandlebarsPlanner.cs | 0
...xample66_FunctionCallingStepwisePlanner.cs | 0
...xample10_DescribeAllPluginsAndFunctions.cs | 0
.../Example13_ConversationSummaryPlugin.cs | 0
.../Plugins}/Example21_OpenAIPlugins.cs | 0
.../Example22_OpenAIPlugin_AzureKeyVault.cs | 0
.../Plugins}/Example23_OpenAPIPlugin.cs | 0
.../Plugins}/Example24_OpenApiPlugin_Jira.cs | 0
.../Plugins}/Example35_GrpcPlugins.cs | 0
.../Plugins}/Example48_GroundednessChecks.cs | 0
.../Plugins}/Example69_MutableKernelPlugin.cs | 0
.../Plugins}/Example83_ApiManifest.cs | 0
.../Example06_TemplateLanguage.cs | 0
.../Example27_PromptFunctionsUsingChatGPT.cs | 0
.../Example30_ChatWithPrompts.cs | 0
.../Example63_ChatCompletionPrompts.cs | 0
.../Example64_MultiplePromptTemplates.cs | 0
.../RAG}/Example78_RAG.cs | 0
...Example80_FunctionCallingPlannerWithRAG.cs | 0
dotnet/samples/Concepts/README.md | 43 +++---
.../Resources/22-ai-plugin.json | 0
.../Resources/22-openapi.json | 0
.../Resources/30-system-prompt.txt | 0
.../Resources/30-user-context.txt | 0
.../Resources/30-user-prompt.txt | 0
.../Resources/65-prompt-override.handlebars | 0
.../Resources/Agents/ParrotAgent.yaml | 0
.../Resources/Agents/ToolAgent.yaml | 0
.../Agents}/travelinfo.txt | 0
.../Resources/EmbeddedResource.cs | 0
.../Resources/EnglishRoberta/dict.txt | 0
.../Resources/EnglishRoberta/encoder.json | 0
.../Resources/EnglishRoberta/vocab.bpe | 0
.../Resources/GenerateStory.yaml | 0
.../Resources/GenerateStoryHandlebars.yaml | 0
.../chat-gpt-retrieval-plugin-open-api.yaml | 0
.../Resources/sample_image.jpg | Bin
.../Resources/test_audio.wav | Bin
.../Resources/test_image.jpg | Bin
.../Resources/travelinfo.txt | 0
.../Search}/Example07_BingAndGooglePlugins.cs | 0
.../Search}/Example11_WebSearchQueries.cs | 0
.../Search}/Example84_AzureAISearchPlugin.cs | 0
.../Example32_StreamingCompletion.cs | 0
.../Concepts/TextToAudio/Example82_Audio.cs | 55 ++++++++
.../TextToImage}/Example18_DallE.cs | 0
.../RepoUtils/ConfigurationException.cs | 20 ---
.../RepoUtils/ConsoleLogger.cs | 37 ------
.../ConfigurationNotFoundException.cs | 2 -
.../samples}/EnumerableExtensions.cs | 2 -
.../InternalUtilities/samples}/Env.cs | 2 -
.../samples}/ObjectExtensions.cs | 2 -
.../samples}/PlanExtensions.cs | 2 -
.../InternalUtilities/samples}/RepoFiles.cs | 2 -
.../samples/SamplesInternalUtilities.props | 5 +
.../samples}/TextOutputHelperExtensions.cs | 2 -
.../InternalUtilities/samples}/XunitLogger.cs | 2 -
.../samples}/YourAppException.cs | 2 -
123 files changed, 430 insertions(+), 129 deletions(-)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example01_Agent.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example02_Plugins.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example03_Chat.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example11_OpenAIAssistant.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example12_OpenAIAssistant_Plugins.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example13_OpenAIAssistant_CodeInterpreter.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example14_OpenAIAssistant_Retrieval.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example15_OpenAIAssistant_ChartMaker.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/Example16_MixedChat.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example70_Agents.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example71_AgentDelegation.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example72_AgentCollaboration.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example73_AgentAuthoring.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example75_AgentTools.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example79_ChatCompletionAgent.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Agents}/Example85_AgentCharts.cs (100%)
rename dotnet/samples/Concepts/{AgentSyntax => Agents}/README.md (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/AudioToText}/Example82_Audio.cs (62%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/AutoFunctionCalling}/Example59_OpenAIFunctionCalling.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/AutoFunctionCalling}/Example98_GeminiFunctionCalling.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example17_ChatGPT.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example33_StreamingChat.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example36_MultiCompletion.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example37_CompletionIdentity.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example44_MultiChatCompletion.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example45_MultiStreamingChatCompletion.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example49_LogitBias.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example52_CustomOpenAIClient.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example54_AzureChatCompletionWithData.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example61_MultipleLLMs.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example67_KernelStreaming.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example68_GPTVision.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example87_ChatHistorySerialization.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example95_GeminiGetModelResult.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example96_GeminiChatCompletion.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ChatCompletion}/Example97_GeminiVision.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/DependencyInjection}/Example08_RetryHandler.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/DependencyInjection}/Example40_DIContainer.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/DependencyInjection}/Example41_HttpClientUsage.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/DependencyInjection}/Example42_KernelBuilder.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Filtering}/Example57_KernelHooks.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples/Example76_Filters.cs => Concepts/Filtering/Example76_Filters copy 2.cs} (100%)
create mode 100644 dotnet/samples/Concepts/Filtering/Example76_Filters.cs
create mode 100644 dotnet/samples/Concepts/Filtering/Example76_PromptFilter.cs
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example01_MethodFunctions.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example03_Arguments.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example05_InlineFunctionDefinition.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example09_FunctionTypes.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example43_GetModelResult.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example56_TemplateMethodFunctionsWithMultipleArguments.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example60_AdvancedMethodFunctions.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Functions}/Example77_StronglyTypedFunctionResult.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/ImageToText}/Example86_ImageToText.cs (100%)
create mode 100644 dotnet/samples/Concepts/Kernel/Example42_KernelBuilder.cs
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Kernel}/Example58_ConfigureExecutionSettings.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Kernel}/Example62_CustomAIServiceSelector.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/LocalModels}/Example16_CustomLLM.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/LocalModels}/Example20_HuggingFace.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/LocalModels}/Example88_CustomMessageAPIEndpoint.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example14_SemanticMemory.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example15_TextMemoryPlugin.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example25_ReadOnlyMemoryStore.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example55_TextChunker.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example81_TextEmbedding.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Memory}/Example99_GeminiEmbeddingGeneration.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Planners}/Example65_HandlebarsPlanner.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Planners}/Example66_FunctionCallingStepwisePlanner.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example10_DescribeAllPluginsAndFunctions.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example13_ConversationSummaryPlugin.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example21_OpenAIPlugins.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example22_OpenAIPlugin_AzureKeyVault.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example23_OpenAPIPlugin.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example24_OpenApiPlugin_Jira.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example35_GrpcPlugins.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example48_GroundednessChecks.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example69_MutableKernelPlugin.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Plugins}/Example83_ApiManifest.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/PromptTemplates}/Example06_TemplateLanguage.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/PromptTemplates}/Example27_PromptFunctionsUsingChatGPT.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/PromptTemplates}/Example30_ChatWithPrompts.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/PromptTemplates}/Example63_ChatCompletionPrompts.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/PromptTemplates}/Example64_MultiplePromptTemplates.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/RAG}/Example78_RAG.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/RAG}/Example80_FunctionCallingPlannerWithRAG.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/22-ai-plugin.json (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/22-openapi.json (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/30-system-prompt.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/30-user-context.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/30-user-prompt.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/65-prompt-override.handlebars (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/Agents/ParrotAgent.yaml (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/Agents/ToolAgent.yaml (100%)
rename dotnet/samples/Concepts/{AgentSyntax/Resources => Resources/Agents}/travelinfo.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/EmbeddedResource.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/EnglishRoberta/dict.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/EnglishRoberta/encoder.json (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/EnglishRoberta/vocab.bpe (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/GenerateStory.yaml (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/GenerateStoryHandlebars.yaml (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/chat-gpt-retrieval-plugin-open-api.yaml (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/sample_image.jpg (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/test_audio.wav (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/test_image.jpg (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts}/Resources/travelinfo.txt (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Search}/Example07_BingAndGooglePlugins.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Search}/Example11_WebSearchQueries.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/Search}/Example84_AzureAISearchPlugin.cs (100%)
rename dotnet/samples/{KernelSyntaxExamples => Concepts/TextGeneration}/Example32_StreamingCompletion.cs (100%)
create mode 100644 dotnet/samples/Concepts/TextToAudio/Example82_Audio.cs
rename dotnet/samples/{KernelSyntaxExamples => Concepts/TextToImage}/Example18_DallE.cs (100%)
delete mode 100644 dotnet/samples/KernelSyntaxExamples/RepoUtils/ConfigurationException.cs
delete mode 100644 dotnet/samples/KernelSyntaxExamples/RepoUtils/ConsoleLogger.cs
rename dotnet/{samples/KernelSyntaxExamples/Reliability => src/InternalUtilities/samples}/ConfigurationNotFoundException.cs (96%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/EnumerableExtensions.cs (98%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/Env.cs (97%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/ObjectExtensions.cs (94%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/PlanExtensions.cs (94%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/RepoFiles.cs (98%)
create mode 100644 dotnet/src/InternalUtilities/samples/SamplesInternalUtilities.props
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/TextOutputHelperExtensions.cs (98%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/XunitLogger.cs (97%)
rename dotnet/{samples/KernelSyntaxExamples/RepoUtils => src/InternalUtilities/samples}/YourAppException.cs (94%)
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example01_Agent.cs b/dotnet/samples/Concepts/Agents/Example01_Agent.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example01_Agent.cs
rename to dotnet/samples/Concepts/Agents/Example01_Agent.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example02_Plugins.cs b/dotnet/samples/Concepts/Agents/Example02_Plugins.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example02_Plugins.cs
rename to dotnet/samples/Concepts/Agents/Example02_Plugins.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example03_Chat.cs b/dotnet/samples/Concepts/Agents/Example03_Chat.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example03_Chat.cs
rename to dotnet/samples/Concepts/Agents/Example03_Chat.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example11_OpenAIAssistant.cs b/dotnet/samples/Concepts/Agents/Example11_OpenAIAssistant.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example11_OpenAIAssistant.cs
rename to dotnet/samples/Concepts/Agents/Example11_OpenAIAssistant.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example12_OpenAIAssistant_Plugins.cs b/dotnet/samples/Concepts/Agents/Example12_OpenAIAssistant_Plugins.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example12_OpenAIAssistant_Plugins.cs
rename to dotnet/samples/Concepts/Agents/Example12_OpenAIAssistant_Plugins.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example13_OpenAIAssistant_CodeInterpreter.cs b/dotnet/samples/Concepts/Agents/Example13_OpenAIAssistant_CodeInterpreter.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example13_OpenAIAssistant_CodeInterpreter.cs
rename to dotnet/samples/Concepts/Agents/Example13_OpenAIAssistant_CodeInterpreter.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example14_OpenAIAssistant_Retrieval.cs b/dotnet/samples/Concepts/Agents/Example14_OpenAIAssistant_Retrieval.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example14_OpenAIAssistant_Retrieval.cs
rename to dotnet/samples/Concepts/Agents/Example14_OpenAIAssistant_Retrieval.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example15_OpenAIAssistant_ChartMaker.cs b/dotnet/samples/Concepts/Agents/Example15_OpenAIAssistant_ChartMaker.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example15_OpenAIAssistant_ChartMaker.cs
rename to dotnet/samples/Concepts/Agents/Example15_OpenAIAssistant_ChartMaker.cs
diff --git a/dotnet/samples/Concepts/AgentSyntax/Example16_MixedChat.cs b/dotnet/samples/Concepts/Agents/Example16_MixedChat.cs
similarity index 100%
rename from dotnet/samples/Concepts/AgentSyntax/Example16_MixedChat.cs
rename to dotnet/samples/Concepts/Agents/Example16_MixedChat.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example70_Agents.cs b/dotnet/samples/Concepts/Agents/Example70_Agents.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example70_Agents.cs
rename to dotnet/samples/Concepts/Agents/Example70_Agents.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example71_AgentDelegation.cs b/dotnet/samples/Concepts/Agents/Example71_AgentDelegation.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example71_AgentDelegation.cs
rename to dotnet/samples/Concepts/Agents/Example71_AgentDelegation.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs b/dotnet/samples/Concepts/Agents/Example72_AgentCollaboration.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example72_AgentCollaboration.cs
rename to dotnet/samples/Concepts/Agents/Example72_AgentCollaboration.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example73_AgentAuthoring.cs b/dotnet/samples/Concepts/Agents/Example73_AgentAuthoring.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example73_AgentAuthoring.cs
rename to dotnet/samples/Concepts/Agents/Example73_AgentAuthoring.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example75_AgentTools.cs b/dotnet/samples/Concepts/Agents/Example75_AgentTools.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example75_AgentTools.cs
rename to dotnet/samples/Concepts/Agents/Example75_AgentTools.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example79_ChatCompletionAgent.cs b/dotnet/samples/Concepts/Agents/Example79_ChatCompletionAgent.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example79_ChatCompletionAgent.cs
rename to dotnet/samples/Concepts/Agents/Example79_ChatCompletionAgent.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example85_AgentCharts.cs b/dotnet/samples/Concepts/Agents/Example85_AgentCharts.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example85_AgentCharts.cs
rename to dotnet/samples/Concepts/Agents/Example85_AgentCharts.cs
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/Example82_Audio.cs
similarity index 62%
rename from dotnet/samples/KernelSyntaxExamples/Example82_Audio.cs
rename to dotnet/samples/Concepts/AudioToText/Example82_Audio.cs
index e5cb891e5894..b1bea0d283eb 100644
--- a/dotnet/samples/KernelSyntaxExamples/Example82_Audio.cs
+++ b/dotnet/samples/Concepts/AudioToText/Example82_Audio.cs
@@ -21,38 +21,6 @@ public sealed class Example82_Audio(ITestOutputHelper output) : BaseTest(output)
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/Example59_OpenAIFunctionCalling.cs b/dotnet/samples/Concepts/AutoFunctionCalling/Example59_OpenAIFunctionCalling.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example59_OpenAIFunctionCalling.cs
rename to dotnet/samples/Concepts/AutoFunctionCalling/Example59_OpenAIFunctionCalling.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example98_GeminiFunctionCalling.cs b/dotnet/samples/Concepts/AutoFunctionCalling/Example98_GeminiFunctionCalling.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example98_GeminiFunctionCalling.cs
rename to dotnet/samples/Concepts/AutoFunctionCalling/Example98_GeminiFunctionCalling.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example17_ChatGPT.cs b/dotnet/samples/Concepts/ChatCompletion/Example17_ChatGPT.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example17_ChatGPT.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example17_ChatGPT.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example33_StreamingChat.cs b/dotnet/samples/Concepts/ChatCompletion/Example33_StreamingChat.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example33_StreamingChat.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example33_StreamingChat.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example36_MultiCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Example36_MultiCompletion.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example36_MultiCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example36_MultiCompletion.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example37_CompletionIdentity.cs b/dotnet/samples/Concepts/ChatCompletion/Example37_CompletionIdentity.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example37_CompletionIdentity.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example37_CompletionIdentity.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example44_MultiChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Example44_MultiChatCompletion.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example44_MultiChatCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example44_MultiChatCompletion.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example45_MultiStreamingChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Example45_MultiStreamingChatCompletion.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example45_MultiStreamingChatCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example45_MultiStreamingChatCompletion.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example49_LogitBias.cs b/dotnet/samples/Concepts/ChatCompletion/Example49_LogitBias.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example49_LogitBias.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example49_LogitBias.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example52_CustomOpenAIClient.cs b/dotnet/samples/Concepts/ChatCompletion/Example52_CustomOpenAIClient.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example52_CustomOpenAIClient.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example52_CustomOpenAIClient.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example54_AzureChatCompletionWithData.cs b/dotnet/samples/Concepts/ChatCompletion/Example54_AzureChatCompletionWithData.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example54_AzureChatCompletionWithData.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example54_AzureChatCompletionWithData.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example61_MultipleLLMs.cs b/dotnet/samples/Concepts/ChatCompletion/Example61_MultipleLLMs.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example61_MultipleLLMs.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example61_MultipleLLMs.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example67_KernelStreaming.cs b/dotnet/samples/Concepts/ChatCompletion/Example67_KernelStreaming.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example67_KernelStreaming.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example67_KernelStreaming.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example68_GPTVision.cs b/dotnet/samples/Concepts/ChatCompletion/Example68_GPTVision.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example68_GPTVision.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example68_GPTVision.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example87_ChatHistorySerialization.cs b/dotnet/samples/Concepts/ChatCompletion/Example87_ChatHistorySerialization.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example87_ChatHistorySerialization.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example87_ChatHistorySerialization.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example95_GeminiGetModelResult.cs b/dotnet/samples/Concepts/ChatCompletion/Example95_GeminiGetModelResult.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example95_GeminiGetModelResult.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example95_GeminiGetModelResult.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example96_GeminiChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/Example96_GeminiChatCompletion.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example96_GeminiChatCompletion.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example96_GeminiChatCompletion.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example97_GeminiVision.cs b/dotnet/samples/Concepts/ChatCompletion/Example97_GeminiVision.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example97_GeminiVision.cs
rename to dotnet/samples/Concepts/ChatCompletion/Example97_GeminiVision.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example08_RetryHandler.cs b/dotnet/samples/Concepts/DependencyInjection/Example08_RetryHandler.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example08_RetryHandler.cs
rename to dotnet/samples/Concepts/DependencyInjection/Example08_RetryHandler.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example40_DIContainer.cs b/dotnet/samples/Concepts/DependencyInjection/Example40_DIContainer.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example40_DIContainer.cs
rename to dotnet/samples/Concepts/DependencyInjection/Example40_DIContainer.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example41_HttpClientUsage.cs b/dotnet/samples/Concepts/DependencyInjection/Example41_HttpClientUsage.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example41_HttpClientUsage.cs
rename to dotnet/samples/Concepts/DependencyInjection/Example41_HttpClientUsage.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example42_KernelBuilder.cs b/dotnet/samples/Concepts/DependencyInjection/Example42_KernelBuilder.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example42_KernelBuilder.cs
rename to dotnet/samples/Concepts/DependencyInjection/Example42_KernelBuilder.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example57_KernelHooks.cs b/dotnet/samples/Concepts/Filtering/Example57_KernelHooks.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example57_KernelHooks.cs
rename to dotnet/samples/Concepts/Filtering/Example57_KernelHooks.cs
diff --git a/dotnet/samples/KernelSyntaxExamples/Example76_Filters.cs b/dotnet/samples/Concepts/Filtering/Example76_Filters copy 2.cs
similarity index 100%
rename from dotnet/samples/KernelSyntaxExamples/Example76_Filters.cs
rename to dotnet/samples/Concepts/Filtering/Example76_Filters copy 2.cs
diff --git a/dotnet/samples/Concepts/Filtering/Example76_Filters.cs b/dotnet/samples/Concepts/Filtering/Example76_Filters.cs
new file mode 100644
index 000000000000..aa7818ebc8a7
--- /dev/null
+++ b/dotnet/samples/Concepts/Filtering/Example76_Filters.cs
@@ -0,0 +1,123 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.SemanticKernel;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Examples;
+
+public class Example76_Filters(ITestOutputHelper output) : BaseTest(output)
+{
+ ///
+ /// Shows how to use function and prompt filters in Kernel.
+ ///
+ [Fact]
+ public async Task FunctionAndPromptFiltersAsync()
+ {
+ var builder = Kernel.CreateBuilder();
+
+ builder.AddAzureOpenAIChatCompletion(
+ deploymentName: TestConfiguration.AzureOpenAI.ChatDeploymentName,
+ endpoint: TestConfiguration.AzureOpenAI.Endpoint,
+ apiKey: TestConfiguration.AzureOpenAI.ApiKey);
+
+ builder.Services.AddSingleton(this.Output);
+
+ // Add filters with DI
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+
+ var kernel = builder.Build();
+
+ // Add filter without DI
+ kernel.PromptFilters.Add(new FirstPromptFilter(this.Output));
+
+ var function = kernel.CreateFunctionFromPrompt("What is Seattle", functionName: "MyFunction");
+ kernel.Plugins.Add(KernelPluginFactory.CreateFromFunctions("MyPlugin", functions: [function]));
+ var result = await kernel.InvokeAsync(kernel.Plugins["MyPlugin"]["MyFunction"]);
+
+ WriteLine(result);
+ }
+
+ #region Filters
+
+ private sealed class FirstFunctionFilter(ITestOutputHelper output) : IFunctionFilter
+ {
+ private readonly ITestOutputHelper _output = output;
+
+ public void OnFunctionInvoking(FunctionInvokingContext context) =>
+ this._output.WriteLine($"{nameof(FirstFunctionFilter)}.{nameof(OnFunctionInvoking)} - {context.Function.PluginName}.{context.Function.Name}");
+
+ public void OnFunctionInvoked(FunctionInvokedContext context) =>
+ this._output.WriteLine($"{nameof(FirstFunctionFilter)}.{nameof(OnFunctionInvoked)} - {context.Function.PluginName}.{context.Function.Name}");
+ }
+
+ private sealed class SecondFunctionFilter(ITestOutputHelper output) : IFunctionFilter
+ {
+ private readonly ITestOutputHelper _output = output;
+
+ public void OnFunctionInvoking(FunctionInvokingContext context) =>
+ this._output.WriteLine($"{nameof(SecondFunctionFilter)}.{nameof(OnFunctionInvoking)} - {context.Function.PluginName}.{context.Function.Name}");
+
+ public void OnFunctionInvoked(FunctionInvokedContext context) =>
+ this._output.WriteLine($"{nameof(SecondFunctionFilter)}.{nameof(OnFunctionInvoked)} - {context.Function.PluginName}.{context.Function.Name}");
+ }
+
+ private sealed class FirstPromptFilter(ITestOutputHelper output) : IPromptFilter
+ {
+ private readonly ITestOutputHelper _output = output;
+
+ public void OnPromptRendering(PromptRenderingContext context) =>
+ this._output.WriteLine($"{nameof(FirstPromptFilter)}.{nameof(OnPromptRendering)} - {context.Function.PluginName}.{context.Function.Name}");
+
+ public void OnPromptRendered(PromptRenderedContext context) =>
+ this._output.WriteLine($"{nameof(FirstPromptFilter)}.{nameof(OnPromptRendered)} - {context.Function.PluginName}.{context.Function.Name}");
+ }
+
+ #endregion
+
+ #region Filter capabilities
+
+ private sealed class FunctionFilterExample : IFunctionFilter
+ {
+ public void OnFunctionInvoked(FunctionInvokedContext context)
+ {
+ // Example: get function result value
+ var value = context.Result.GetValue
@@ -81,5 +82,16 @@
-
+
+
+
+ PreserveNewest
+
+
+
+
+ Always
+
+
+
diff --git a/dotnet/samples/Concepts/Planners/Example66_FunctionCallingStepwisePlanner.cs b/dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs
similarity index 90%
rename from dotnet/samples/Concepts/Planners/Example66_FunctionCallingStepwisePlanner.cs
rename to dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs
index 90ec7817bc54..336dddf34b4b 100644
--- a/dotnet/samples/Concepts/Planners/Example66_FunctionCallingStepwisePlanner.cs
+++ b/dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs
@@ -7,7 +7,7 @@
namespace Examples;
-public class Example66_FunctionCallingStepwisePlanner(ITestOutputHelper output) : BaseTest(output)
+public class FunctionCallingStepwisePlanner(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
@@ -26,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/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs b/dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
index 70216900be03..461d1adffdc6 100644
--- a/dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
+++ b/dotnet/samples/Concepts/RAG/WithFunctionCallingStepwisePlanner.cs
@@ -27,7 +27,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)
{
From 71a86fede118b9380971f35527201ca1a8091fe7 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Thu, 25 Apr 2024 18:28:31 +0100
Subject: [PATCH 08/24] More renaming
---
.../samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs | 2 +-
.../{ExecutionSettings.cs => ConfigureExecutionSettings.cs} | 4 ++--
...{MemoryStore_ReadOnly.cs => MemoryStore_CustomReadOnly.cs} | 2 +-
...anticTextMemoryUsage.cs => SemanticTextMemory_Building.cs} | 2 +-
.../Memory/{TextEmbedding.cs => TextChunkingAndEmbedding.cs} | 2 +-
...ation.cs => TextMemoryPlugin_GeminiEmbeddingGeneration.cs} | 2 +-
...PluginUsage.cs => TextMemoryPlugin_MultipleMemoryStore.cs} | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
rename dotnet/samples/Concepts/Kernel/{ExecutionSettings.cs => ConfigureExecutionSettings.cs} (95%)
rename dotnet/samples/Concepts/Memory/{MemoryStore_ReadOnly.cs => MemoryStore_CustomReadOnly.cs} (99%)
rename dotnet/samples/Concepts/Memory/{SemanticTextMemoryUsage.cs => SemanticTextMemory_Building.cs} (98%)
rename dotnet/samples/Concepts/Memory/{TextEmbedding.cs => TextChunkingAndEmbedding.cs} (98%)
rename dotnet/samples/Concepts/Memory/{Gemini_EmbeddingGeneration.cs => TextMemoryPlugin_GeminiEmbeddingGeneration.cs} (99%)
rename dotnet/samples/Concepts/Memory/{Plugin_TextMemoryPluginUsage.cs => TextMemoryPlugin_MultipleMemoryStore.cs} (99%)
diff --git a/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
index 3ad1c3d15479..ec6da2fa4542 100644
--- a/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
+++ b/dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletion.cs
@@ -7,7 +7,7 @@
namespace Examples;
// The following example shows how to use Semantic Kernel with OpenAI ChatGPT API
-public class UsingChatGPT(ITestOutputHelper output) : BaseTest(output)
+public class OpenAI_ChatCompletion(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task OpenAIChatSampleAsync()
diff --git a/dotnet/samples/Concepts/Kernel/ExecutionSettings.cs b/dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
similarity index 95%
rename from dotnet/samples/Concepts/Kernel/ExecutionSettings.cs
rename to dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
index c05a1687d110..0e9edc6833b2 100644
--- a/dotnet/samples/Concepts/Kernel/ExecutionSettings.cs
+++ b/dotnet/samples/Concepts/Kernel/ConfigureExecutionSettings.cs
@@ -7,7 +7,7 @@
namespace Examples;
-public sealed class ExecutionSettings(ITestOutputHelper output) : BaseTest(output)
+public sealed class ConfigureExecutionSettings(ITestOutputHelper output) : BaseTest(output)
{
///
/// Show how to configure model execution settings
@@ -15,7 +15,7 @@ public sealed class ExecutionSettings(ITestOutputHelper output) : BaseTest(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/Concepts/Memory/MemoryStore_ReadOnly.cs b/dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
similarity index 99%
rename from dotnet/samples/Concepts/Memory/MemoryStore_ReadOnly.cs
rename to dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
index fe0f2421b4f8..219230c78978 100644
--- a/dotnet/samples/Concepts/Memory/MemoryStore_ReadOnly.cs
+++ b/dotnet/samples/Concepts/Memory/MemoryStore_CustomReadOnly.cs
@@ -16,7 +16,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 MemoryStore_ReadOnly(ITestOutputHelper output) : BaseTest(output)
+public class MemoryStore_CustomReadOnly(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/Concepts/Memory/SemanticTextMemoryUsage.cs b/dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
similarity index 98%
rename from dotnet/samples/Concepts/Memory/SemanticTextMemoryUsage.cs
rename to dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
index bd09f99fbe0c..45baf297dfaf 100644
--- a/dotnet/samples/Concepts/Memory/SemanticTextMemoryUsage.cs
+++ b/dotnet/samples/Concepts/Memory/SemanticTextMemory_Building.cs
@@ -15,7 +15,7 @@ namespace Examples;
* Semantic Memory allows to store your data like traditional DBs,
* adding the ability to query it using natural language.
*/
-public class SemanticTextMemoryUsage(ITestOutputHelper output) : BaseTest(output)
+public class SemanticTextMemory_Building(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "SKGitHub";
diff --git a/dotnet/samples/Concepts/Memory/TextEmbedding.cs b/dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
similarity index 98%
rename from dotnet/samples/Concepts/Memory/TextEmbedding.cs
rename to dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
index 3d0757d4c104..ead9f2416de0 100644
--- a/dotnet/samples/Concepts/Memory/TextEmbedding.cs
+++ b/dotnet/samples/Concepts/Memory/TextChunkingAndEmbedding.cs
@@ -7,7 +7,7 @@
namespace Examples;
-public class 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/Concepts/Memory/Gemini_EmbeddingGeneration.cs b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
similarity index 99%
rename from dotnet/samples/Concepts/Memory/Gemini_EmbeddingGeneration.cs
rename to dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
index 8d7e006b698a..c2e50575bd26 100644
--- a/dotnet/samples/Concepts/Memory/Gemini_EmbeddingGeneration.cs
+++ b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_GeminiEmbeddingGeneration.cs
@@ -11,7 +11,7 @@ namespace Examples;
///
/// Represents an example class for Gemini Embedding Generation with volatile memory store.
///
-public sealed class Gemini_EmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
+public sealed class TextMemoryPlugin_GeminiEmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "aboutMe";
diff --git a/dotnet/samples/Concepts/Memory/Plugin_TextMemoryPluginUsage.cs b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
similarity index 99%
rename from dotnet/samples/Concepts/Memory/Plugin_TextMemoryPluginUsage.cs
rename to dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
index b06aff1b1ec7..c53e59433b14 100644
--- a/dotnet/samples/Concepts/Memory/Plugin_TextMemoryPluginUsage.cs
+++ b/dotnet/samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs
@@ -21,7 +21,7 @@
namespace Examples;
-public class Plugin_TextMemoryPlugin(ITestOutputHelper output) : BaseTest(output)
+public class TextMemoryPlugin_MultipleMemoryStore(ITestOutputHelper output) : BaseTest(output)
{
private const string MemoryCollectionName = "aboutMe";
From d59c7d99a1080a619c9e2e0208fc961d6a728faa Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 12:06:40 +0100
Subject: [PATCH 09/24] minimizing namespaces and ajusting SDK for projects
---
dotnet/Directory.Packages.props | 2 +
dotnet/samples/Concepts/Concepts.csproj | 6 +-
dotnet/samples/GettingStarted/BaseTest.cs | 52 --------------
.../GettingStarted/GettingStarted.csproj | 10 ++-
.../RepoUtils/ConfigurationException.cs | 20 ------
.../ConfigurationNotFoundException.cs | 32 ---------
.../samples/GettingStarted/RepoUtils/Env.cs | 36 ----------
.../RepoUtils/ObjectExtensions.cs | 15 -----
.../RepoUtils/TextOutputHelperExtensions.cs | 33 ---------
.../GettingStarted/RepoUtils/XunitLogger.cs | 35 ----------
.../RepoUtils/YourAppException.cs | 20 ------
.../Resources/EmbeddedResource.cs | 67 -------------------
.../GettingStarted/Step1_Create_Kernel.cs | 4 --
.../GettingStarted/Step2_Add_Plugins.cs | 6 --
.../GettingStarted/Step3_Yaml_Prompt.cs | 4 --
.../Step4_Dependency_Injection.cs | 6 --
.../GettingStarted/Step5_Chat_Prompt.cs | 4 --
.../GettingStarted/Step6_Responsible_AI.cs | 4 --
.../GettingStarted/Step7_Observability.cs | 6 --
.../GettingStarted/Step8_Pipelining.cs | 8 ---
.../GettingStarted/TestConfiguration.cs | 50 --------------
.../LearnResources/LearnResources.csproj | 9 ++-
.../LearnResources/MicrosoftLearn/Planner.cs | 3 -
.../samples}/EmbeddedResource.cs | 0
24 files changed, 22 insertions(+), 410 deletions(-)
delete mode 100644 dotnet/samples/GettingStarted/BaseTest.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/ConfigurationException.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/ConfigurationNotFoundException.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/Env.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/ObjectExtensions.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/TextOutputHelperExtensions.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/XunitLogger.cs
delete mode 100644 dotnet/samples/GettingStarted/RepoUtils/YourAppException.cs
delete mode 100644 dotnet/samples/GettingStarted/Resources/EmbeddedResource.cs
delete mode 100644 dotnet/samples/GettingStarted/TestConfiguration.cs
rename dotnet/{samples/Concepts/Resources => src/InternalUtilities/samples}/EmbeddedResource.cs (100%)
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/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index d325f40d0b8c..1a1f8374d1e6 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -8,14 +8,15 @@
false
true
- Concepts
+ Concepts2
net8.0
CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110
Library
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
+ false
+ false
@@ -92,6 +93,5 @@
Always
-
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..c35cbeb6ff41 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -1,10 +1,11 @@
-
+
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
QuickStart
+ enable
net8.0
true
false
@@ -24,6 +25,7 @@
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -46,6 +48,8 @@
+
+
@@ -55,4 +59,8 @@
+
+
+
+
\ No newline at end of file
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/ConfigurationNotFoundException.cs b/dotnet/samples/GettingStarted/RepoUtils/ConfigurationNotFoundException.cs
deleted file mode 100644
index bae05dc4e3a0..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/ConfigurationNotFoundException.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-
-namespace RepoUtils;
-
-public sealed class ConfigurationNotFoundException : Exception
-{
- public string? Section { get; }
- public string? Key { get; }
-
- public ConfigurationNotFoundException(string section, string key)
- : base($"Configuration key '{section}:{key}' not found")
- {
- this.Section = section;
- this.Key = key;
- }
-
- public ConfigurationNotFoundException(string section)
- : base($"Configuration section '{section}' not found")
- {
- this.Section = section;
- }
-
- public ConfigurationNotFoundException() : base()
- {
- }
-
- public ConfigurationNotFoundException(string? message, Exception? innerException) : base(message, innerException)
- {
- }
-}
diff --git a/dotnet/samples/GettingStarted/RepoUtils/Env.cs b/dotnet/samples/GettingStarted/RepoUtils/Env.cs
deleted file mode 100644
index e2e1de5ff781..000000000000
--- a/dotnet/samples/GettingStarted/RepoUtils/Env.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System;
-using Microsoft.Extensions.Configuration;
-
-namespace RepoUtils;
-
-internal sealed class Env
-{
- ///
- /// Simple helper used to load env vars and secrets like credentials,
- /// to avoid hard coding them in the sample code
- ///
- /// Secret name / Env var name
- /// Value found in Secret Manager or Environment Variable
- internal static string Var(string name)
- {
- var configuration = new ConfigurationBuilder()
- .AddUserSecrets()
- .Build();
-
- var value = configuration[name];
- if (!string.IsNullOrEmpty(value))
- {
- return value;
- }
-
- value = Environment.GetEnvironmentVariable(name);
- if (string.IsNullOrEmpty(value))
- {
- throw new YourAppException($"Secret / Env var not set: {name}");
- }
-
- return value;
- }
-}
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 7384722c0eea..5a0a9557b43e 100644
--- a/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs
+++ b/dotnet/samples/GettingStarted/Step6_Responsible_AI.cs
@@ -1,11 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-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 0010813b2c48..83826998b161 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/LearnResources/LearnResources.csproj b/dotnet/samples/LearnResources/LearnResources.csproj
index a5cf2ee36005..9646f13bba38 100644
--- a/dotnet/samples/LearnResources/LearnResources.csproj
+++ b/dotnet/samples/LearnResources/LearnResources.csproj
@@ -1,4 +1,4 @@
-
+
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
@@ -7,6 +7,7 @@
net8.0
true
+ enable
false
CS8618,IDE0009,CA1051,CA1050,CA1707,CA2007,VSTHRD111,CS1591,RCS1110,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0101
@@ -29,6 +30,7 @@
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -44,6 +46,7 @@
+
@@ -62,4 +65,8 @@
Always
+
+
+
+
\ No newline at end of file
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/Planner.cs b/dotnet/samples/LearnResources/MicrosoftLearn/Planner.cs
index 1f88ec099165..9f527b76a771 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/Planner.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/Planner.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-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 Plugins;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/Concepts/Resources/EmbeddedResource.cs b/dotnet/src/InternalUtilities/samples/EmbeddedResource.cs
similarity index 100%
rename from dotnet/samples/Concepts/Resources/EmbeddedResource.cs
rename to dotnet/src/InternalUtilities/samples/EmbeddedResource.cs
From f8c9bf07d39aa149cad352bf86bd00598003b083 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 12:21:57 +0100
Subject: [PATCH 10/24] Adding Folder for Sample utilities to improve
visibility
---
dotnet/samples/GettingStarted/GettingStarted.csproj | 1 +
dotnet/samples/LearnResources/MicrosoftLearn/AIServices.cs | 3 ---
dotnet/samples/LearnResources/MicrosoftLearn/BaseTest.cs | 2 --
.../LearnResources/MicrosoftLearn/ConfiguringPrompts.cs | 4 ----
.../LearnResources/MicrosoftLearn/CreatingFunctions.cs | 3 ---
.../LearnResources/MicrosoftLearn/FunctionsWithinPrompts.cs | 5 -----
dotnet/samples/LearnResources/MicrosoftLearn/Plugin.cs | 4 ----
dotnet/samples/LearnResources/MicrosoftLearn/Prompts.cs | 3 ---
.../LearnResources/MicrosoftLearn/SerializingPrompts.cs | 6 ------
dotnet/samples/LearnResources/MicrosoftLearn/Templates.cs | 5 -----
.../LearnResources/MicrosoftLearn/TestConfiguration.cs | 1 -
.../samples/LearnResources/MicrosoftLearn/UsingTheKernel.cs | 3 ---
dotnet/samples/LearnResources/Plugins/MathPlugin.cs | 1 -
dotnet/samples/LearnResources/Plugins/MathSolver.cs | 1 -
.../samples/{ => InternalUtilities}/BaseTest.cs | 0
.../ConfigurationNotFoundException.cs | 0
.../samples/{ => InternalUtilities}/EmbeddedResource.cs | 0
.../samples/{ => InternalUtilities}/EnumerableExtensions.cs | 0
.../samples/{ => InternalUtilities}/Env.cs | 0
.../samples/{ => InternalUtilities}/ObjectExtensions.cs | 0
.../samples/{ => InternalUtilities}/RepoFiles.cs | 0
.../{ => InternalUtilities}/SamplesInternalUtilities.props | 0
.../samples/{ => InternalUtilities}/TestConfiguration.cs | 0
.../{ => InternalUtilities}/TextOutputHelperExtensions.cs | 0
.../samples/{ => InternalUtilities}/XunitLogger.cs | 0
.../samples/{ => InternalUtilities}/YourAppException.cs | 0
26 files changed, 1 insertion(+), 41 deletions(-)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/BaseTest.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/ConfigurationNotFoundException.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/EmbeddedResource.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/EnumerableExtensions.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/Env.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/ObjectExtensions.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/RepoFiles.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/SamplesInternalUtilities.props (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/TestConfiguration.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/TextOutputHelperExtensions.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/XunitLogger.cs (100%)
rename dotnet/src/InternalUtilities/samples/{ => InternalUtilities}/YourAppException.cs (100%)
diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/GettingStarted.csproj
index c35cbeb6ff41..052b1b2d1898 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -48,6 +48,7 @@
+
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/AIServices.cs b/dotnet/samples/LearnResources/MicrosoftLearn/AIServices.cs
index 1817350513e7..65a66229b0f8 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/AIServices.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/AIServices.cs
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/BaseTest.cs b/dotnet/samples/LearnResources/MicrosoftLearn/BaseTest.cs
index 738f065c70b7..5716e8cb2f0e 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/BaseTest.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/BaseTest.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/ConfiguringPrompts.cs b/dotnet/samples/LearnResources/MicrosoftLearn/ConfiguringPrompts.cs
index bce40826e44b..ef73d3c2b8f5 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/ConfiguringPrompts.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/ConfiguringPrompts.cs
@@ -1,13 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Plugins.Core;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/CreatingFunctions.cs b/dotnet/samples/LearnResources/MicrosoftLearn/CreatingFunctions.cs
index d18324f2c281..0379c58e3274 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/CreatingFunctions.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/CreatingFunctions.cs
@@ -1,12 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Plugins;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/FunctionsWithinPrompts.cs b/dotnet/samples/LearnResources/MicrosoftLearn/FunctionsWithinPrompts.cs
index 3292fb359ba7..bb7c34338f03 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/FunctionsWithinPrompts.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/FunctionsWithinPrompts.cs
@@ -1,14 +1,9 @@
// 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.Plugins.Core;
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/Plugin.cs b/dotnet/samples/LearnResources/MicrosoftLearn/Plugin.cs
index 9888313a24d1..d68482a831ac 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/Plugin.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/Plugin.cs
@@ -1,13 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/Prompts.cs b/dotnet/samples/LearnResources/MicrosoftLearn/Prompts.cs
index 3f32f698f8eb..29f89c037e8d 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/Prompts.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/Prompts.cs
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/SerializingPrompts.cs b/dotnet/samples/LearnResources/MicrosoftLearn/SerializingPrompts.cs
index b939b4c31890..5f0be6fa6289 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/SerializingPrompts.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/SerializingPrompts.cs
@@ -1,16 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Reflection;
-using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Plugins.Core;
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/Templates.cs b/dotnet/samples/LearnResources/MicrosoftLearn/Templates.cs
index 2b3d90d3e37d..ae705e994a76 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/Templates.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/Templates.cs
@@ -1,13 +1,8 @@
// 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.PromptTemplates.Handlebars;
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/TestConfiguration.cs b/dotnet/samples/LearnResources/MicrosoftLearn/TestConfiguration.cs
index 01108b8827dc..d6df5f215b4c 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/TestConfiguration.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/TestConfiguration.cs
@@ -1,6 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.Configuration;
diff --git a/dotnet/samples/LearnResources/MicrosoftLearn/UsingTheKernel.cs b/dotnet/samples/LearnResources/MicrosoftLearn/UsingTheKernel.cs
index 99daa03023bb..400c5f29eb11 100644
--- a/dotnet/samples/LearnResources/MicrosoftLearn/UsingTheKernel.cs
+++ b/dotnet/samples/LearnResources/MicrosoftLearn/UsingTheKernel.cs
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.Threading.Tasks;
//
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Core;
//
-using Xunit;
-using Xunit.Abstractions;
namespace Examples;
diff --git a/dotnet/samples/LearnResources/Plugins/MathPlugin.cs b/dotnet/samples/LearnResources/Plugins/MathPlugin.cs
index 101f03505d2a..a0b6bfa7c30a 100644
--- a/dotnet/samples/LearnResources/Plugins/MathPlugin.cs
+++ b/dotnet/samples/LearnResources/Plugins/MathPlugin.cs
@@ -1,6 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
-using System;
using System.ComponentModel;
using Microsoft.SemanticKernel;
diff --git a/dotnet/samples/LearnResources/Plugins/MathSolver.cs b/dotnet/samples/LearnResources/Plugins/MathSolver.cs
index 78454e2599cb..eb305c3f1928 100644
--- a/dotnet/samples/LearnResources/Plugins/MathSolver.cs
+++ b/dotnet/samples/LearnResources/Plugins/MathSolver.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
using System.ComponentModel;
-using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Planning.Handlebars;
diff --git a/dotnet/src/InternalUtilities/samples/BaseTest.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/BaseTest.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
diff --git a/dotnet/src/InternalUtilities/samples/ConfigurationNotFoundException.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/ConfigurationNotFoundException.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/ConfigurationNotFoundException.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/ConfigurationNotFoundException.cs
diff --git a/dotnet/src/InternalUtilities/samples/EmbeddedResource.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/EmbeddedResource.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/EmbeddedResource.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/EmbeddedResource.cs
diff --git a/dotnet/src/InternalUtilities/samples/EnumerableExtensions.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/EnumerableExtensions.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/EnumerableExtensions.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/EnumerableExtensions.cs
diff --git a/dotnet/src/InternalUtilities/samples/Env.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/Env.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs
diff --git a/dotnet/src/InternalUtilities/samples/ObjectExtensions.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/ObjectExtensions.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/ObjectExtensions.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/ObjectExtensions.cs
diff --git a/dotnet/src/InternalUtilities/samples/RepoFiles.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/RepoFiles.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/RepoFiles.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/RepoFiles.cs
diff --git a/dotnet/src/InternalUtilities/samples/SamplesInternalUtilities.props b/dotnet/src/InternalUtilities/samples/InternalUtilities/SamplesInternalUtilities.props
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/SamplesInternalUtilities.props
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/SamplesInternalUtilities.props
diff --git a/dotnet/src/InternalUtilities/samples/TestConfiguration.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/TestConfiguration.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/TestConfiguration.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/TestConfiguration.cs
diff --git a/dotnet/src/InternalUtilities/samples/TextOutputHelperExtensions.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/TextOutputHelperExtensions.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs
diff --git a/dotnet/src/InternalUtilities/samples/XunitLogger.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/XunitLogger.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs
diff --git a/dotnet/src/InternalUtilities/samples/YourAppException.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/YourAppException.cs
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/YourAppException.cs
rename to dotnet/src/InternalUtilities/samples/InternalUtilities/YourAppException.cs
From a3dc27a04e36a40f6d0a7cde54ae90143cd6d7e3 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 12:24:59 +0100
Subject: [PATCH 11/24] Adjustments
---
dotnet/samples/GettingStarted/GettingStarted.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/GettingStarted.csproj
index 052b1b2d1898..73e465f45ffd 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -3,7 +3,7 @@
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
- QuickStart
+ GettingStarted
enable
net8.0
From dd9bf2a8a51bc2d3d4f861501b8901312fd9aece Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 12:40:50 +0100
Subject: [PATCH 12/24] Typo fix
---
.../Concepts/DependencyInjection/HttpClient_Resiliency.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
index d3053650e381..eb4e26c7cb48 100644
--- a/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
+++ b/dotnet/samples/Concepts/DependencyInjection/HttpClient_Resiliency.cs
@@ -12,7 +12,7 @@ namespace Examples;
public class HttpClient_Resiliency(ITestOutputHelper output) : BaseTest(output)
{
///
- /// Demostrates the usage of the HttpClientFactory with a custom resilience policy.
+ /// Demonstrates the usage of the HttpClientFactory with a custom resilience policy.
///
[Fact]
public async Task RunAsync()
From 447bc75a7f310c4c7bdf4555f06a8ed6c249f9fd Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 14:42:39 +0100
Subject: [PATCH 13/24] Warning fix
---
.../samples/Concepts/Agents/Legacy_Agents.cs | 4 +-
dotnet/samples/Concepts/Filtering/Filters.cs | 1 +
...ner.cs => FunctionCallStepwisePlanning.cs} | 2 +-
.../{Handlebars.cs => HandlebarsPlanning.cs} | 2 +-
.../Resources/Plugins/LegacyMenuPlugin.cs | 75 +++++++++++++++++++
.../Concepts/Resources/Plugins/MenuPlugin.cs | 6 ++
.../GettingStarted/Step6_Responsible_AI.cs | 5 --
.../Memory/AzureCosmosDBMongoDB/DataHelper.cs | 4 +-
...OnnxTextEmbeddingGenerationServiceTests.cs | 16 ++--
.../samples/InternalUtilities/BaseTest.cs | 1 -
.../samples/InternalUtilities/Env.cs | 2 +
.../TextOutputHelperExtensions.cs | 2 -
.../samples/InternalUtilities/XunitLogger.cs | 1 -
.../SamplesInternalUtilities.props | 0
14 files changed, 98 insertions(+), 23 deletions(-)
rename dotnet/samples/Concepts/Planners/{FunctionCallingStepwisePlanner.cs => FunctionCallStepwisePlanning.cs} (95%)
rename dotnet/samples/Concepts/Planners/{Handlebars.cs => HandlebarsPlanning.cs} (99%)
create mode 100644 dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
rename dotnet/src/InternalUtilities/samples/{InternalUtilities => }/SamplesInternalUtilities.props (100%)
diff --git a/dotnet/samples/Concepts/Agents/Legacy_Agents.cs b/dotnet/samples/Concepts/Agents/Legacy_Agents.cs
index 699e96e0ac3a..b3c5f75e9c9a 100644
--- a/dotnet/samples/Concepts/Agents/Legacy_Agents.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_Agents.cs
@@ -54,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/Concepts/Filtering/Filters.cs b/dotnet/samples/Concepts/Filtering/Filters.cs
index 7ca46cf30527..906a91874836 100644
--- a/dotnet/samples/Concepts/Filtering/Filters.cs
+++ b/dotnet/samples/Concepts/Filtering/Filters.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
diff --git a/dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs b/dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
similarity index 95%
rename from dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs
rename to dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
index 960219969336..25bf9dec642d 100644
--- a/dotnet/samples/Concepts/Planners/FunctionCallingStepwisePlanner.cs
+++ b/dotnet/samples/Concepts/Planners/FunctionCallStepwisePlanning.cs
@@ -6,7 +6,7 @@
namespace Examples;
-public class FunctionCallingStepwisePlanner(ITestOutputHelper output) : BaseTest(output)
+public class FunctionCallStepwisePlanning(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
diff --git a/dotnet/samples/Concepts/Planners/Handlebars.cs b/dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
similarity index 99%
rename from dotnet/samples/Concepts/Planners/Handlebars.cs
rename to dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
index 747dab8a0279..479279e4497c 100644
--- a/dotnet/samples/Concepts/Planners/Handlebars.cs
+++ b/dotnet/samples/Concepts/Planners/HandlebarsPlanning.cs
@@ -11,7 +11,7 @@
namespace Examples;
// This example shows how to use the Handlebars sequential planner.
-public class Handlebars(ITestOutputHelper output) : BaseTest(output)
+public class HandlebarsPlanning(ITestOutputHelper output) : BaseTest(output)
{
private static int s_sampleIndex;
diff --git a/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
new file mode 100644
index 000000000000..7111e873cf4c
--- /dev/null
+++ b/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs
@@ -0,0 +1,75 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using System.ComponentModel;
+using Microsoft.SemanticKernel;
+
+namespace Plugins;
+
+public sealed class LegacyMenuPlugin
+{
+ public const string CorrelationIdArgument = "correlationId";
+
+ private readonly List _correlationIds = [];
+
+ public IReadOnlyList CorrelationIds => this._correlationIds;
+
+ ///
+ /// Returns a mock item menu.
+ ///
+ [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(KernelArguments? arguments)
+ {
+ CaptureCorrelationId(arguments, nameof(GetSpecials));
+
+ return
+ [
+ "Special Soup: Clam Chowder",
+ "Special Salad: Cobb Salad",
+ "Special Drink: Chai Tea",
+ ];
+ }
+
+ ///
+ /// Returns a mock item price.
+ ///
+ [KernelFunction, Description("Provides the price of the requested menu item.")]
+ public string GetItemPrice(
+ [Description("The name of the menu item.")]
+ string menuItem,
+ KernelArguments? arguments)
+ {
+ CaptureCorrelationId(arguments, nameof(GetItemPrice));
+
+ return "$9.99";
+ }
+
+ ///
+ /// An item is 86'd when the kitchen cannot serve due to running out of ingredients.
+ ///
+ [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,
+ [Description("The number of items requested.")]
+ int count,
+ KernelArguments? arguments)
+ {
+ CaptureCorrelationId(arguments, nameof(IsItem86d));
+
+ return count < 3;
+ }
+
+ private void CaptureCorrelationId(KernelArguments? arguments, string scope)
+ {
+ if (arguments?.TryGetValue(CorrelationIdArgument, out object? correlationId) ?? false)
+ {
+ string? correlationText = correlationId?.ToString();
+
+ if (!string.IsNullOrWhiteSpace(correlationText))
+ {
+ this._correlationIds.Add($"{scope}:{correlationText}");
+ }
+ }
+ }
+}
diff --git a/dotnet/samples/Concepts/Resources/Plugins/MenuPlugin.cs b/dotnet/samples/Concepts/Resources/Plugins/MenuPlugin.cs
index ba74f786d90f..be82177eda5d 100644
--- a/dotnet/samples/Concepts/Resources/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()
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/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/DataHelper.cs b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/DataHelper.cs
index 87546750ee9c..e7f708c19041 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/DataHelper.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/DataHelper.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Linq;
@@ -43,4 +43,4 @@ public static MemoryRecord[] CreateBatchRecords(int count) =>
private static DateTime GetDateTime() =>
new(TimeSpan.TicksPerMillisecond * (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond), DateTimeKind.Local);
-}
\ No newline at end of file
+}
diff --git a/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs b/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
index 2636feb44381..e2f7f006202c 100644
--- a/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Onnx/BertOnnxTextEmbeddingGenerationServiceTests.cs
@@ -1,18 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.
-using Microsoft.SemanticKernel.Embeddings;
-using Microsoft.SemanticKernel;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Threading.Tasks;
-using System;
-using Xunit;
-using System.Numerics.Tensors;
-using Microsoft.SemanticKernel.Connectors.Onnx;
-using System.Text;
using System.Net.Http;
+using System.Numerics.Tensors;
using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Connectors.Onnx;
+using Microsoft.SemanticKernel.Embeddings;
+using Xunit;
namespace SemanticKernel.IntegrationTests.Connectors.Onnx;
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
index b4ea1f98f173..b7a71d204011 100644
--- a/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
+++ b/dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs
@@ -3,7 +3,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
-using Xunit.Abstractions;
public abstract class BaseTest
{
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs
index 729d79cd7cd7..5c2aa4b5a13e 100644
--- a/dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs
+++ b/dotnet/src/InternalUtilities/samples/InternalUtilities/Env.cs
@@ -2,6 +2,8 @@
using Microsoft.Extensions.Configuration;
+#pragma warning disable CA1812 // Avoid uninstantiated internal classes
+
internal sealed class Env
{
///
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs
index cfb938a80fec..7f2ff7c3c8ad 100644
--- a/dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs
+++ b/dotnet/src/InternalUtilities/samples/InternalUtilities/TextOutputHelperExtensions.cs
@@ -1,7 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
-using Xunit.Abstractions;
-
public static class TextOutputHelperExtensions
{
public static void WriteLine(this ITestOutputHelper testOutputHelper, object target)
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs b/dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs
index 06169c6b6c31..ca2c22cd800a 100644
--- a/dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs
+++ b/dotnet/src/InternalUtilities/samples/InternalUtilities/XunitLogger.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Extensions.Logging;
-using Xunit.Abstractions;
///
/// A logger that writes to the Xunit test output
diff --git a/dotnet/src/InternalUtilities/samples/InternalUtilities/SamplesInternalUtilities.props b/dotnet/src/InternalUtilities/samples/SamplesInternalUtilities.props
similarity index 100%
rename from dotnet/src/InternalUtilities/samples/InternalUtilities/SamplesInternalUtilities.props
rename to dotnet/src/InternalUtilities/samples/SamplesInternalUtilities.props
From e1bb8becfceff6a959cac39c5a09b5cd12b9b003 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 14:47:54 +0100
Subject: [PATCH 14/24] UnitTests passing all
---
.../GettingStartedWithAgents/GettingStartedWithAgents.csproj | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
index 8208021e8be8..9115b3f79287 100644
--- a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
+++ b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
@@ -30,6 +30,7 @@
+
@@ -44,6 +45,7 @@
+
From 58cd931b0f2311c9594d3f2c84ac7d09aa8577a3 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 15:34:54 +0100
Subject: [PATCH 15/24] Fix warnings and build
---
dotnet/samples/GettingStarted/GettingStarted.csproj | 4 +---
.../GettingStartedWithAgents/GettingStartedWithAgents.csproj | 1 +
dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs | 1 -
dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs | 1 -
dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs | 1 -
dotnet/samples/LearnResources/LearnResources.csproj | 4 +---
6 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/GettingStarted.csproj
index 73e465f45ffd..496b1baf6e4b 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -1,7 +1,4 @@
-
- 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
GettingStarted
@@ -12,6 +9,7 @@
CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101
Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
diff --git a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
index 9115b3f79287..64c7a4e4653f 100644
--- a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
+++ b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
@@ -13,6 +13,7 @@
CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110
Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
diff --git a/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
index 4f26fcd3e6dd..def6bb2ea74d 100644
--- a/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
@@ -2,7 +2,6 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
index 5f591d8410af..a3c8551643bb 100644
--- a/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
@@ -4,7 +4,6 @@
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
index 0992a5bd97dd..d5c90736fc79 100644
--- a/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs
@@ -3,7 +3,6 @@
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
-using Xunit.Abstractions;
namespace GettingStarted;
diff --git a/dotnet/samples/LearnResources/LearnResources.csproj b/dotnet/samples/LearnResources/LearnResources.csproj
index 9646f13bba38..ed13bf32682e 100644
--- a/dotnet/samples/LearnResources/LearnResources.csproj
+++ b/dotnet/samples/LearnResources/LearnResources.csproj
@@ -1,7 +1,4 @@
-
- 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
-
LearnResources
@@ -12,6 +9,7 @@
CS8618,IDE0009,CA1051,CA1050,CA1707,CA2007,VSTHRD111,CS1591,RCS1110,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0101
Library
+ 5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
From 7bfa869a29586ac2644ad3d823fbdf4e8752fd86 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 15:55:44 +0100
Subject: [PATCH 16/24] Fix AssemblyVersionName error
---
dotnet/samples/Concepts/Concepts.csproj | 10 ++++------
.../GettingStartedWithAgents.csproj | 4 +---
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/dotnet/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index 43a1314a423f..40a0787a43ee 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -1,21 +1,19 @@
+ Concepts
+ 1.0.0.0
+ false
+
net8.0
enable
enable
-
false
true
-
- Concepts2
-
- net8.0
CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110
Library
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
- false
false
diff --git a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
index 64c7a4e4653f..0ac7baf6baf9 100644
--- a/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
+++ b/dotnet/samples/GettingStartedWithAgents/GettingStartedWithAgents.csproj
@@ -1,14 +1,12 @@
+ GettingStartedWithAgents
net8.0
enable
enable
-
false
true
-
- GettingStartedWithAgents
CS8618,IDE0009,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110
From 45247a3e9a87076f97ec42d9f77666bcaacdb9a3 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 26 Apr 2024 18:25:11 +0100
Subject: [PATCH 17/24] Adding Getting Started to VSCode launch options
---
.vscode/launch.json | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/.vscode/launch.json b/.vscode/launch.json
index d512a2e56d8c..21bde253e9c3 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,6 +1,7 @@
{
"version": "0.2.0",
"configurations": [
+
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
@@ -35,11 +36,18 @@
]
},
{
- "name": "C#: HuggingFaceImageTextExample",
+ "name": "C#: HuggingFaceImageToText",
"type": "dotnet",
"request": "launch",
- "projectPath": "${workspaceFolder}\\dotnet\\samples\\HuggingFaceImageTextExample\\HuggingFaceImageTextExample.csproj",
- "launchConfigurationId": "TargetFramework=;HuggingFaceImageTextExample"
+ "projectPath": "${workspaceFolder}\\dotnet\\samples\\Demos\\HuggingFaceImageToText.csproj",
+ "launchConfigurationId": "TargetFramework=;HuggingFaceImageToText"
+ },
+ {
+ "name": "C#: GettingStarted",
+ "type": "dotnet",
+ "request": "launch",
+ "projectPath": "${workspaceFolder}\\dotnet\\samples\\GettingStarted\\GettingStarted.csproj",
+ "launchConfigurationId": "TargetFramework=;GettingStarted"
}
]
}
\ No newline at end of file
From b777411ccdcb485da2bdcb340a094cd315e389a7 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Sat, 27 Apr 2024 07:59:23 +0100
Subject: [PATCH 18/24] Adding AssemblyInfo
---
dotnet/samples/Concepts/Concepts.csproj | 1 +
.../Concepts/Properties/AssemblyInfo.cs | 34 +++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 dotnet/samples/Concepts/Properties/AssemblyInfo.cs
diff --git a/dotnet/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index 40a0787a43ee..773a4473407e 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -3,6 +3,7 @@
Concepts
1.0.0.0
+ 1.0.0.0
false
net8.0
diff --git a/dotnet/samples/Concepts/Properties/AssemblyInfo.cs b/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000000..109d37464884
--- /dev/null
+++ b/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Properties")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Properties")]
+[assembly: AssemblyCopyright("Copyright © 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("7a06e178-6ef3-4d45-b427-3a5268d51913")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
From 122c80b771ce77ec1ad787db720540d8a8cf9685 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Sat, 27 Apr 2024 08:40:54 +0100
Subject: [PATCH 19/24] Fix Broken Links
---
.vscode/launch.json | 19 +++++-------
.vscode/tasks.json | 14 ++++-----
.../0021-json-serializable-custom-types.md | 2 +-
.../Concepts/Agents/Legacy_AgentAuthoring.cs | 4 +--
.../Kernel/CustomAIServiceSelector.cs | 2 +-
.../CreatePluginFromOpenAI_AzureKeyVault.cs | 2 +-
.../CreatePluginFromOpenApiSpec_Jira.cs | 2 +-
.../Concepts/Plugins/ImportPluginFromGrpc.cs | 2 +-
.../MultiplePromptTemplates.cs | 2 +-
.../Concepts/Properties/AssemblyInfo.cs | 30 +++++--------------
dotnet/samples/Concepts/README.md | 2 +-
.../HuggingFace_TextGeneration.cs | 6 +---
dotnet/samples/GettingStarted/README.md | 2 +-
.../GettingStartedWithAgents/Step1_Agent.cs | 2 +-
.../GettingStartedWithAgents/Step2_Plugins.cs | 2 +-
dotnet/samples/README.md | 14 ++++-----
.../Connectors.Memory.Chroma/README.md | 2 +-
.../Connectors.Memory.Kusto/README.md | 2 +-
.../Connectors.Memory.Milvus/README.md | 2 +-
.../Connectors.Memory.MongoDB/README.md | 2 +-
.../Connectors.Memory.Postgres/README.md | 2 +-
.../Connectors.Memory.Redis/README.md | 2 +-
.../Events/CancelKernelEventArgs.cs | 2 +-
.../Events/FunctionInvokedEventArgs.cs | 2 +-
.../Events/FunctionInvokingEventArgs.cs | 2 +-
.../Events/KernelEventArgs.cs | 2 +-
.../Events/PromptRenderedEventArgs.cs | 2 +-
.../Events/PromptRenderingEventArgs.cs | 2 +-
.../src/SemanticKernel.Abstractions/Kernel.cs | 16 +++++-----
29 files changed, 63 insertions(+), 84 deletions(-)
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 21bde253e9c3..3e38b1ff0525 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,21 +1,20 @@
{
"version": "0.2.0",
"configurations": [
-
{
// 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
@@ -31,23 +30,21 @@
"type": "python",
"request": "launch",
"module": "pytest",
- "args": [
- "${file}"
- ]
+ "args": ["${file}"]
},
{
- "name": "C#: HuggingFaceImageToText",
+ "name": "C#: HuggingFaceImageToText Demo",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}\\dotnet\\samples\\Demos\\HuggingFaceImageToText.csproj",
"launchConfigurationId": "TargetFramework=;HuggingFaceImageToText"
},
{
- "name": "C#: GettingStarted",
+ "name": "C#: GettingStarted Samples",
"type": "dotnet",
"request": "launch",
"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/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs b/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
index 1e4aef5d341a..785fbb247148 100644
--- a/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
+++ b/dotnet/samples/Concepts/Agents/Legacy_AgentAuthoring.cs
@@ -21,7 +21,7 @@ public class Legacy_AgentAuthoring(ITestOutputHelper output) : BaseTest(output)
[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
@@ -43,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/Concepts/Kernel/CustomAIServiceSelector.cs b/dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
index 1016f30d2fa2..bbba5274ccdd 100644
--- a/dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
+++ b/dotnet/samples/Concepts/Kernel/CustomAIServiceSelector.cs
@@ -16,7 +16,7 @@ public class CustomAIServiceSelector(ITestOutputHelper output) : BaseTest(output
[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/Plugins/CreatePluginFromOpenAI_AzureKeyVault.cs b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenAI_AzureKeyVault.cs
index 37711fca767e..61d5a4bd394d 100644
--- a/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenAI_AzureKeyVault.cs
+++ b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenAI_AzureKeyVault.cs
@@ -33,7 +33,7 @@ public class CreatePluginFromOpenAI_AzureKeyVault(ITestOutputHelper output) : Ba
/// dotnet user-secrets set "KeyVault:ClientId" "your_client_id"
/// dotnet user-secrets set "KeyVault:ClientSecret" "your_secret"
///
- /// 5. Replace your tenant ID with the "TENANT_ID" placeholder in dotnet/samples/KernelSyntaxExamples/Resources/22-ai-plugin.json
+ /// 5. Replace your tenant ID with the "TENANT_ID" placeholder in dotnet/samples/Concepts/Resources/22-ai-plugin.json
///
[Fact(Skip = "Setup credentials")]
public async Task RunAsync()
diff --git a/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
index 2817dda10f92..cd632e4db33d 100644
--- a/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
+++ b/dotnet/samples/Concepts/Plugins/CreatePluginFromOpenApiSpec_Jira.cs
@@ -31,7 +31,7 @@ public class CreatePluginFromOpenApiSpec_Jira(ITestOutputHelper output) : BaseTe
/// 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()
diff --git a/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs b/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
index 91d5b6a3cb04..a924bf042386 100644
--- a/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
+++ b/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs
@@ -6,7 +6,7 @@
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/Concepts/PromptTemplates/MultiplePromptTemplates.cs b/dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
index d19a74ea37c1..716a7777ef97 100644
--- a/dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
+++ b/dotnet/samples/Concepts/PromptTemplates/MultiplePromptTemplates.cs
@@ -17,7 +17,7 @@ public class MultiplePromptTemplates(ITestOutputHelper output) : BaseTest(output
[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/Concepts/Properties/AssemblyInfo.cs b/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
index 109d37464884..f17c9f3e91ee 100644
--- a/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
+++ b/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
@@ -6,29 +6,15 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("Properties")]
-[assembly: AssemblyDescription("")]
+[assembly: System.CLSCompliantAttribute(false)]
+[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("5ee045b0-aea3-4f08-8d31-32d1a6f8fed0")]
+[assembly: AssemblyTitle("Concepts")]
+[assembly: AssemblyDescription("Semantic Kernel Concepts Samples Project")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Properties")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Concepts")]
[assembly: AssemblyCopyright("Copyright © 2024")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("7a06e178-6ef3-4d45-b427-3a5268d51913")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+
+[assembly: ComVisible(false)]
diff --git a/dotnet/samples/Concepts/README.md b/dotnet/samples/Concepts/README.md
index feabf5dff1c5..63f4878727ea 100644
--- a/dotnet/samples/Concepts/README.md
+++ b/dotnet/samples/Concepts/README.md
@@ -22,4 +22,4 @@ This section contains code snippets that demonstrate the usage of Semantic Kerne
| 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) |
| LocalModels | Using services against `LocalModels` to run models locally |
-| Agents | Different ways of using [`Agents`](./AgentSyntax/README.md) |
+| Agents | Different ways of using [`Agents`](./Agents/README.md) |
diff --git a/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
index cef321943993..bfb7538db2c6 100644
--- a/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
+++ b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
@@ -10,7 +10,7 @@
namespace Examples;
// The following example shows how to use Semantic Kernel with HuggingFace API.
-public class Example20_HuggingFace : BaseTest
+public class HuggingFace_TextGeneration(ITestOutputHelper helper) : BaseTest(helper)
{
///
/// This example uses HuggingFace Inference API to access hosted models.
@@ -95,8 +95,4 @@ public async Task RunLlamaExampleAsync()
WriteLine(result.GetValue());
}
-
- public Example20_HuggingFace(ITestOutputHelper output) : base(output)
- {
- }
}
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/GettingStartedWithAgents/Step1_Agent.cs b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
index def6bb2ea74d..475999d2f86a 100644
--- a/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs
@@ -26,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/GettingStartedWithAgents/Step2_Plugins.cs b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
index a3c8551643bb..0661155ae7d2 100644
--- a/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
+++ b/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs
@@ -33,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.
diff --git a/dotnet/samples/README.md b/dotnet/samples/README.md
index 4b1b9d4c65c5..01e3f99e8667 100644
--- a/dotnet/samples/README.md
+++ b/dotnet/samples/README.md
@@ -1,9 +1,9 @@
## Kernel Samples
-| Type | Description |
-| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
-| [`Getting Started`](./GettingStarted/README.md) | Take this step by step tutorial to get started with the Semantic Kernel and get introduced to the key concepts. |
-| [`Concepts`](./Concepts/README.md) | This section contains focussed samples which illustrate all of the concepts included in the Semantic Kernel. |
-| [`Demos`](./Demos/README.md) | Look here to find a sample which demonstrate how to use many of Semantic Kernel features. |
-| [`LearnResources`](./LearnResources/README.md) | Code snippets that are related to online documentation sources like Microsoft Learn, DevBlogs and others |
-| [`KernelSyntaxExamples`](./KernelSyntaxExamples/README.md) | ⚠️ Work in progress: Moving into `Concepts`. |
+| Type | Description |
+| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
+| [`Getting Started`](./GettingStarted/README.md) | Take this step by step tutorial to get started with the Semantic Kernel and get introduced to the key concepts. |
+| [`Concepts`](./Concepts/README.md) | This section contains focussed samples which illustrate all of the concepts included in the Semantic Kernel. |
+| [`Demos`](./Demos/README.md) | Look here to find a sample which demonstrate how to use many of Semantic Kernel features. |
+| [`LearnResources`](./LearnResources/README.md) | Code snippets that are related to online documentation sources like Microsoft Learn, DevBlogs and others |
+| `KernelSyntaxExamples` | ⚠️ Work in progress: Moving into `Concepts`. |
diff --git a/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md b/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
index 2d6e09fbca90..958adfc5aa2c 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
@@ -21,7 +21,7 @@ docker-compose up -d --build
3. Use Semantic Kernel with Chroma, using server local endpoint `http://localhost:8000`:
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
const string endpoint = "http://localhost:8000";
diff --git a/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md b/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
index e7685b1b0adb..17c4fdcadf8e 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
@@ -7,7 +7,7 @@ This connector uses [Azure Data Explorer (Kusto)](https://learn.microsoft.com/en
1. Create a cluster and database in Azure Data Explorer (Kusto) - see https://learn.microsoft.com/en-us/azure/data-explorer/create-cluster-and-database?tabs=free
2. To use Kusto as a semantic memory store, use the following code:
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
using Kusto.Data;
diff --git a/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md b/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
index 8619aa4dc5ea..cf66a6801202 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
@@ -19,7 +19,7 @@ docker-compose up -d
```
3. Use Semantic Kernel with Milvus, connecting to `localhost` with the default (gRPC) port of 1536:
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
using MilvusMemoryStore memoryStore = new("localhost");
diff --git a/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md b/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
index 74b3dc8c35c5..214c1e27fa35 100644
--- a/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
@@ -25,7 +25,7 @@ This connector uses [MongoDB Atlas Vector Search](https://www.mongodb.com/produc
```
4. Create the MongoDB memory store
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
var connectionString = "MONGODB ATLAS CONNECTION STRING"
diff --git a/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md b/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
index 4941821a3fe1..6218b1d0c06a 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
@@ -34,7 +34,7 @@ sk_demo=# CREATE EXTENSION vector;
> Note, "Azure Cosmos DB for PostgreSQL" uses `SELECT CREATE_EXTENSION('vector');` to enable the extension.
3. To use Postgres as a semantic memory store:
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
NpgsqlDataSourceBuilder dataSourceBuilder = new NpgsqlDataSourceBuilder("Host=localhost;Port=5432;Database=sk_demo;User Id=postgres;Password=mysecretpassword");
diff --git a/dotnet/src/Connectors/Connectors.Memory.Redis/README.md b/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
index 62e7fb3ec031..2cd8adcc2733 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
@@ -23,7 +23,7 @@ docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:la
```
2. To use Redis as a semantic memory store:
- > See [Example 14](../../../samples/KernelSyntaxExamples/Example14_SemanticMemory.cs) and [Example 15](../../../samples/KernelSyntaxExamples/Example15_TextMemoryPlugin.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
// ConnectionMultiplexer should be a singleton instance in your application, please consider to dispose of it when your application shuts down.
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/CancelKernelEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/CancelKernelEventArgs.cs
index ed07decf7f27..5d268974e828 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/CancelKernelEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/CancelKernelEventArgs.cs
@@ -9,7 +9,7 @@ namespace Microsoft.SemanticKernel;
/// Provides an for cancelable operations related
/// to -based operations.
///
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public abstract class CancelKernelEventArgs : KernelEventArgs
{
///
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokedEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokedEventArgs.cs
index 0317cb5cf860..de32ad666716 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokedEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokedEventArgs.cs
@@ -7,7 +7,7 @@ namespace Microsoft.SemanticKernel;
///
/// Provides a used in events just after a function is invoked.
///
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public sealed class FunctionInvokedEventArgs : CancelKernelEventArgs
{
///
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokingEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokingEventArgs.cs
index 99396a137bfe..803c9acc72fd 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokingEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/FunctionInvokingEventArgs.cs
@@ -7,7 +7,7 @@ namespace Microsoft.SemanticKernel;
///
/// Provides a used in events just before a function is invoked.
///
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public sealed class FunctionInvokingEventArgs : CancelKernelEventArgs
{
///
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/KernelEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/KernelEventArgs.cs
index 6c659dc53f33..d7bb3701232e 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/KernelEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/KernelEventArgs.cs
@@ -6,7 +6,7 @@
namespace Microsoft.SemanticKernel;
/// Provides an for operations related to -based operations.
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public abstract class KernelEventArgs : EventArgs
{
///
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderedEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderedEventArgs.cs
index 83f14a76aafd..373c8c1e0a01 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderedEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderedEventArgs.cs
@@ -8,7 +8,7 @@ namespace Microsoft.SemanticKernel;
///
/// Provides a used in events raised just after a prompt has been rendered.
///
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public sealed class PromptRenderedEventArgs : CancelKernelEventArgs
{
private string _renderedPrompt;
diff --git a/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderingEventArgs.cs b/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderingEventArgs.cs
index b808a6e8c293..2d86f989da98 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderingEventArgs.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Events/PromptRenderingEventArgs.cs
@@ -7,7 +7,7 @@ namespace Microsoft.SemanticKernel;
///
/// Provides a used in events raised just before a prompt is rendered.
///
-[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+[Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public sealed class PromptRenderingEventArgs : KernelEventArgs
{
///
diff --git a/dotnet/src/SemanticKernel.Abstractions/Kernel.cs b/dotnet/src/SemanticKernel.Abstractions/Kernel.cs
index db70310000d5..abe569008c46 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Kernel.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Kernel.cs
@@ -602,31 +602,31 @@ private static bool IsNotEmpty(IEnumerable enumerable) =>
/// Provides an event that's raised prior to a function's invocation.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public event EventHandler? FunctionInvoking;
///
/// Provides an event that's raised after a function's invocation.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public event EventHandler? FunctionInvoked;
///
/// Provides an event that's raised prior to a prompt being rendered.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public event EventHandler? PromptRendering;
///
/// Provides an event that's raised after a prompt is rendered.
///
[EditorBrowsable(EditorBrowsableState.Never)]
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
public event EventHandler? PromptRendered;
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
internal FunctionInvokingEventArgs? OnFunctionInvoking(KernelFunction function, KernelArguments arguments)
{
FunctionInvokingEventArgs? eventArgs = null;
@@ -639,7 +639,7 @@ private static bool IsNotEmpty(IEnumerable enumerable) =>
return eventArgs;
}
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
internal FunctionInvokedEventArgs? OnFunctionInvoked(KernelFunction function, KernelArguments arguments, FunctionResult result)
{
FunctionInvokedEventArgs? eventArgs = null;
@@ -652,7 +652,7 @@ private static bool IsNotEmpty(IEnumerable enumerable) =>
return eventArgs;
}
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
internal PromptRenderingEventArgs? OnPromptRendering(KernelFunction function, KernelArguments arguments)
{
PromptRenderingEventArgs? eventArgs = null;
@@ -665,7 +665,7 @@ private static bool IsNotEmpty(IEnumerable enumerable) =>
return eventArgs;
}
- [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/KernelSyntaxExamples/Getting_Started/Step7_Observability.cs of Semantic Kernel repository.")]
+ [Obsolete("Events are deprecated in favor of filters. Example in dotnet/samples/GettingStarted/Step7_Observability.cs of Semantic Kernel repository.")]
internal PromptRenderedEventArgs? OnPromptRendered(KernelFunction function, KernelArguments arguments, string renderedPrompt)
{
PromptRenderedEventArgs? eventArgs = null;
From cef1abc55ecc70f5fa9a1860ca21d8881c105dd1 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Sat, 27 Apr 2024 08:44:53 +0100
Subject: [PATCH 20/24] Memory Path Correction
---
dotnet/src/Connectors/Connectors.Memory.Chroma/README.md | 2 +-
dotnet/src/Connectors/Connectors.Memory.Kusto/README.md | 2 +-
dotnet/src/Connectors/Connectors.Memory.Milvus/README.md | 2 +-
dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md | 2 +-
dotnet/src/Connectors/Connectors.Memory.Postgres/README.md | 2 +-
dotnet/src/Connectors/Connectors.Memory.Redis/README.md | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md b/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
index 958adfc5aa2c..04d5e5526f10 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Chroma/README.md
@@ -21,7 +21,7 @@ docker-compose up -d --build
3. Use Semantic Kernel with Chroma, using server local endpoint `http://localhost:8000`:
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
const string endpoint = "http://localhost:8000";
diff --git a/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md b/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
index 17c4fdcadf8e..f7c276c7e9c3 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Kusto/README.md
@@ -7,7 +7,7 @@ This connector uses [Azure Data Explorer (Kusto)](https://learn.microsoft.com/en
1. Create a cluster and database in Azure Data Explorer (Kusto) - see https://learn.microsoft.com/en-us/azure/data-explorer/create-cluster-and-database?tabs=free
2. To use Kusto as a semantic memory store, use the following code:
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
using Kusto.Data;
diff --git a/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md b/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
index cf66a6801202..b4d8e71d5a2c 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Milvus/README.md
@@ -19,7 +19,7 @@ docker-compose up -d
```
3. Use Semantic Kernel with Milvus, connecting to `localhost` with the default (gRPC) port of 1536:
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
using MilvusMemoryStore memoryStore = new("localhost");
diff --git a/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md b/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
index 214c1e27fa35..4a6ddcda3483 100644
--- a/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.MongoDB/README.md
@@ -25,7 +25,7 @@ This connector uses [MongoDB Atlas Vector Search](https://www.mongodb.com/produc
```
4. Create the MongoDB memory store
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
var connectionString = "MONGODB ATLAS CONNECTION STRING"
diff --git a/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md b/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
index 6218b1d0c06a..35c80a45087a 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Postgres/README.md
@@ -34,7 +34,7 @@ sk_demo=# CREATE EXTENSION vector;
> Note, "Azure Cosmos DB for PostgreSQL" uses `SELECT CREATE_EXTENSION('vector');` to enable the extension.
3. To use Postgres as a semantic memory store:
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
NpgsqlDataSourceBuilder dataSourceBuilder = new NpgsqlDataSourceBuilder("Host=localhost;Port=5432;Database=sk_demo;User Id=postgres;Password=mysecretpassword");
diff --git a/dotnet/src/Connectors/Connectors.Memory.Redis/README.md b/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
index 2cd8adcc2733..3827e46918a4 100644
--- a/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
+++ b/dotnet/src/Connectors/Connectors.Memory.Redis/README.md
@@ -23,7 +23,7 @@ docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:la
```
2. To use Redis as a semantic memory store:
- > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
+ > See [Example 14](../../../samples/Concepts/Memory/SemanticTextMemory_Building.cs) and [Example 15](../../../samples/Concepts/Memory/TextMemoryPlugin_MultipleMemoryStore.cs) for more memory usage examples with the kernel.
```csharp
// ConnectionMultiplexer should be a singleton instance in your application, please consider to dispose of it when your application shuts down.
From a55a0a892cc3f60b0c8777a6f41626c4f3cfae9e Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Mon, 29 Apr 2024 08:22:51 +0100
Subject: [PATCH 21/24] Removing AssemblyBuild error
---
docs/decisions/0042-samples-restructure.md | 2 +-
dotnet/samples/Concepts/Concepts.csproj | 2 +-
.../Concepts/Properties/AssemblyInfo.cs | 20 -------------------
3 files changed, 2 insertions(+), 22 deletions(-)
delete mode 100644 dotnet/samples/Concepts/Properties/AssemblyInfo.cs
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/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index 773a4473407e..19f220b60c97 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -4,7 +4,6 @@
Concepts
1.0.0.0
1.0.0.0
- false
net8.0
enable
@@ -16,6 +15,7 @@
Library
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
false
+ false
diff --git a/dotnet/samples/Concepts/Properties/AssemblyInfo.cs b/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
deleted file mode 100644
index f17c9f3e91ee..000000000000
--- a/dotnet/samples/Concepts/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: System.CLSCompliantAttribute(false)]
-[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("5ee045b0-aea3-4f08-8d31-32d1a6f8fed0")]
-[assembly: AssemblyTitle("Concepts")]
-[assembly: AssemblyDescription("Semantic Kernel Concepts Samples Project")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("Concepts")]
-[assembly: AssemblyCopyright("Copyright © 2024")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-
-[assembly: ComVisible(false)]
From 1bc4d6dfdda4080619a6e0846b3d6dc9f7283f7e Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Mon, 29 Apr 2024 11:54:05 +0100
Subject: [PATCH 22/24] Fix usings, removing versioning
---
dotnet/samples/Concepts/Concepts.csproj | 18 ++++++++++++++----
.../HuggingFace_ChatCompletionWithTGI.cs | 6 +-----
.../MultipleProviders_ChatCompletion.cs | 6 +-----
.../Memory/HuggingFace_EmbeddingGeneration.cs | 6 +-----
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dotnet/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index 19f220b60c97..5b037561d1c1 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -2,11 +2,8 @@
Concepts
- 1.0.0.0
- 1.0.0.0
net8.0
- enable
enable
false
true
@@ -15,7 +12,6 @@
Library
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
false
- false
@@ -83,6 +79,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs b/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs
index c404f4d52295..97bcfb1c07e2 100644
--- a/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs
+++ b/dotnet/samples/Concepts/LocalModels/HuggingFace_ChatCompletionWithTGI.cs
@@ -9,7 +9,7 @@
namespace Examples;
// The following example shows how to use Semantic Kernel with HuggingFace API.
-public class HuggingFace_ChatCompletionWithTGI : BaseTest
+public class HuggingFace_ChatCompletionWithTGI(ITestOutputHelper output) : BaseTest(output)
{
///
/// Follow steps in to setup HuggingFace local Text Generation Inference HTTP server.
@@ -86,8 +86,4 @@ public async Task RunTGI_StreamingChatCompletionAsync()
Write(chatMessageChunk.Content);
}
}
-
- public HuggingFace_ChatCompletionWithTGI(ITestOutputHelper output) : base(output)
- {
- }
}
diff --git a/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs b/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
index b294f6003b5f..73dcecdb068c 100644
--- a/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
+++ b/dotnet/samples/Concepts/LocalModels/MultipleProviders_ChatCompletion.cs
@@ -28,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 MultipleProviders_ChatCompletion : 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
@@ -92,8 +92,4 @@ Sign the mail as AI Assistant.
this.WriteLine(word);
};
}
-
- public MultipleProviders_ChatCompletion(ITestOutputHelper output) : base(output)
- {
- }
}
diff --git a/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs b/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs
index 57ffeda8ce1e..d960d707cf46 100644
--- a/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs
+++ b/dotnet/samples/Concepts/Memory/HuggingFace_EmbeddingGeneration.cs
@@ -10,7 +10,7 @@
namespace Examples;
// The following example shows how to use Semantic Kernel with HuggingFace API.
-public class HuggingFace_EmbeddingGeneration : BaseTest
+public class HuggingFace_EmbeddingGeneration(ITestOutputHelper output) : BaseTest(output)
{
[RetryFact(typeof(HttpOperationException))]
public async Task RunInferenceApiEmbeddingAsync()
@@ -30,8 +30,4 @@ public async Task RunInferenceApiEmbeddingAsync()
this.WriteLine($"Generated {embeddings.Count} embeddings for the provided text");
}
-
- public HuggingFace_EmbeddingGeneration(ITestOutputHelper output) : base(output)
- {
- }
}
From 2bee5a9ba7e57d1e09d5874d12cb73ed200bf6f2 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Mon, 29 Apr 2024 12:09:31 +0100
Subject: [PATCH 23/24] Fix warnings
---
dotnet/samples/Concepts/Concepts.csproj | 7 -------
1 file changed, 7 deletions(-)
diff --git a/dotnet/samples/Concepts/Concepts.csproj b/dotnet/samples/Concepts/Concepts.csproj
index 5b037561d1c1..31be3a10499e 100644
--- a/dotnet/samples/Concepts/Concepts.csproj
+++ b/dotnet/samples/Concepts/Concepts.csproj
@@ -79,18 +79,11 @@
-
-
-
-
-
-
-
From 5a6dbf4e1216aa7668500d86f5195e0ff53f0322 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Mon, 29 Apr 2024 12:33:08 +0100
Subject: [PATCH 24/24] Hugging Face Test update
---
.../TextGeneration/HuggingFace_TextGeneration.cs | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
index bfb7538db2c6..49faef919bae 100644
--- a/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
+++ b/dotnet/samples/Concepts/TextGeneration/HuggingFace_TextGeneration.cs
@@ -12,6 +12,7 @@ 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:
@@ -23,7 +24,7 @@ public async Task RunInferenceApiExampleAsync()
Kernel kernel = Kernel.CreateBuilder()
.AddHuggingFaceTextGeneration(
- model: TestConfiguration.HuggingFace.ModelId,
+ model: TestConfiguration.HuggingFace.ModelId ?? DefaultModel,
apiKey: TestConfiguration.HuggingFace.ApiKey)
.Build();
@@ -34,16 +35,22 @@ public async Task RunInferenceApiExampleAsync()
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()
{
- WriteLine("\n======== HuggingFace zephyr-7b-beta streaming example ========\n");
+ string model = TestConfiguration.HuggingFace.ModelId ?? DefaultModel;
- const string Model = "HuggingFaceH4/zephyr-7b-beta";
+ WriteLine($"\n======== HuggingFace {model} streaming example ========\n");
Kernel kernel = Kernel.CreateBuilder()
.AddHuggingFaceTextGeneration(
- model: Model,
+ model: model,
apiKey: TestConfiguration.HuggingFace.ApiKey)
.Build();