Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yortch committed Jan 17, 2025
1 parent bbe554e commit 8a81c5f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ In this lesson we will create a semantic kernel chatbot with a system prompt and

1. Open `Program.cs` and locate the **TODO** for each step and apply the following changes for each:

1. TODO: Step 1: add code to initialize kernel with chat completion:
1. **TODO: Step 1**: add code to initialize kernel with chat completion:

```csharp
IKernelBuilder builder = KernelBuilderProvider.CreateKernelWithChatCompletion();
Kernel kernel = builder.Build();
```

1. TODO: Step 2: add the following system prompt:
1. **TODO: Step 2**: add the following system prompt:

```csharp
OpenAIPromptExecutionSettings promptExecutionSettings = new()
Expand All @@ -30,13 +30,13 @@ In this lesson we will create a semantic kernel chatbot with a system prompt and
};
```

1. TODO: Step 3: initialize kernel arguments
1. **TODO: Step 3**: initialize kernel arguments

```csharp
KernelArguments kernelArgs = new(promptExecutionSettings);
```

1. TODO: Step 4: add a loop to invoke prompt asynchronously providing user input and kernel arguments:
1. **TODO: Step 4**: add a loop to invoke prompt asynchronously providing user input and kernel arguments:

```csharp
await foreach (var response in kernel.InvokePromptStreamingAsync(userInput, kernelArgs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ In this lesson we will add chat history to our chat agent.

1. Open `Program.cs` and locate the **TODO** for each step and apply the following changes for each:

1. TODO: Step 1: add code to include the chat completion namespace
1. **TODO: Step 1**: add code to include the chat completion namespace

```csharp
using Microsoft.SemanticKernel.ChatCompletion;
```

1. TODO: Step 2a: Add code to get `chatCompletionService` instance and to initialize `chatHistory` with system prompt
1. **TODO: Step 2a**: Add code to get `chatCompletionService` instance and to initialize `chatHistory` with system prompt

```csharp
var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
ChatHistory chatHistory = new("You are a friendly financial advisor that only emits financial advice in a creative and funny tone");
```

TODO: Step 2b: **Remove** the `promptExecutionSettings` and `kernelArgs` initialization code below
**TODO: Step 2b**: **Remove** the `promptExecutionSettings` and `kernelArgs` initialization code below

```csharp
OpenAIPromptExecutionSettings promptExecutionSettings = new()
Expand All @@ -45,14 +45,14 @@ In this lesson we will add chat history to our chat agent.
KernelArguments kernelArgs = new(promptExecutionSettings);
```

1. TODO: Step 3: Add code to initialize `fullMessage` variable and add user input to chat history:
1. **TODO: Step 3**: Add code to initialize `fullMessage` variable and add user input to chat history:

```csharp
string fullMessage = "";
chatHistory.AddUserMessage(userInput);
```

1. TODO: Step 4: **Remove** the `foreach` loop below:
1. **TODO: Step 4**: **Remove** the `foreach` loop below:

```csharp
await foreach (var response in kernel.InvokePromptStreamingAsync(userInput, kernelArgs))
Expand Down Expand Up @@ -105,7 +105,7 @@ In this lesson we will add chat history to our chat agent.
1. Next ask which stocks you should have bought if you could go back to the year you were born:
```txt
If I could go back in time to the year I was born, which stocks would have made me a millionare?
If I could go back in time to the year I was born, which stocks would have made me a millionaire?
```
You will receive a similar response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ In this lesson we will a semantic kernel plugins to be able to retrieve stock pr
dotnet run
```

At the prompt enter
At the prompt enter:

```bash
What is the current date?
```bash
What is the current date?
```

Assistant will give a similar response:
Assistant will give a similar response:

```txt
Assistant > I can't access today's date, but imagine it’s an eternal "Fri-yay," ready for financial fun! How can I help you on this hypothetical day?
```
```txt
Assistant > I can't access today's date, but imagine it’s an eternal "Fri-yay," ready for financial fun! How can I help you on this hypothetical day?
```

