-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Enhance `readme.md` associated with _Agent_ samples. Also include _ agent sample in _Getting Started with Agents_. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Updated readmes - Clean-up pass on samples - Added an OpenAI Assistant to _Getting Started_ ### 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 😄
- Loading branch information
Showing
6 changed files
with
199 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,89 @@ | ||
# Semantic Kernel: Agent syntax examples | ||
This project contains a collection of examples on how to use _Semantic Kernel Agents_. | ||
|
||
This project contains a collection of examples on how to use SK Agents. | ||
#### NuGet: | ||
- [Microsoft.SemanticKernel.Agents.Abstractions](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.Abstractions) | ||
- [Microsoft.SemanticKernel.Agents.Core](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.Core) | ||
- [Microsoft.SemanticKernel.Agents.OpenAI](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.OpenAI) | ||
|
||
#### Source | ||
- [Semantic Kernel Agent Framework](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Agents) | ||
|
||
The examples can be run as integration tests but their code can also be copied to stand-alone programs. | ||
|
||
## Running Examples with Filters | ||
## Examples | ||
|
||
You can run specific examples in the KernelSyntaxExamples project by using test filters (dotnet test --filter). | ||
Type "dotnet test --help" at the command line for more details. | ||
The concept agents examples are grouped by prefix: | ||
|
||
## Configuring Secrets | ||
Prefix|Description | ||
---|--- | ||
OpenAIAssistant|How to use agents based on the [Open AI Assistant API](https://platform.openai.com/docs/assistants). | ||
MixedChat|How to combine different agent types. | ||
ComplexChat|How to deveop complex agent chat solutions. | ||
Legacy|How to use the legacy _Experimental Agent API_. | ||
|
||
## Legacy Agents | ||
|
||
Most of the examples will require secrets and credentials, to access OpenAI, Azure OpenAI, | ||
Bing and other resources. We suggest using .NET | ||
[Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets) | ||
to avoid the risk of leaking secrets into the repository, branches and pull requests. | ||
You can also use environment variables if you prefer. | ||
Support for the OpenAI Assistant API was originally published in `Microsoft.SemanticKernel.Experimental.Agents` package: | ||
[Microsoft.SemanticKernel.Experimental.Agents](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Experimental/Agents) | ||
|
||
To set your secrets with Secret Manager: | ||
This package has been superseded by _Semantic Kernel Agents_, which includes support for Open AI Assistant agents. | ||
|
||
## Running Examples | ||
Examples may be explored and ran within _Visual Studio_ using _Test Explorer_. | ||
|
||
You can also run specific examples via the command-line by using test filters (`dotnet test --filter`). Type `dotnet test --help` at the command line for more details. | ||
|
||
Example: | ||
|
||
``` | ||
dotnet test --filter OpenAIAssistant_CodeInterpreter | ||
``` | ||
cd dotnet/samples/AgentSyntaxExamples | ||
|
||
dotnet user-secrets init | ||
## Configuring Secrets | ||
|
||
dotnet user-secrets set "OpenAI:ChatModelId" "..." | ||
dotnet user-secrets set "OpenAI:ApiKey" "..." | ||
Each example requires secrets / credentials to access OpenAI or Azure OpenAI. | ||
|
||
dotnet user-secrets set "AzureOpenAI:DeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:ChatDeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://... .openai.azure.com/" | ||
dotnet user-secrets set "AzureOpenAI:ApiKey" "..." | ||
We suggest using .NET [Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets) 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 .NET Secret Manager: | ||
|
||
1. Navigate the console to the project folder: | ||
|
||
``` | ||
cd dotnet/samples/GettingStartedWithAgents | ||
``` | ||
|
||
2. Examine existing secret definitions: | ||
|
||
``` | ||
dotnet user-secrets list | ||
``` | ||
|
||
3. If needed, perform first time initialization: | ||
|
||
``` | ||
dotnet user-secrets init | ||
``` | ||
|
||
4. Define secrets for either Open AI: | ||
|
||
``` | ||
dotnet user-secrets set "OpenAI:ChatModelId" "..." | ||
dotnet user-secrets set "OpenAI:ApiKey" "..." | ||
``` | ||
|
||
5. Or Azure Open AI: | ||
|
||
``` | ||
dotnet user-secrets set "AzureOpenAI:DeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:ChatDeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://... .openai.azure.com/" | ||
dotnet user-secrets set "AzureOpenAI:ApiKey" "..." | ||
``` | ||
|
||
> NOTE: Azure secrets will take precedence, if both Open AI and Azure Open AI secrets are defined, unless `ForceOpenAI` is set: | ||
``` | ||
protected override bool ForceOpenAI => true; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,95 @@ | ||
# Semantic Kernel Agents - Getting Started | ||
|
||
This project contains a collection of examples on how to use SK Agents. | ||
This project contains a step by step guide to get started with _Semantic Kernel Agents_. | ||
|
||
|
||
#### NuGet: | ||
- [Microsoft.SemanticKernel.Agents.Abstractions](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.Abstractions) | ||
- [Microsoft.SemanticKernel.Agents.Core](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.Core) | ||
- [Microsoft.SemanticKernel.Agents.OpenAI](https://www.nuget.org/packages/Microsoft.SemanticKernel.Agents.OpenAI) | ||
|
||
#### Source | ||
- [Semantic Kernel Agent Framework](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Agents) | ||
|
||
The examples can be run as integration tests but their code can also be copied to stand-alone programs. | ||
|
||
## Examples | ||
|
||
The getting started with agents examples include: | ||
|
||
Example|Description | ||
---|--- | ||
[Step1_Agent](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs)|How to create and use an agent. | ||
[Step2_Plugins](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs)|How to associate plug-ins with an agent. | ||
[Step3_Chat](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs)|How to create a conversation between agents. | ||
[Step4_KernelFunctionStrategies](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Step4_KernelFunctionStrategies/Step1_Agent.cs)|How to utilize a `KernelFunction` as a _chat strategy_. | ||
[Step5_JsonResult](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs)|How to have an agent produce JSON. | ||
[Step6_DependencyInjection](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs)|How to define dependency injection patterns for agents. | ||
[Step7_OpenAIAssistant](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/GettingStartedWithAgents/Step7_OpenAIAssistant.cs)|How to create an Open AI Assistant agent. | ||
|
||
## Legacy Agents | ||
|
||
Support for the OpenAI Assistant API was originally published in `Microsoft.SemanticKernel.Experimental.Agents` package: | ||
[Microsoft.SemanticKernel.Experimental.Agents](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Experimental/Agents) | ||
|
||
This package has been superseded by _Semantic Kernel Agents_, which includes support for Open AI Assistant agents. | ||
|
||
|
||
## Running Examples with Filters | ||
Examples may be explored and ran within _Visual Studio_ using _Test Explorer_. | ||
|
||
You can also run specific examples via the command-line by using test filters (`dotnet test --filter`). Type `dotnet test --help` at the command line for more details. | ||
|
||
Example: | ||
|
||
You can run specific examples in the project by using test filters (dotnet test --filter). | ||
Type "dotnet test --help" at the command line for more details. | ||
``` | ||
dotnet test --filter Step3_Chat | ||
``` | ||
|
||
## Configuring Secrets | ||
|
||
Most of the examples will require secrets and credentials, to access OpenAI, Azure OpenAI, | ||
Bing and other resources. We suggest using .NET | ||
[Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets) | ||
to avoid the risk of leaking secrets into the repository, branches and pull requests. | ||
You can also use environment variables if you prefer. | ||
Each example requires secrets / credentials to access OpenAI or Azure OpenAI. | ||
|
||
To set your secrets with Secret Manager: | ||
We suggest using .NET [Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets) to avoid the risk of leaking secrets into the repository, branches and pull requests. You can also use environment variables if you prefer. | ||
|
||
``` | ||
cd dotnet/samples/AgentSyntaxExamples | ||
To set your secrets with .NET Secret Manager: | ||
|
||
1. Navigate the console to the project folder: | ||
|
||
``` | ||
cd dotnet/samples/GettingStartedWithAgents | ||
``` | ||
|
||
2. Examine existing secret definitions: | ||
|
||
dotnet user-secrets init | ||
``` | ||
dotnet user-secrets list | ||
``` | ||
|
||
dotnet user-secrets set "OpenAI:ChatModelId" "..." | ||
dotnet user-secrets set "OpenAI:ApiKey" "..." | ||
3. If needed, perform first time initialization: | ||
|
||
dotnet user-secrets set "AzureOpenAI:DeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:ChatDeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://... .openai.azure.com/" | ||
dotnet user-secrets set "AzureOpenAI:ApiKey" "..." | ||
``` | ||
dotnet user-secrets init | ||
``` | ||
|
||
4. Define secrets for either Open AI: | ||
|
||
``` | ||
dotnet user-secrets set "OpenAI:ChatModelId" "..." | ||
dotnet user-secrets set "OpenAI:ApiKey" "..." | ||
``` | ||
|
||
5. Or Azure Open AI: | ||
|
||
``` | ||
dotnet user-secrets set "AzureOpenAI:DeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:ChatDeploymentName" "..." | ||
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://... .openai.azure.com/" | ||
dotnet user-secrets set "AzureOpenAI:ApiKey" "..." | ||
``` | ||
|
||
> NOTE: Azure secrets will take precedence, if both Open AI and Azure Open AI secrets are defined, unless `ForceOpenAI` is set: | ||
``` | ||
protected override bool ForceOpenAI => true; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters