/semantic-kernel-workshop-2024

Learn to build agent, rag application with Semantic Kernel through hands-on labs

Primary LanguageJupyter NotebookMIT LicenseMIT

Semantic Kernel C# Workshop

This workshop comprises notebooks designed to assist developers in quickly familiarizing themselves with Semantic Kernel. The labs showcase the two most common AI patterns: AI Agent and RAG. Throughout these labs, we will cover essential components and concepts to help you get started, whether you're just prototyping an idea or building a copilot for a product.

Topics

If you are attending the workshop in person, an Azure OpenAI API key has already been configured for you in the Lab enviroment.

For other users, make sure you configured config/settings.json before starting, see the setup section.

  1. Semantic Kernel - Agent
  2. Plugin
  3. Memory Embedding and RAG

Run

You can run these notebooks with any of the following options.

Option 1: Docker

This is the simplest option. Open a termial, enter the directory contains dockerfile. Run the following command.

  docker build -t sk-workshop .
  docker run --rm -p 8888:8888 sk-workshop jupyter lab serverextension enable --py nbgitpuller --sys-prefix --NotebookApp.token='' --NotebookApp.password='' 

Then open browser at http://localhost:8888

Option 2: VS Code

You can also Visual Studio Code with the Polygot extension

The steps above should be sufficient, you can now open all the C# notebooks in VS Code.

VS Code screenshot example:

image

Option 3: Run notebooks in the browser with JupyterLab

You can run the notebooks also in the browser with JupyterLab. These steps should be sufficient to start:

Install Python 3, Pip and .NET 8 in your system, then:

pip install jupyterlab
dotnet tool install -g Microsoft.dotnet-interactive
dotnet tool update -g Microsoft.dotnet-interactive
dotnet interactive jupyter install

This command will confirm that Jupyter now supports C# notebooks:

jupyter kernelspec list

Enter the notebooks folder, and run this to launch the browser interface:

jupyter-lab

image

Setup

To start using these notebooks, be sure to add the appropriate API keys to config/settings.json.

You can create the file manually or run the Setup notebook.

For Azure OpenAI:

{
  "type": "azure",
  "model": "...", // Azure OpenAI Deployment Name
  "endpoint": "...", // Azure OpenAI endpoint
  "apikey": "..." // Azure OpenAI key
}

For OpenAI:

{
  "type": "openai",
  "model": "gpt-3.5-turbo", // OpenAI model name
  "apikey": "...", // OpenAI API Key
  "org": "" // only for OpenAI accounts with multiple orgs
}

If you need an Azure OpenAI key, go here. If you need an OpenAI key, go here

Troubleshooting

Nuget

If you are unable to get the Nuget package, first list your Nuget sources:

dotnet nuget list source

If you see No sources found., add the NuGet official package source:

dotnet nuget add source "https://api.nuget.org/v3/index.json" --name "nuget.org"

Run dotnet nuget list source again to verify the source was added.

Polyglot Notebooks

If somehow the notebooks don't work, run these commands:

Note: "Polyglot Notebooks" used to be called ".NET Interactive Notebooks", so you might find online some documentation referencing the old name.

Acknowledgement

The above instructions include content adapted from the README file of the Microsoft Semantic Kernel repository, available at: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/README.md.