1. Notice it does not provide a specific answer. We can use a Semantic Kernel Plugin to be able to fix that.

1. In the `Plugins` directory from `Core.Utilities` directory review the file named
`TimeInformationPlugin.cs` which has the following content:
1. In the `Plugins` directory from `Core.Utilities` directory review the file named `TimeInformationPlugin.cs` which has the following content:

```csharp
using System.ComponentModel;
Expand All @@ -53,26 +52,25 @@ In this lesson we will a semantic kernel plugins to be able to retrieve stock pr
}
```

1. Next locate TODO: Step 1 in `Program.cs` and add the following import line:
1. Next locate **TODO: Step 1** in `Program.cs` and add the following import line:

```csharp
using Core.Utilities.Plugins;
```

1. Next locate TODO: Step 2 in `Program.cs` and provide the following line to register the `TimeInformationPlugin`:
1. Next locate **TODO: Step 2** in `Program.cs` and provide the following line to register the `TimeInformationPlugin`:

```csharp
kernel.Plugins.AddFromObject(new TimeInformationPlugin());
```
1. Next locate TODO: Step 3 and add the following line to be able to
auto invoke kernel functions:
1. Next locate **TODO: Step 3** and add the following line to be able to auto invoke kernel functions:
```csharp
ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions
```
1. Next locate TODO: Step 4 and add the following parameters:
1. Next locate **TODO: Step 4** and add the following parameters:
```csharp
await foreach (var chatUpdate in chatCompletionService.GetStreamingChatMessageContentsAsync(chatHistory, promptExecutionSettings, kernel))
Expand Down Expand Up @@ -125,13 +123,13 @@ In this lesson we will a semantic kernel plugins to be able to retrieve stock pr
}
```
1. Next, locate TODO: Step 5 in `Program.cs` and add import required for `StockService`:
1. Next, locate **TODO: Step 5** in `Program.cs` and add import required for `StockService`:
```csharp
using Core.Utilities.Services;
```
1. Next locate TODO: Step 6 and provide the following line to register the new `StockDataPlugin`:
1. Next locate **TODO: Step 6** and provide the following line to register the new `StockDataPlugin`:
```csharp
HttpClient httpClient = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

In this lesson we will add a Web Search Engine plugin that uses Bing Search to our semantic kernel chatbot.

1. Ensure all [pre-requisites](pre-reqs.md) are met and installed (including updating the `BingSearchService` `apiKey` value in the `appSettings.json` file using the key from **Bing Search Service v7** in Azure (https://portal.azure.com)).
1. Ensure all [pre-requisites](pre-reqs.md) are met and installed (including updating the `BingSearchService` `apiKey` value in the `appSettings.json` file using the key from **Bing Search Service v7** in [Azure Portal](https://portal.azure.com).

1. Switch to Lesson 4 directory:

Expand All @@ -22,24 +22,24 @@ In this lesson we will add a Web Search Engine plugin that uses Bing Search to o
dotnet run
```

At the prompt enter
1. At the prompt enter:

```bash
What is the sentiment on Microsoft stock?
```bash
What is the sentiment on Microsoft stock?
```

Assistant will give a generic response:
Assistant will give a generic response:

```txt
Assistant > The sentiment on Microsoft (ticker symbol: MSFT) largely hinges on factors like:
```txt
Assistant > The sentiment on Microsoft (ticker symbol: MSFT) largely hinges on factors like:
- Tech innovation (e.g., AI, Azure cloud service, and gaming)
- Quarterly earnings reports
- Overall market conditions
- How much caffeine traders have consumed
```
- Tech innovation (e.g., AI, Azure cloud service, and gaming)
- Quarterly earnings reports
- Overall market conditions
- How much caffeine traders have consumed
```

1. Notice it does not provide a specific answer. We can add the Web Search Engine plugin to be able to provide a better answer.
Notice it does not provide a specific answer. We can add the Web Search Engine plugin to be able to provide a better answer.

1. Next locate **TODO: Step 1** in `Program.cs` and add the following import lines:

Expand Down

0 comments on commit 8a81c5f

Please sign in to comment.