Skip to content

Commit 21038a2

Browse files
authored
.Net: Updated dotnet notebooks to use SK v1.0.1 (microsoft#4373)
### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent d6a88a6 commit 21038a2

13 files changed

+44
-48
lines changed

dotnet/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ requirements and setup instructions.
7878
5. [Using Kernel Arguments to Build a Chat Experience](./notebooks/04-kernel-arguments-chat.ipynb)
7979
6. [Creating and Executing Plans](./notebooks/05-using-the-planner.ipynb)
8080
7. [Building Memory with Embeddings](./notebooks/06-memory-and-embeddings.ipynb)
81-
8. [Creating images with DALL-E 2](./notebooks/07-DALL-E-2.ipynb)
82-
9. [Chatting with ChatGPT and Images](./notebooks/08-chatGPT-with-DALL-E-2.ipynb)
81+
8. [Creating images with DALL-E 3](./notebooks/07-DALL-E-3.ipynb)
82+
9. [Chatting with ChatGPT and Images](./notebooks/08-chatGPT-with-DALL-E-3.ipynb)
8383
10. [BingSearch using Kernel](./notebooks/10-BingSearch-using-kernel.ipynb)
8484

8585
# Nuget packages

dotnet/notebooks/00-getting-started.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"outputs": [],
6262
"source": [
6363
"// Import Semantic Kernel\n",
64-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\""
64+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\""
6565
]
6666
},
6767
{

dotnet/notebooks/01-basic-loading-the-kernel.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"outputs": [],
3434
"source": [
35-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\""
35+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\""
3636
]
3737
},
3838
{

dotnet/notebooks/02-running-prompts-from-file.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
},
9494
"outputs": [],
9595
"source": [
96-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
96+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
9797
"\n",
9898
"#!import config/Settings.cs\n",
9999
"\n",

dotnet/notebooks/03-semantic-function-inline.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
54+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
5555
"\n",
5656
"#!import config/Settings.cs\n",
5757
"\n",

dotnet/notebooks/04-kernel-arguments-chat.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"outputs": [],
3232
"source": [
33-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
33+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
3434
"#!import config/Settings.cs\n",
3535
"\n",
3636
"using Microsoft.SemanticKernel;\n",

dotnet/notebooks/05-using-the-planner.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
},
2626
"outputs": [],
2727
"source": [
28-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
29-
"#r \"nuget: Microsoft.SemanticKernel.Planners.Handlebars, 1.0.0-rc4\"\n",
28+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
29+
"#r \"nuget: Microsoft.SemanticKernel.Planners.Handlebars, 1.0.1-preview\"\n",
3030
"\n",
3131
"#!import config/Settings.cs\n",
3232
"#!import config/Utils.cs\n",

dotnet/notebooks/06-memory-and-embeddings.ipynb

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
},
3434
"outputs": [],
3535
"source": [
36-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
36+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
37+
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Memory, 1.0.1-alpha\"\n",
3738
"#r \"nuget: System.Linq.Async, 6.0.1\"\n",
3839
"\n",
3940
"#!import config/Settings.cs\n",
@@ -87,7 +88,7 @@
8788
"using Microsoft.SemanticKernel.Connectors.OpenAI;\n",
8889
"\n",
8990
"// Memory functionality is experimental\n",
90-
"#pragma warning disable SKEXP0011, SKEXP0052\n",
91+
"#pragma warning disable SKEXP0003, SKEXP0011, SKEXP0052\n",
9192
"\n",
9293
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
9394
"\n",
@@ -459,7 +460,7 @@
459460
"outputs": [],
460461
"source": [
461462
"// Memory functionality is experimental\n",
462-
"#pragma warning disable SKEXP0011, SKEXP0052\n",
463+
"#pragma warning disable SKEXP0003, SKEXP0011, SKEXP0052\n",
463464
"\n",
464465
"var memoryBuilder = new MemoryBuilder();\n",
465466
"\n",

dotnet/notebooks/07-DALL-E-2.ipynb renamed to dotnet/notebooks/07-DALL-E-3.ipynb

+12-11
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"source": [
88
"# Generating images with AI\n",
99
"\n",
10-
"This notebook demonstrates how to use OpenAI DALL-E 2 to generate images, in combination with other LLM features like text and embedding generation.\n",
10+
"This notebook demonstrates how to use OpenAI DALL-E 3 to generate images, in combination with other LLM features like text and embedding generation.\n",
1111
"\n",
12-
"Here, we use Chat Completion to generate a random image description and DALL-E 2 to create an image from that description, showing the image inline.\n",
12+
"Here, we use Chat Completion to generate a random image description and DALL-E 3 to create an image from that description, showing the image inline.\n",
1313
"\n",
1414
"Lastly, the notebook asks the user to describe the image. The embedding of the user's description is compared to the original description, using Cosine Similarity, and returning a score from 0 to 1, where 1 means exact match."
1515
]
@@ -33,7 +33,8 @@
3333
"source": [
3434
"// Usual setup: importing Semantic Kernel SDK and SkiaSharp, used to display images inline.\n",
3535
"\n",
36-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
36+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
37+
"#r \"nuget: System.Numerics.Tensors, 8.0.0\"\n",
3738
"#r \"nuget: SkiaSharp, 2.88.3\"\n",
3839
"\n",
3940
"#!import config/Settings.cs\n",
@@ -56,7 +57,7 @@
5657
"\n",
5758
"The notebook uses:\n",
5859
"\n",
59-
"* **OpenAI Dall-E 2** to transform the image description into an image\n",
60+
"* **OpenAI Dall-E 3** to transform the image description into an image\n",
6061
"* **text-embedding-ada-002** to compare your guess against the real image description\n",
6162
"\n",
6263
"**Note:**: For Azure OpenAI, your endpoint should have DALL-E API enabled."
@@ -85,14 +86,14 @@
8586
"// Load OpenAI credentials from config/settings.json\n",
8687
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
8788
"\n",
88-
"// Configure the three AI features: text embedding (using Ada), text completion (using DaVinci 3), image generation (DALL-E 2)\n",
89+
"// Configure the three AI features: text embedding (using Ada), chat completion, image generation (DALL-E 3)\n",
8990
"var builder = Kernel.CreateBuilder();\n",
9091
"\n",
9192
"if(useAzureOpenAI)\n",
9293
"{\n",
9394
" builder.AddAzureOpenAITextEmbeddingGeneration(\"text-embedding-ada-002\", azureEndpoint, apiKey);\n",
9495
" builder.AddAzureOpenAIChatCompletion(model, azureEndpoint, apiKey);\n",
95-
" builder.AddAzureOpenAITextToImage(azureEndpoint, apiKey);\n",
96+
" builder.AddAzureOpenAITextToImage(\"dall-e-3\", azureEndpoint, apiKey);\n",
9697
"}\n",
9798
"else\n",
9899
"{\n",
@@ -115,12 +116,12 @@
115116
"cell_type": "markdown",
116117
"metadata": {},
117118
"source": [
118-
"# Generate a (random) image with DALL-E 2\n",
119+
"# Generate a (random) image with DALL-E 3\n",
119120
"\n",
120121
"**genImgDescription** is a Semantic Function used to generate a random image description. \n",
121122
"The function takes in input a random number to increase the diversity of its output.\n",
122123
"\n",
123-
"The random image description is then given to **Dall-E 2** asking to create an image."
124+
"The random image description is then given to **Dall-E 3** asking to create an image."
124125
]
125126
},
126127
{
@@ -159,10 +160,10 @@
159160
"var imageDescriptionResult = await kernel.InvokeAsync(genImgDescription, new() { [\"input\"] = random });\n",
160161
"var imageDescription = imageDescriptionResult.ToString();\n",
161162
"\n",
162-
"// Use DALL-E 2 to generate an image. OpenAI in this case returns a URL (though you can ask to return a base64 image)\n",
163-
"var imageUrl = await dallE.GenerateImageAsync(imageDescription.Trim(), 512, 512);\n",
163+
"// Use DALL-E 3 to generate an image. OpenAI in this case returns a URL (though you can ask to return a base64 image)\n",
164+
"var imageUrl = await dallE.GenerateImageAsync(imageDescription.Trim(), 1024, 1024);\n",
164165
"\n",
165-
"await SkiaUtils.ShowImage(imageUrl, 512, 512);"
166+
"await SkiaUtils.ShowImage(imageUrl, 1024, 1024);"
166167
]
167168
},
168169
{

dotnet/notebooks/08-chatGPT-with-DALL-E-2.ipynb renamed to dotnet/notebooks/08-chatGPT-with-DALL-E-3.ipynb

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"cell_type": "markdown",
66
"metadata": {},
77
"source": [
8-
"# Using ChatGPT with the Semantic Kernel featuring DALL-E 2\n",
8+
"# Using ChatGPT with the Semantic Kernel featuring DALL-E 3\n",
99
"\n",
1010
"This notebook shows how to make use of the new ChatCompletion API from OpenAI, popularized by ChatGPT. This API brings a new ChatML schema which is different from the TextCompletion API. While the text completion API expects input a prompt and returns a simple string, the chat completion API expects in input a Chat history and returns a new message:\n",
1111
"\n",
@@ -34,7 +34,7 @@
3434
"source": [
3535
"When deciding between which one to use, know that ChatGPT models (i.e. gpt-3.5-turbo) are optimized for chat applications and have been fine-tuned for instruction-following and dialogue. As such, for creating semantic plugins with the Semantic Kernel, users may still find the TextCompletion model better suited for certain use cases.\n",
3636
"\n",
37-
"The code below shows how to setup SK with ChatGPT, how to manage the Chat history object, and to make things a little more interesting asks ChatGPT to reply with image descriptions instead so we can have a dialog using images, leveraging DALL-E 2 integration."
37+
"The code below shows how to setup SK with ChatGPT, how to manage the Chat history object, and to make things a little more interesting asks ChatGPT to reply with image descriptions instead so we can have a dialog using images, leveraging DALL-E 3 integration."
3838
]
3939
},
4040
{
@@ -56,7 +56,7 @@
5656
"source": [
5757
"// Usual setup: importing Semantic Kernel SDK and SkiaSharp, used to display images inline.\n",
5858
"\n",
59-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
59+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
6060
"#r \"nuget: SkiaSharp, 2.88.3\"\n",
6161
"\n",
6262
"#!import config/Settings.cs\n",
@@ -77,7 +77,7 @@
7777
"The notebook uses:\n",
7878
"\n",
7979
"* **OpenAI ChatGPT** to chat with the user\n",
80-
"* **OpenAI Dall-E 2** to transform messages into images"
80+
"* **OpenAI Dall-E 3** to transform messages into images"
8181
]
8282
},
8383
{
@@ -103,13 +103,13 @@
103103
"// Load OpenAI credentials from config/settings.json\n",
104104
"var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();\n",
105105
"\n",
106-
"// Configure the two AI features: OpenAI Chat and DALL-E 2 for image generation\n",
106+
"// Configure the two AI features: OpenAI Chat and DALL-E 3 for image generation\n",
107107
"var builder = Kernel.CreateBuilder();\n",
108108
"\n",
109109
"if(useAzureOpenAI)\n",
110110
"{\n",
111111
" builder.AddAzureOpenAIChatCompletion(\"gpt-35-turbo\", azureEndpoint, apiKey);\n",
112-
" builder.AddAzureOpenAITextToImage(azureEndpoint, apiKey);\n",
112+
" builder.AddAzureOpenAITextToImage(\"dall-e-3\", azureEndpoint, apiKey);\n",
113113
"}\n",
114114
"else\n",
115115
"{\n",
@@ -135,7 +135,7 @@
135135
"\n",
136136
"Before starting the chat, we create a new chat object with some instructions, which are included in the chat history. \n",
137137
"\n",
138-
"The instructions tell OpenAI what kind of chat we want to have, in this case we ask to reply with \"image descriptions\", so that we can chain ChatGPT with DALL-E 2."
138+
"The instructions tell OpenAI what kind of chat we want to have, in this case we ask to reply with \"image descriptions\", so that we can chain ChatGPT with DALL-E 3."
139139
]
140140
},
141141
{
@@ -210,8 +210,8 @@
210210
"\n",
211211
" // 3. Show the reply as an image\n",
212212
" Console.WriteLine($\"\\nBot:\");\n",
213-
" var imageUrl = await dallE.GenerateImageAsync(assistantReply.Content, 256, 256);\n",
214-
" await SkiaUtils.ShowImage(imageUrl, 256, 256);\n",
213+
" var imageUrl = await dallE.GenerateImageAsync(assistantReply.Content, 1024, 1024);\n",
214+
" await SkiaUtils.ShowImage(imageUrl, 1024, 1024);\n",
215215
" Console.WriteLine($\"[{assistantReply}]\\n\");\n",
216216
"}"
217217
]

dotnet/notebooks/09-memory-with-chroma.ipynb

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
},
3939
"outputs": [],
4040
"source": [
41-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
42-
"#r \"nuget: Microsoft.SemanticKernel.Connectors.Chroma, 1.0.0-rc4\"\n",
41+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
42+
"#r \"nuget: Microsoft.SemanticKernel.Connectors.Chroma, 1.0.1-alpha\"\n",
43+
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Memory, 1.0.1-alpha\"\n",
4344
"#r \"nuget: System.Linq.Async, 6.0.1\"\n",
4445
"\n",
4546
"#!import config/Settings.cs\n",
@@ -99,7 +100,7 @@
99100
},
100101
"outputs": [],
101102
"source": [
102-
"#pragma warning disable SKEXP0011, SKEXP0022, SKEXP0052\n",
103+
"#pragma warning disable SKEXP0003, SKEXP0011, SKEXP0022, SKEXP0052\n",
103104
"\n",
104105
"using Microsoft.SemanticKernel.Connectors.OpenAI;\n",
105106
"\n",
@@ -469,7 +470,7 @@
469470
},
470471
"outputs": [],
471472
"source": [
472-
"#pragma warning disable SKEXP0011, SKEXP0022, SKEXP0052\n",
473+
"#pragma warning disable SKEXP0003, SKEXP0011, SKEXP0022, SKEXP0052\n",
473474
"\n",
474475
"var memoryBuilder = new MemoryBuilder();\n",
475476
"\n",

dotnet/notebooks/10-BingSearch-using-kernel.ipynb

+3-10
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
},
3636
"outputs": [],
3737
"source": [
38-
"#r \"nuget: Microsoft.SemanticKernel, 1.0.0-rc4\"\n",
39-
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Web, 1.0.0-rc4\"\n",
38+
"#r \"nuget: Microsoft.SemanticKernel, 1.0.1\"\n",
39+
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Web, 1.0.1-alpha\"\n",
40+
"#r \"nuget: Microsoft.SemanticKernel.Plugins.Core, 1.0.1-alpha\"\n",
4041
"\n",
4142
"#!import config/Settings.cs\n",
4243
"#!import config/Utils.cs\n",
@@ -186,14 +187,6 @@
186187
"}"
187188
]
188189
},
189-
{
190-
"attachments": {},
191-
"cell_type": "markdown",
192-
"metadata": {},
193-
"source": [
194-
"Just uncomment the examples to run them in the following code:"
195-
]
196-
},
197190
{
198191
"cell_type": "code",
199192
"execution_count": null,

dotnet/notebooks/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ For a quick dive, look at the [getting started notebook](00-getting-started.ipyn
6060
4. [Using Kernel Arguments to Build a Chat Experience](04-kernel-arguments-chat.ipynb)
6161
5. [Creating and Executing Plans](05-using-the-planner.ipynb)
6262
6. [Building Memory with Embeddings](06-memory-and-embeddings.ipynb)
63-
7. [Creating images with DALL-E 2](07-DALL-E-2.ipynb)
64-
8. [Chatting with ChatGPT and Images](08-chatGPT-with-DALL-E-2.ipynb)
63+
7. [Creating images with DALL-E 3](07-DALL-E-3.ipynb)
64+
8. [Chatting with ChatGPT and Images](08-chatGPT-with-DALL-E-3.ipynb)
6565
9. [Building Semantic Memory with Chroma](09-memory-with-chroma.ipynb)
6666
10. [BingSearch using Kernel](10-BingSearch-using-kernel.ipynb)
6767

0 commit comments

Comments
 (0)