Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improving doc comments #5550

Merged
merged 9 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/dotnet/core/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,29 @@ Or, add via `<PackageReference>`
<PackageReference Include="Microsoft.AutoGen.Contracts" Version="0.4.0-dev.1" />
<PackageReference Include="Microsoft.AutoGen.Core" Version="0.4.0-dev.1" />
```

# Additional Packages

The *Core* and *Contracts* packages will give you what you need for writing and running agents using the Core API within a single process.

- *Microsoft.AutoGen.AgentChat* - An implementation of the AgentChat package for building chat-centric agent orchestration on top of the Core SDK
- *Microsoft.AutoGen.Agents* - a package that has a small number of default agents you can use.
- *Microsoft.AutoGen.Extensions* - Extensions to support closely related projects including Aspire, Microsoft.Extensions.AI, and Semantic Kernel

```sh
dotnet add package Microsoft.AutoGen.AgentChat --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.Agents --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.Extensions --version 0.4.0-dev-1
```

To enable running a system with agents in different processes that allows for x-language communication between python and .NET agents, there are additional packages:

- *Microsoft.AutoGen.Core.Grpc* - the .NET client runtime for agents in a distributed system. It has the same API as *Microsoft.AutoGen.Core*.
- *Microsoft.AutoGen.RuntimeGatewway.Grpc* - the .NET server side of the distributed system that allows you to run multiple gateways to manage fleets of agents and enables x-language interoperability.
- *Microsoft.AutoGen.AgentHost* - A .NET Aspire project that hosts the Grpc Service

```sh
dotnet add package Microsoft.AutoGen.Core.Grpc --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.RuntimeGateway.Grpc --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.AgentHost --version 0.4.0-dev-1
```

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,45 @@

namespace Microsoft.AutoGen.RuntimeGateway.Grpc.Abstractions;

/// <summary>
/// Defines the gateway interface for handling RPC requests and subscriptions.
/// Note that all of the request types are generated from the proto file.
/// </summary>
public interface IGateway : IGrainObserver
{
/// <summary>
/// Invokes a request asynchronously.
/// </summary>
/// <param name="request">The RPC request.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the RPC response.</returns>
ValueTask<RpcResponse> InvokeRequestAsync(RpcRequest request);

/// <summary>
/// Registers an agent type asynchronously.
/// </summary>
/// <param name="request">The register agent type request.</param>
/// <param name="context">The server call context.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the register agent type response.</returns>
ValueTask<RegisterAgentTypeResponse> RegisterAgentTypeAsync(RegisterAgentTypeRequest request, ServerCallContext context);

/// <summary>
/// Subscribes to a topic asynchronously.
/// </summary>
/// <param name="request">The add subscription request.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the add subscription response.</returns>
ValueTask<AddSubscriptionResponse> SubscribeAsync(AddSubscriptionRequest request);

/// <summary>
/// Unsubscribes from a topic asynchronously.
/// </summary>
/// <param name="request">The remove subscription request.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the remove subscription response.</returns>
ValueTask<RemoveSubscriptionResponse> UnsubscribeAsync(RemoveSubscriptionRequest request);

/// <summary>
/// Gets the subscriptions asynchronously.
/// </summary>
/// <param name="request">The get subscriptions request.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the list of subscriptions.</returns>
ValueTask<List<Subscription>> GetSubscriptionsAsync(GetSubscriptionsRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Microsoft.AutoGen.RuntimeGateway.Grpc.Abstractions;

/// <summary>
/// Interface for managing agent registration, placement, and subscriptions.
/// Keeps track of which agents are registered with which gateways.
/// </summary>
public interface IGatewayRegistry : IRegistry
{
Expand All @@ -27,6 +27,7 @@ public interface IGatewayRegistry : IRegistry
/// Registers a new agent type with the specified worker.
/// </summary>
/// <param name="request">The request containing agent type details.</param>
/// <param name="clientId">The client ID of the worker.</param>
/// <param name="worker">The worker to register the agent type with.</param>
/// <returns>A task representing the asynchronous operation.</returns>
ValueTask RegisterAgentTypeAsync(RegisterAgentTypeRequest request, string clientId, IGateway worker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Microsoft.AutoGen.RuntimeGateway.Grpc.Abstractions;

public interface IRegistry
{

/// <summary>
/// Gets a list of agents subscribed to and handling the specified topic and event type.
/// </summary>
Expand All @@ -20,19 +19,21 @@ public interface IRegistry
/// <param name="request">The subscription request.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <remarks>removing CancellationToken from here as it is not compatible with Orleans Serialization</remarks>
/// <remarks>removing CancellationToken from here as it is not compatible with Orleans Serialization</remarks>
ValueTask SubscribeAsync(AddSubscriptionRequest request);

/// <summary>
/// Unsubscribes an agent from a topic.
/// </summary>
/// <param name="request">The unsubscription request.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <returns>A task representing the asynchronous operation.</retur/// <remarks>removing CancellationToken from here as it is not compatible with Orleans Serialization</remarks>
/// <remarks>removing CancellationToken from here as it is not compatible with Orleans Serialization</remarks>
ValueTask UnsubscribeAsync(RemoveSubscriptionRequest request); // TODO: This should have its own request type.
ValueTask UnsubscribeAsync(RemoveSubscriptionRequest request); // TODO: This should have its own request type.equest r // TODO: This should have its own request type.equest); // TODO: This should have its own request type.

/// <summary>
/// Gets the subscriptions for a specified agent type.
/// </summary>
/// <param name="request">The get subscriptions request.</param>
/// <returns>A task representing the asynchronous operation, with the subscriptions as the result.</returns>
ValueTask<List<Subscription>> GetSubscriptionsAsync(GetSubscriptionsRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using System.Threading.Channels;
using Grpc.Core;
using Microsoft.AutoGen.Protobuf;
using Microsoft.AutoGen.RuntimeGateway.Grpc.Abstractions;

namespace Microsoft.AutoGen.RuntimeGateway.Grpc;

public sealed class GrpcWorkerConnection : IAsyncDisposable, IConnection
public sealed class GrpcWorkerConnection : IAsyncDisposable
{
private static long s_nextConnectionId;
private Task _readTask = Task.CompletedTask;
Expand Down Expand Up @@ -57,6 +56,7 @@ public Task Connect()

private readonly Channel<Message> _outboundMessages;

/// <inheritdoc/>
public void AddSupportedType(string type)
{
lock (_lock)
Expand All @@ -65,6 +65,7 @@ public void AddSupportedType(string type)
}
}

/// <inheritdoc/>
public HashSet<string> GetSupportedTypes()
{
lock (_lock)
Expand All @@ -73,10 +74,13 @@ public HashSet<string> GetSupportedTypes()
}
}

/// <inheritdoc/>
public async Task SendMessage(Message message)
{
await _outboundMessages.Writer.WriteAsync(message).ConfigureAwait(false);
}

/// <inheritdoc/>
public async Task RunReadPump()
{
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
Expand All @@ -98,6 +102,7 @@ public async Task RunReadPump()
}
}

/// <inheritdoc/>
public async Task RunWritePump()
{
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
Expand All @@ -117,11 +122,13 @@ public async Task RunWritePump()
}
}

/// <inheritdoc/>
public async ValueTask DisposeAsync()
{
_shutdownCancellationToken.Cancel();
await Completion.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
}

/// <inheritdoc/>
public override string ToString() => $"Connection-{_connectionId}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public ValueTask<List<Subscription>> GetSubscriptionsAsync(GetSubscriptionsReque
}
return new(subscriptions);
}

private sealed class WorkerState
{
public HashSet<string> SupportedTypes { get; set; } = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public struct TypeSubscriptionSurrogate
public sealed class TypeSubscriptionSurrogateConverter :
IConverter<TypeSubscription, TypeSubscriptionSurrogate>
{
/// <summary>
/// Converts from the surrogate to the original type.
/// </summary>
/// <param name="surrogate">The surrogate to convert from.</param>
/// <returns>The original type.</returns>
public TypeSubscription ConvertFromSurrogate(
in TypeSubscriptionSurrogate surrogate) =>
new TypeSubscription
Expand All @@ -25,6 +30,11 @@ public TypeSubscription ConvertFromSurrogate(
AgentType = surrogate.AgentType
};

/// <summary>
/// Converts from the original type to the surrogate.
/// </summary>
/// <param name="value">The original type to convert from.</param>
/// <returns>The surrogate type.</returns>
public TypeSubscriptionSurrogate ConvertToSurrogate(
in TypeSubscription value) =>
new TypeSubscriptionSurrogate
Expand Down
Loading