mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Add test infrastructure for agent conformance tests (#77)
* Add test infrastructure for agent conformance tests * Address PR comments. * Switch TargetFrameworks to have inline condition
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AgentConformance.IntegrationTests;
|
||||
using AgentConformanceTests;
|
||||
using Microsoft.Agents;
|
||||
using Microsoft.Extensions.AI;
|
||||
using OpenAI;
|
||||
|
||||
namespace OpenAIChatCompletion.IntegrationTests;
|
||||
|
||||
public class OpenAIChatCompletionFixture : AgentFixture
|
||||
{
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
private IChatClient _chatClient;
|
||||
private Agent _agent;
|
||||
private AgentThread _agentThread;
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
|
||||
public override Agent Agent => this._agent;
|
||||
|
||||
public override AgentThread AgentThread => this._agentThread;
|
||||
|
||||
public override Task<List<ChatMessage>> GetChatHistory()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Task InitializeAsync()
|
||||
{
|
||||
var config = TestConfiguration.LoadSection<OpenAIConfiguration>();
|
||||
|
||||
this._chatClient = new OpenAIClient(config.ApiKey)
|
||||
.GetChatClient(config.ChatModelId)
|
||||
.AsIChatClient();
|
||||
|
||||
this._agentThread = new ChatClientAgentThread();
|
||||
|
||||
this._agent =
|
||||
new ChatClientAgent(this._chatClient, new()
|
||||
{
|
||||
Name = "HelpfulAssistant",
|
||||
Instructions = "You are a helpful assistant.",
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task DisposeAsync()
|
||||
{
|
||||
this._chatClient.Dispose();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user