-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1002 from solliancenet/aa-e2e-sdwza-examples
E2E examples 12 & 12: KM Agent on SDZWA
- Loading branch information
Showing
10 changed files
with
306 additions
and
11 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
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
64 changes: 64 additions & 0 deletions
64
tests/dotnet/Core.Examples/Example0011_KnowledgeManagementAgentWithSemanticKernel.cs
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using FoundationaLLM.Core.Examples.Constants; | ||
using FoundationaLLM.Core.Examples.Interfaces; | ||
using FoundationaLLM.Core.Examples.Setup; | ||
using Xunit.Abstractions; | ||
|
||
namespace FoundationaLLM.Core.Examples | ||
{ | ||
/// <summary> | ||
/// Example class for the Knowledge Management agent with LangChain. | ||
/// </summary> | ||
public class Example0011_KnowledgeManagementAgentWithSemanticKernel : BaseTest, IClassFixture<TestFixture> | ||
{ | ||
private readonly IAgentConversationTestService _agentConversationTestService; | ||
|
||
private string textEmbeddingProfileName = "text_embedding_profile_generic"; | ||
private string indexingProfileName = "indexing_profile_sdzwa"; | ||
|
||
public Example0011_KnowledgeManagementAgentWithSemanticKernel(ITestOutputHelper output, TestFixture fixture) | ||
: base(output, fixture.ServiceProvider) | ||
{ | ||
_agentConversationTestService = GetService<IAgentConversationTestService>(); | ||
} | ||
|
||
[Fact] | ||
public async Task RunAsync() | ||
{ | ||
WriteLine("============ Knowledge Management agent with Semantic Kernel on SDZWA ============"); | ||
await RunExampleAsync(); | ||
} | ||
|
||
private async Task RunExampleAsync() | ||
{ | ||
var agentName = TestAgentNames.SemanticKernelSDZWA; | ||
var userPrompts = new List<string> | ||
{ | ||
"Who are you?", | ||
"Tell me one interesting facts about the San Diego Zoo?", | ||
"How many animals does the San Diego Zoo host?", | ||
"What does the San Diego Zoo do to treat illness among it's inhabitants?" | ||
}; | ||
|
||
WriteLine($"Send questions to the {agentName} agent."); | ||
|
||
var response = await _agentConversationTestService.RunAgentConversationWithSession( | ||
agentName, userPrompts, null, true, indexingProfileName, textEmbeddingProfileName); | ||
|
||
WriteLine($"Agent conversation history:"); | ||
|
||
var invalidAgentResponsesFound = 0; | ||
foreach (var message in response) | ||
{ | ||
WriteLine($"- {message.Sender}: {message.Text}"); | ||
|
||
if (string.Equals(message.Sender, Common.Constants.Agents.InputMessageRoles.Assistant, StringComparison.CurrentCultureIgnoreCase) && | ||
message.Text == TestResponseMessages.FailedCompletionResponse) | ||
{ | ||
invalidAgentResponsesFound++; | ||
} | ||
} | ||
|
||
Assert.True(invalidAgentResponsesFound == 0, $"{invalidAgentResponsesFound} invalid agent responses found."); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
tests/dotnet/Core.Examples/Example0012_KnowledgeManagementAgentWithLangChain.cs
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using FoundationaLLM.Core.Examples.Constants; | ||
using FoundationaLLM.Core.Examples.Interfaces; | ||
using FoundationaLLM.Core.Examples.Setup; | ||
using Xunit.Abstractions; | ||
|
||
namespace FoundationaLLM.Core.Examples | ||
{ | ||
/// <summary> | ||
/// Example class for the Knowledge Management agent with SemanticKernel. | ||
/// </summary> | ||
public class Example0012_KnowledgeManagementAgentWithLangChain : BaseTest, IClassFixture<TestFixture> | ||
{ | ||
private readonly IAgentConversationTestService _agentConversationTestService; | ||
|
||
private string textEmbeddingProfileName = "text_embedding_profile_generic"; | ||
private string indexingProfileName = "indexing_profile_sdzwa"; | ||
|
||
public Example0012_KnowledgeManagementAgentWithLangChain(ITestOutputHelper output, TestFixture fixture) | ||
: base(output, fixture.ServiceProvider) | ||
{ | ||
_agentConversationTestService = GetService<IAgentConversationTestService>(); | ||
} | ||
|
||
[Fact] | ||
public async Task RunAsync() | ||
{ | ||
WriteLine("============ Knowledge Management agent with Lang Chain on SDZWA ============"); | ||
await RunExampleAsync(); | ||
} | ||
|
||
private async Task RunExampleAsync() | ||
{ | ||
var agentName = TestAgentNames.LangChainSDZWA; | ||
var userPrompts = new List<string> | ||
{ | ||
"Who are you?", | ||
"Tell me one interesting facts about the San Diego Zoo?", | ||
"How many animals does the San Diego Zoo host?", | ||
"What does the San Diego Zoo do to treat illness among it's inhabitants?" | ||
}; | ||
|
||
WriteLine($"Send questions to the {agentName} agent."); | ||
|
||
var response = await _agentConversationTestService.RunAgentConversationWithSession( | ||
agentName, userPrompts, null, true, indexingProfileName, textEmbeddingProfileName); | ||
|
||
WriteLine($"Agent conversation history:"); | ||
|
||
var invalidAgentResponsesFound = 0; | ||
foreach (var message in response) | ||
{ | ||
WriteLine($"- {message.Sender}: {message.Text}"); | ||
|
||
if (string.Equals(message.Sender, Common.Constants.Agents.InputMessageRoles.Assistant, StringComparison.CurrentCultureIgnoreCase) && | ||
message.Text == TestResponseMessages.FailedCompletionResponse) | ||
{ | ||
invalidAgentResponsesFound++; | ||
} | ||
} | ||
|
||
Assert.True(invalidAgentResponsesFound == 0, $"{invalidAgentResponsesFound} invalid agent responses found."); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.