Before starting we need to setup some configuration, like which AI backend to use.
When using the kernel for AI requests, the kernel needs some settings like URL and credentials to the AI models. The SDK currently supports OpenAI and Azure OpenAI, other services will be added over time. If you need an Azure OpenAI key, go here.
The following code will ask a few questions and save the settings to a local
settings.json
configuration file, under the config folder. You can
also edit the file manually if you prefer. Please keep the file safe.
First step: choose whether you want to use the notebooks with Azure OpenAI or OpenAI,
setting the useAzureOpenAI
boolean below.
bool useAzureOpenAI = false;
Run the following code. If you need to find the value and copy and paste, you can re-run the code and continue from where you left off.
#!import config/Settings.cs
await Settings.AskAzureEndpoint(useAzureOpenAI);
await Settings.AskModel(useAzureOpenAI);
await Settings.AskApiKey(useAzureOpenAI);
// Uncomment this if you're using OpenAI and need to set the Org Id
// await Settings.AskOrg(useAzureOpenAI);
If the code above doesn't show any error, you're good to go and run the other notebooks.
If you want to reset the configuration and start again, please uncomment and run the code below. You can also edit the config/settings.json manually if you prefer.
#!import config/Settings.cs
// Uncomment this line to reset your settings and delete the file from disk.
// Settings.Reset();
Now that your environment is all set up, let's dive into how to do basic loading of the Semantic Kernel.