mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* Add ADR for different run response options * Add another option to the list. * Update agno non-streaming with further clarification * Add another option * Adding optional includeUpdates option * Adding Pros/Cons for each option * Make pros/cons a list * Add some thoughts on structured outputs and custom AIContent types * Update design doc to clarify primary and secondary better and split out custom response types with it's own options * Add structured outputs competitive comparison and suggestion * Address PR comments. * Remove AgentRunFinishReason until we can find a good use case for it. * Add finish reason to list of excluded properties. * Add custom agent run response types. Usage to follow. * Update Agent run response types * Add additional code coverage * Remove onIntermediateMessage since it is unecessary with the new response approach. * Add AgentId to response. * Rename ParseAsStructuredOutput to Deserialize * Update decision doc. * Fix formatting. * Update CopilotStudio to return new response types * Address PR comment Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> --------- Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.AI;
|
|
using Microsoft.Extensions.AI.Agents;
|
|
using Moq;
|
|
|
|
namespace Microsoft.Agents.Orchestration.UnitTest;
|
|
|
|
/// <summary>
|
|
/// Mock definition of <see cref="Agent"/>.
|
|
/// </summary>
|
|
internal sealed class MockAgent(int index) : Agent
|
|
{
|
|
public static MockAgent CreateWithResponse(int index, string response)
|
|
{
|
|
return new(index)
|
|
{
|
|
Response = [new(ChatRole.Assistant, response)]
|
|
};
|
|
}
|
|
|
|
public int InvokeCount { get; private set; }
|
|
|
|
public IReadOnlyList<ChatMessage> Response { get; set; } = [];
|
|
|
|
public override string? Name => $"testagent{index}";
|
|
|
|
public override string? Description => $"test {index}";
|
|
|
|
public override AgentThread GetNewThread()
|
|
{
|
|
return new AgentThread() { Id = Guid.NewGuid().ToString() };
|
|
}
|
|
|
|
public override Task<AgentRunResponse> RunAsync(IReadOnlyCollection<ChatMessage> messages, AgentThread? thread = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)
|
|
{
|
|
this.InvokeCount++;
|
|
if (thread == null)
|
|
{
|
|
Mock<AgentThread> mockThread = new(MockBehavior.Strict);
|
|
thread = mockThread.Object;
|
|
}
|
|
|
|
return Task.FromResult(new AgentRunResponse(messages: [.. this.Response]));
|
|
}
|
|
|
|
public override IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync(IReadOnlyCollection<ChatMessage> messages, AgentThread? thread = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)
|
|
{
|
|
this.InvokeCount++;
|
|
|
|
return this.Response.Select(message => new AgentRunResponseUpdate(message.Role, message.Text)).ToAsyncEnumerable();
|
|
}
|
|
}
|