Files
semantic-kernel/samples/dotnet/kernel-syntax-examples
af03e00a79 Feature serviceregistry (#993)
### Motivation, Context and Description

This PR introduces several changes aimed to simplify the kernel and
enhancing its extensibility for AI services management. The changes
include the following:

1. Kernel simplification and extensibility: The code responsible for AI
services management, such as registration and resolution, has been moved
out of the Kernel and KernelConfig classes into a new class called
AIServiceProvider. This restructuring promotes the principle of Single
Responsibility, ensuring that each class has a clear and focused
purpose.

2. Hosting apps customization: With the introduction of the
AIServiceProvider, hosting applications now have the flexibility to
provide their own implementation of the provider if needed. This
promotes extensibility, allowing the hosting apps to tailor the AI
service management according to their specific requirements.

3. AI services registration improvements: A new method called
WithAiService has been added, which enables the registration of any new
AI service that is not currently supported.

4. Improved kernel builder interface: The Add* methods for AI services
registration have been moved from the KernelConfig class to the
KernelBuilder. This change aligns the interface with other KernelBilder
methods, such as WithLogger and WithMemory, creating a more cohesive and
intuitive kernel builder interface.

---------

Co-authored-by: Shawn Callegari <[email protected]>
Co-authored-by: Lee Miller <[email protected]>
2023-05-22 15:21:48 -07:00
..
2023-05-01 19:50:10 -07:00
2023-05-01 19:50:10 -07:00
2023-05-22 15:21:48 -07:00

Semantic Kernel syntax examples

This project contains a collection of semi-random examples about various scenarios using SK components.

The examples are ordered by number, starting with very basic examples.

Most of the examples will require secrets and credentials, to access OpenAI, Azure OpenAI, Bing and other resources. We suggest using .NET Secret Manager to avoid the risk of leaking secrets into the repository, branches and pull requests. You can also use environment variables if you prefer.

To set your secrets with Secret Manager:

cd samples/dotnet/kernel-syntax-examples

dotnet user-secrets set "BING_API_KEY" "..."
dotnet user-secrets set "OPENAI_API_KEY" "..."
dotnet user-secrets set "AZURE_OPENAI_SERVICE_ID" "..."
dotnet user-secrets set "AZURE_OPENAI_DEPLOYMENT_NAME" "..."
dotnet user-secrets set "AZURE_OPENAI_CHAT_DEPLOYMENT_NAME" "..."
dotnet user-secrets set "AZURE_OPENAI_ENDPOINT" "https://... .openai.azure.com/"
dotnet user-secrets set "AZURE_OPENAI_KEY" "..."
dotnet user-secrets set "AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME" "..."
dotnet user-secrets set "AZURE_OPENAI_EMBEDDINGS_ENDPOINT" "https://... .openai.azure.com/"
dotnet user-secrets set "AZURE_OPENAI_EMBEDDINGS_KEY" "..."
dotnet user-secrets set "ACS_ENDPOINT" "https://... .search.windows.net"
dotnet user-secrets set "ACS_API_KEY" "..."
dotnet user-secrets set "QDRANT_ENDPOINT" "..."
dotnet user-secrets set "QDRANT_PORT" "..."
dotnet user-secrets set "GITHUB_PERSONAL_ACCESS_TOKEN" "github_pat_..."
dotnet user-secrets set "POSTGRES_CONNECTIONSTRING" "..."

To set your secrets with environment variables, use these names:

  • BING_API_KEY
  • OPENAI_API_KEY
  • AZURE_OPENAI_SERVICE_ID
  • AZURE_OPENAI_DEPLOYMENT_NAME
  • AZURE_OPENAI_ENDPOINT
  • AZURE_OPENAI_KEY
  • ACS_ENDPOINT
  • ACS_API_KEY
  • QDRANT_ENDPOINT
  • QDRANT_PORT
  • GITHUB_PERSONAL_ACCESS_TOKEN
  • POSTGRES_CONNECTIONSTRING
  • AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME
  • AZURE_OPENAI_EMBEDDINGS_ENDPOINT
  • AZURE_OPENAI_EMBEDDINGS_KEY