Skip to content

Commit

Permalink
.Net - Agent Samples Restructure (#5987)
Browse files Browse the repository at this point in the history
### 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.
-->

Organize samples as part of restructuring.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Added `Getting_Started` along with two functional areas:
`OpenAIAssistant` and `MixedAssistants`


![image](https://github.com/microsoft/semantic-kernel/assets/66376200/3bb9be12-5a54-4406-a175-2529a1fdbcf5)

### 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
crickman authored Apr 24, 2024
1 parent 5ba79ee commit e0be616
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 89 deletions.
4 changes: 4 additions & 0 deletions dotnet/samples/Concepts/AgentSyntax/AgentSyntax.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@
</EmbeddedResource>
<None Remove="Resources\*" />
</ItemGroup>
<ItemGroup>
<Folder Include="MixedAgents\" />
<Folder Include="OpenAIAssistant\" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion dotnet/samples/Concepts/AgentSyntax/BaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Reflection;
using Configuration;
using Microsoft.Extensions.Configuration;
Expand Down
68 changes: 0 additions & 68 deletions dotnet/samples/Concepts/AgentSyntax/Example11_OpenAIAssistant.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
using Xunit;
using Xunit.Abstractions;

namespace Examples;
namespace GettingStarted;

/// <summary>
/// Demonstrate creation of <see cref="ChatCompletionAgent"/> and
/// eliciting its response to three explicit user messages.
/// </summary>
public class Example01_Agent(ITestOutputHelper output) : BaseTest(output)
public class Step1_Agent(ITestOutputHelper output) : BaseTest(output)
{
private const string ParrotName = "Parrot";
private const string ParrotInstructions = "Repeat the user message in the voice of a pirate and then end with a parrot sound.";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
Expand All @@ -8,13 +9,13 @@
using Xunit;
using Xunit.Abstractions;

namespace Examples;
namespace GettingStarted;

/// <summary>
/// Demonstrate creation of <see cref="ChatCompletionAgent"/> with a <see cref="KernelPlugin"/>,
/// and then eliciting its response to explicit user messages.
/// </summary>
public class Example02_Plugins(ITestOutputHelper output) : BaseTest(output)
public class Step2_Plugins(ITestOutputHelper output) : BaseTest(output)
{
private const string HostName = "Host";
private const string HostInstructions = "Answer questions about the menu.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Examples;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
using Xunit;
using Xunit.Abstractions;

namespace Examples;
namespace GettingStarted;

/// <summary>
/// Demonstrate creation of <see cref="AgentChat"/> with <see cref="AgentGroupChatSettings"/>
/// that inform how chat proceeds with regards to: Agent selection, chat continuation, and maximum
/// number of agent interactions.
/// </summary>
public class Example03_Chat(ITestOutputHelper output) : BaseTest(output)
public class Step3_Chat(ITestOutputHelper output) : BaseTest(output)
{
private const string ReviewerName = "ArtDirector";
private const string ReviewerInstructions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
using Xunit.Abstractions;

namespace Examples;

/// <summary>
/// Demonstrate that two different agent types are able to participate in the same conversation.
/// In this case a <see cref="ChatCompletionAgent"/> and <see cref="OpenAIAssistantAgent"/> participate.
/// </summary>
public class Example16_MixedChat(ITestOutputHelper output) : BaseTest(output)
public class MixedChat_Agents(ITestOutputHelper output) : BaseTest(output)
{
private const string ReviewerName = "ArtDirector";
private const string ReviewerInstructions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
using Xunit.Abstractions;

namespace Examples;

/// <summary>
/// Demonstrate creation of <see cref="OpenAIAssistantAgent"/> with a <see cref="KernelPlugin"/>,
/// and then eliciting its response to explicit user messages.
/// Demonstrate creation of <see cref="OpenAIAssistantAgent"/> and
/// eliciting its response to three explicit user messages.
/// </summary>
/// <remarks>
/// This example demonstrates that outside of initialization (and cleanup), plugin
/// usage for <see cref="OpenAIAssistantAgent"/> is no different from <see cref="ChatCompletionAgent"/>.
/// This example demonstrates that outside of initialization (and cleanup), using
/// <see cref="OpenAIAssistantAgent"/> is no different from <see cref="ChatCompletionAgent"/>
/// even with with a <see cref="KernelPlugin"/>.
/// </remarks>
public class Example12_OpenAIAssistant_Plugins(ITestOutputHelper output) : BaseTest(output)
public class OpenAIAssistant_Agent(ITestOutputHelper output) : BaseTest(output)
{
private const string HostName = "Host";
private const string HostInstructions = "Answer questions about the menu.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
using Xunit.Abstractions;

namespace Examples;

/// <summary>
/// Demonstrate using code-interpreter with <see cref="OpenAIAssistantAgent"/> to
/// produce image content displays the requested charts.
/// </summary>
public class Example15_OpenAIAssistant_ChartMaker(ITestOutputHelper output) : BaseTest(output)
public class OpenAIAssistant_ChartMaker(ITestOutputHelper output) : BaseTest(output)
{
/// <summary>
/// Target Open AI services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
using Xunit.Abstractions;

namespace Examples;

/// <summary>
/// Demonstrate using code-interpreter on <see cref="OpenAIAssistantAgent"/> .
/// </summary>
public class Example13_OpenAIAssistant_CodeInterpreter(ITestOutputHelper output) : BaseTest(output)
public class OpenAIAssistant_CodeInterpreter(ITestOutputHelper output) : BaseTest(output)
{
[Fact]
public async Task RunAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
using Xunit.Abstractions;

namespace Examples;

/// <summary>
/// Demonstrate using retrieval on <see cref="OpenAIAssistantAgent"/> .
/// </summary>
public class Example14_OpenAIAssistant_Retrieval(ITestOutputHelper output) : BaseTest(output)
public class OpenAIAssistant_Retrieval(ITestOutputHelper output) : BaseTest(output)
{
/// <summary>
/// Retrieval tool not supported on Azure OpenAI.
Expand Down

0 comments on commit e0be616

Please sign in to comment.