mirror of https://github.com/microsoft/autogen.git
Merge 2766b47142
into eca80ff663
This commit is contained in:
commit
564e5c1dbc
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Termination.cs
|
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Abstractions;
|
namespace Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
public static class TerminationConditionExtensions
|
public static class TerminationConditionExtensions
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// ExternalTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// FunctionCallTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// HandoffTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// SourceMatchTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// StopMessageTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// TextMentionTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
using Microsoft.Extensions.AI;
|
using Microsoft.Extensions.AI;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// TokenUsageTermination.cs
|
|
||||||
|
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
|
|
||||||
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
namespace Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// TerminationConditionTests.cs
|
|
||||||
|
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.AutoGen.AgentChat.Abstractions;
|
using Microsoft.AutoGen.AgentChat.Abstractions;
|
||||||
using Microsoft.AutoGen.AgentChat.Terminations;
|
using Microsoft.AutoGen.AgentChat.Terminations;
|
||||||
|
@ -473,4 +470,25 @@ public class TerminationConditionTests
|
||||||
termination.Reset();
|
termination.Reset();
|
||||||
termination.IsTerminated.Should().BeFalse();
|
termination.IsTerminated.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Test_SourceMatchTermination()
|
||||||
|
{
|
||||||
|
SourceMatchTermination termination = new("user", "agent");
|
||||||
|
termination.IsTerminated.Should().BeFalse();
|
||||||
|
|
||||||
|
TextMessage userMessage = new() { Content = "Hello", Source = "user" };
|
||||||
|
TextMessage agentMessage = new() { Content = "World", Source = "agent" };
|
||||||
|
TextMessage otherMessage = new() { Content = "Hi", Source = "other" };
|
||||||
|
|
||||||
|
await termination.InvokeExpectingNullAsync([]);
|
||||||
|
await termination.InvokeExpectingStopAsync([userMessage]);
|
||||||
|
await termination.InvokeExpectingStopAsync([agentMessage]);
|
||||||
|
await termination.InvokeExpectingNullAsync([otherMessage]);
|
||||||
|
|
||||||
|
await termination.InvokeExpectingFailureAsync([], reset: false);
|
||||||
|
|
||||||
|
termination.Reset();
|
||||||
|
termination.IsTerminated.Should().BeFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue