Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kostapetan committed Nov 30, 2024
1 parent 3b8a659 commit 9b02bf8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
1 change: 0 additions & 1 deletion dotnet/src/Microsoft.AutoGen/Client/AgentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ public Task CallHandler(CloudEvent item, CancellationToken cancellationToken)
/// <returns>A task representing the asynchronous operation, containing the RPC response.</returns>
public Task<RpcResponse> HandleRequestAsync(RpcRequest request, CancellationToken cancellationToken = default) => Task.FromResult(new RpcResponse { Error = "Not implemented" });


/// <summary>
/// Handles an object asynchronously by invoking the appropriate handler method based on the object's type.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion dotnet/src/Microsoft.AutoGen/Client/IHandleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Microsoft.AutoGen.Core;


/// <summary>
/// Provides extension methods for types implementing the IHandle interface.
/// </summary>
Expand Down
22 changes: 6 additions & 16 deletions dotnet/test/Microsoft.AutoGen.Agents.Tests/AgentBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Concurrent;
using FluentAssertions;
using Google.Protobuf.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Core;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -63,7 +64,7 @@ await client.PublishMessageAsync(new TextMessage()
/// <summary>
/// The test agent is a simple agent that is used for testing purposes.
/// </summary>
public class TestAgent : AgentBase, IHandle<string>, IHandle<int>, IHandle<TextMessage>
public class TestAgent : AgentBase, IHandle<TextMessage>
{
public TestAgent(
RuntimeContext context,
Expand All @@ -72,19 +73,7 @@ public TestAgent(
{
}

public Task Handle(string item)
{
ReceivedItems.Add(item);
return Task.CompletedTask;
}

public Task Handle(int item)
{
ReceivedItems.Add(item);
return Task.CompletedTask;
}

public Task Handle(TextMessage item)
public Task Handle(TextMessage item, CancellationToken cancellationToken = default)
{
ReceivedMessages[item.Source] = item.TextMessage_;
return Task.CompletedTask;
Expand All @@ -104,13 +93,14 @@ public sealed class InMemoryAgentRuntimeFixture : IDisposable
{
public InMemoryAgentRuntimeFixture()
{
var builder = Host.CreateApplicationBuilder();
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { });

// step 1: create in-memory agent runtime
// step 2: register TestAgent to that agent runtime
builder
//.AddAgentService(local: true, useGrpc: false)
.AddAgentWorker(local: true)
.AddInMemoryWorker()
.AddAgentHost()
.AddAgent<TestAgent>(nameof(TestAgent));

AppHost = builder.Build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsTestProject>True</IsTestProject>
Expand All @@ -12,6 +12,7 @@
<ProjectReference Include="..\..\src\Microsoft.AutoGen\Core\Microsoft.AutoGen.Contracts.csproj" />
<ProjectReference Include="..\Microsoft.Autogen.Tests.Shared\Microsoft.Autogen.Tests.Shared.csproj" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>

0 comments on commit 9b02bf8

Please sign in to comment.