Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Upgrade .Net notebooks to Microsoft.SemanticKernel, 1.0.0-beta6 #3478

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotnet/notebooks/00-getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"outputs": [],
"source": [
"// Import Semantic Kernel\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\""
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\""
]
},
{
Expand Down Expand Up @@ -108,7 +108,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions dotnet/notebooks/01-basic-loading-the-kernel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\""
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\""
]
},
{
Expand Down Expand Up @@ -121,7 +121,7 @@
"outputs": [],
"source": [
"Kernel.Builder\n",
".WithAzureChatCompletionService(\n",
".WithAzureOpenAIChatCompletionService(\n",
" \"my-finetuned-model\", // Azure OpenAI *Deployment Name*\n",
" \"https://contoso.openai.azure.com/\", // Azure OpenAI *Endpoint*\n",
" \"...your Azure OpenAI Key...\", // Azure OpenAI *Key*\n",
Expand Down
4 changes: 2 additions & 2 deletions dotnet/notebooks/02-running-prompts-from-file.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"\n",
"#!import config/Settings.cs\n",
"\n",
Expand All @@ -102,7 +102,7 @@
"// Configure AI backend used by the kernel\n",
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down
23 changes: 11 additions & 12 deletions dotnet/notebooks/03-semantic-function-inline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"\n",
"#!import config/Settings.cs\n",
"\n",
"using Microsoft.SemanticKernel;\n",
"using Microsoft.SemanticKernel.SemanticFunctions;\n",
"using Microsoft.SemanticKernel.Connectors.AI.OpenAI;\n",
"using Microsoft.SemanticKernel.TemplateEngine;\n",
"using Microsoft.SemanticKernel.TemplateEngine.Basic;\n",
"\n",
"var builder = new KernelBuilder();\n",
"\n",
"// Configure AI backend used by the kernel\n",
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down Expand Up @@ -127,8 +128,8 @@
" TopP = 0.5\n",
"};\n",
"\n",
"var promptConfig = new PromptTemplateConfig();\n",
"promptConfig.ModelSettings.Add(aiRequestSettings);"
"var promptTemplateConfig = new PromptTemplateConfig();\n",
"promptTemplateConfig.ModelSettings.Add(aiRequestSettings);"
]
},
{
Expand All @@ -153,10 +154,10 @@
},
"outputs": [],
"source": [
"var promptTemplate = new PromptTemplate(\n",
"var promptTemplateFactory = new BasicPromptTemplateFactory();\n",
"var promptTemplate = promptTemplateFactory.Create(\n",
" skPrompt, // Prompt template defined in natural language\n",
" promptConfig, // Prompt configuration\n",
" kernel // SK instance\n",
" promptTemplateConfig // Prompt configuration\n",
");"
]
},
Expand All @@ -181,9 +182,7 @@
},
"outputs": [],
"source": [
"var functionConfig = new SemanticFunctionConfig(promptConfig, promptTemplate);\n",
"\n",
"var summaryFunction = kernel.RegisterSemanticFunction(\"MyPlugin\", \"Summary\", functionConfig);"
"var summaryFunction = kernel.RegisterSemanticFunction(\"MyPlugin\", \"Summary\", promptTemplateConfig, promptTemplate);"
]
},
{
Expand Down Expand Up @@ -314,7 +313,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down
16 changes: 6 additions & 10 deletions dotnet/notebooks/04-context-variables-chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#!import config/Settings.cs\n",
"\n",
"using Microsoft.SemanticKernel;\n",
"using Microsoft.SemanticKernel.SemanticFunctions;\n",
"using Microsoft.SemanticKernel.TemplateEngine;\n",
"using Microsoft.SemanticKernel.TemplateEngine.Basic;\n",
"using Microsoft.SemanticKernel.Orchestration;\n",
"using Microsoft.SemanticKernel.Connectors.AI.OpenAI;\n",
"\n",
Expand All @@ -47,7 +48,7 @@
"// Configure AI backend used by the kernel\n",
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down Expand Up @@ -91,10 +92,7 @@
" MaxTokens = 2000,\n",
" Temperature = 0.7,\n",
" TopP = 0.5\n",
"};\n",
"\n",
"var promptConfig = new PromptTemplateConfig();\n",
"promptConfig.ModelSettings.Add(aiRequestSettings);"
"};"
]
},
{
Expand All @@ -121,9 +119,7 @@
},
"outputs": [],
"source": [
"var promptTemplate = new PromptTemplate(skPrompt, promptConfig, kernel);\n",
"var functionConfig = new SemanticFunctionConfig(promptConfig, promptTemplate);\n",
"var chatFunction = kernel.RegisterSemanticFunction(\"ChatBot\", \"Chat\", functionConfig);"
"var chatFunction = kernel.CreateSemanticFunction(skPrompt, requestSettings: aiRequestSettings);"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions dotnet/notebooks/05-using-the-planner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"\n",
"#!import config/Settings.cs\n",
"#!import config/Utils.cs\n",
Expand All @@ -43,7 +43,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down
7 changes: 3 additions & 4 deletions dotnet/notebooks/06-memory-and-embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#r \"nuget: System.Linq.Async, 6.0.1\"\n",
"\n",
"#!import config/Settings.cs\n",
"\n",
"using Microsoft.SemanticKernel;\n",
"using Microsoft.SemanticKernel.SemanticFunctions;\n",
"using Microsoft.SemanticKernel.Orchestration;\n",
"\n",
"var kernelBuilder = new KernelBuilder();\n",
Expand All @@ -48,7 +47,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" kernelBuilder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" kernelBuilder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" kernelBuilder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down Expand Up @@ -93,7 +92,7 @@
"\n",
"if (useAzureOpenAI)\n",
"{\n",
" memoryBuilder.WithAzureTextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
" memoryBuilder.WithAzureOpenAITextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
"}\n",
"else\n",
"{\n",
Expand Down
8 changes: 4 additions & 4 deletions dotnet/notebooks/07-DALL-E-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"source": [
"// Usual setup: importing Semantic Kernel SDK and SkiaSharp, used to display images inline.\n",
"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#r \"nuget: SkiaSharp, 2.88.3\"\n",
"\n",
"#!import config/Settings.cs\n",
Expand Down Expand Up @@ -86,8 +86,8 @@
"\n",
"if(useAzureOpenAI)\n",
"{\n",
" builder.WithAzureTextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAITextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIImageGenerationService(azureEndpoint, apiKey);\n",
"}\n",
"else\n",
Expand Down Expand Up @@ -225,4 +225,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
6 changes: 3 additions & 3 deletions dotnet/notebooks/08-chatGPT-with-DALL-E-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"source": [
"// Usual setup: importing Semantic Kernel SDK and SkiaSharp, used to display images inline.\n",
"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#r \"nuget: SkiaSharp, 2.88.3\"\n",
"\n",
"#!import config/Settings.cs\n",
Expand Down Expand Up @@ -104,7 +104,7 @@
"\n",
"if(useAzureOpenAI)\n",
"{\n",
" builder.WithAzureChatCompletionService(\"gpt-35-turbo\", azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(\"gpt-35-turbo\", azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIImageGenerationService(azureEndpoint, apiKey);\n",
"}\n",
"else\n",
Expand Down Expand Up @@ -240,4 +240,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
10 changes: 5 additions & 5 deletions dotnet/notebooks/09-memory-with-chroma.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel.Connectors.Memory.Chroma, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#r \"nuget: Microsoft.SemanticKernel.Connectors.Memory.Chroma, 1.0.0-beta6\"\n",
"#r \"nuget: System.Linq.Async, 6.0.1\"\n",
"\n",
"#!import config/Settings.cs\n",
Expand All @@ -59,7 +59,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" kernelBuilder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" kernelBuilder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" kernelBuilder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down Expand Up @@ -106,7 +106,7 @@
"\n",
"if (useAzureOpenAI)\n",
"{\n",
" memoryBuilder.WithAzureTextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
" memoryBuilder.WithAzureOpenAITextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
"}\n",
"else\n",
"{\n",
Expand Down Expand Up @@ -465,7 +465,7 @@
"\n",
"if (useAzureOpenAI)\n",
"{\n",
" memoryBuilder.WithAzureTextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
" memoryBuilder.WithAzureOpenAITextEmbeddingGenerationService(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
"}\n",
"else\n",
"{\n",
Expand Down
6 changes: 3 additions & 3 deletions dotnet/notebooks/10-BingSearch-using-kernel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
},
"outputs": [],
"source": [
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Web, 1.0.0-beta1\"\n",
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-beta6\"\n",
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Web, 1.0.0-beta6\"\n",
"\n",
"#!import config/Settings.cs\n",
"#!import config/Utils.cs\n",
Expand All @@ -55,7 +55,7 @@
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
"\n",
"if (useAzureOpenAI)\n",
" builder.WithAzureChatCompletionService(model, azureEndpoint, apiKey);\n",
" builder.WithAzureOpenAIChatCompletionService(model, azureEndpoint, apiKey);\n",
"else\n",
" builder.WithOpenAIChatCompletionService(model, apiKey, orgId);\n",
"\n",
Expand Down
Loading