Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into stream_token_0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jspv authored Dec 4, 2024
2 parents 8b9295e + e1d5833 commit c20298d
Show file tree
Hide file tree
Showing 248 changed files with 3,926 additions and 1,479 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
filters: |
dotnet:
- "dotnet/**"
- "protos/**"
workflows:
- ".github/workflows/**"
- name: dotnet has changes
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/dotnet-publish-nuget.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/dotnet-publish-packages.yml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<div align="center">
<img src="https://microsoft.github.io/autogen/0.2/img/ag.svg" alt="AutoGen Logo" width="100">

[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen) [![GitHub Discussions](https://img.shields.io/badge/Discussions-Q%26A-green?logo=github)](https://github.com/microsoft/autogen/discussions) [![0.2 Docs](https://img.shields.io/badge/Docs-0.2-blue)](https://microsoft.github.io/autogen/0.2/) [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Company?style=flat&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/105812540)
[![GitHub Discussions](https://img.shields.io/badge/Discussions-Q%26A-green?logo=github)](https://github.com/microsoft/autogen/discussions) [![0.2 Docs](https://img.shields.io/badge/Docs-0.2-blue)](https://microsoft.github.io/autogen/0.2/) [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/)
[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev8/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev8/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev8/)

</div>
Expand Down Expand Up @@ -115,7 +116,8 @@ To use Azure OpenAI models, follow the instruction
```python
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.task import Console, TextMentionTermination
from autogen_agentchat.ui import Console
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient

Expand Down Expand Up @@ -181,7 +183,7 @@ var app = await App.PublishMessageAsync("HelloAgents", new NewMessageReceived
await App.RuntimeApp!.WaitForShutdownAsync();
await app.WaitForShutdownAsync();

[TopicSubscription("HelloAgents")]
[TopicSubscription("agents")]
public class HelloAgent(
IAgentContext context,
[FromKeyedServices("EventTypes")] EventTypes typeRegistry) : ConsoleAgent(
Expand Down
6 changes: 4 additions & 2 deletions docs/design/02 - Topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ A topic is identified by two components (called a `TopicId`):

- [`type`](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#type) - represents the type of event that occurs, this is static and defined in code
- SHOULD use reverse domain name notation to avoid naming conflicts. For example: `com.example.my-topic`.
- Allowed values MUST match the regex: `^[\w\-\.\:\=]+\Z`
- Notably, this is the same as agent type with the addition of `=` and `:` characters
- [`source`](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#source-1) - represents where the event originated from, this is dynamic and based on the message itself
- SHOULD be a URI

Agent instances are identified by two components (called an `AgentId`):

- `type` - represents the type of agent, this is static and defined in code
- MUST be a valid identifier as defined [here](https://docs.python.org/3/reference/lexical_analysis.html#identifiers) except that only the ASCII range is allowed
- Allowed values MUST match the regex: `^[\w\-\.]+\Z`
- `key` - represents the instance of the agent type for the key
- SHOULD be a URI

Expand Down Expand Up @@ -61,6 +63,6 @@ For this subscription source should map directly to agent key.
This subscription will therefore receive all events for the following well known topics:

- `{AgentType}:` - General purpose direct messages. These should be routed to the approriate message handler.
- `{AgentType}:rpc_request` - RPC request messages. These should be routed to the approriate RPC handler.
- `{AgentType}:rpc_request={RequesterAgentType}` - RPC request messages. These should be routed to the approriate RPC handler, and RequesterAgentType used to publish the response
- `{AgentType}:rpc_response={RequestId}` - RPC response messages. These should be routed back to the response future of the caller.
- `{AgentType}:error={RequestId}` - Error message that corresponds to the given request.
63 changes: 35 additions & 28 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
<MicrosoftSemanticKernelVersion>1.22.0</MicrosoftSemanticKernelVersion>
<MicrosoftSemanticKernelExperimentalVersion>1.22.0-alpha</MicrosoftSemanticKernelExperimentalVersion>
<MicrosoftExtensionsAIVersion>9.0.0-preview.9.24525.1</MicrosoftExtensionsAIVersion>
<MicrosoftExtensionConfiguration>9.0.0</MicrosoftExtensionConfiguration>
<MicrosoftExtensionDependencyInjection>9.0.0</MicrosoftExtensionDependencyInjection>
<MicrosoftExtensionLogging>9.0.0</MicrosoftExtensionLogging>
<MicrosoftOrleans>9.0.1</MicrosoftOrleans>
<OpenTelemetryInstrumentation>1.9.0</OpenTelemetryInstrumentation>
<MicrosoftDotNetInteractive>1.0.0-beta.24229.4</MicrosoftDotNetInteractive>
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Hosting" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.Python" Version="9.0.0" />
<PackageVersion Include="AspNetCore.Authentication.ApiKey" Version="8.0.1" />
<PackageVersion Include="Aspire.Azure.AI.OpenAI" Version="8.0.1-preview.8.24267.1" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
Expand Down Expand Up @@ -41,33 +48,33 @@
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="$(MicrosoftExtensionsAIVersion)" />
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.8.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftExtensionConfiguration)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionConfiguration)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionConfiguration)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(MicrosoftExtensionConfiguration)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionDependencyInjection)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionDependencyInjection)" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionLogging)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionLogging)" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
<PackageVersion Include="Microsoft.Orleans.Clustering.Cosmos" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.CodeGenerator" Version="9.0.1">
<PackageVersion Include="Microsoft.Orleans.Clustering.Cosmos" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.CodeGenerator" Version="$(MicrosoftOrleans)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.Orleans.Core.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Persistence.Cosmos" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Reminders" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Reminders.Cosmos" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Runtime" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Serialization" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Serialization.Protobuf" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Streaming" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Streaming.EventHubs" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Core.Abstractions" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Persistence.Cosmos" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Reminders" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Reminders.Cosmos" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Runtime" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Serialization" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Serialization.Protobuf" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Streaming" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.Orleans.Streaming.EventHubs" Version="$(MicrosoftOrleans)" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.29.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Agents.Core" Version="$(MicrosoftSemanticKernelExperimentalVersion)" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.AzureOpenAI" Version="1.29.0" />
Expand All @@ -79,9 +86,9 @@
<PackageVersion Include="Octokit.Webhooks.AspNetCore" Version="2.4.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="$(OpenTelemetryInstrumentation)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="$(OpenTelemetryInstrumentation)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="$(OpenTelemetryInstrumentation)" />
<PackageVersion Include="OrleansDashboard" Version="8.2.0" />
<PackageVersion Include="PdfPig" Version="0.1.10-alpha-20241121-7db34" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.1.0" />
Expand All @@ -92,9 +99,9 @@
<PackageVersion Include="System.IO.Packaging" Version="9.0.0" />
<PackageVersion Include="System.Memory.Data" Version="9.0.0" />
<PackageVersion Include="JsonSchema.Net.Generation" Version="4.5.1" />
<PackageVersion Include="Microsoft.DotNet.Interactive" Version="1.0.0-beta.24229.4" />
<PackageVersion Include="Microsoft.DotNet.Interactive.Jupyter" Version="1.0.0-beta.24229.4" />
<PackageVersion Include="Microsoft.DotNet.Interactive.PackageManagement" Version="1.0.0-beta.24229.4" />
<PackageVersion Include="Microsoft.DotNet.Interactive" Version="$(MicrosoftDotNetInteractive)" />
<PackageVersion Include="Microsoft.DotNet.Interactive.Jupyter" Version="$(MicrosoftDotNetInteractive)" />
<PackageVersion Include="Microsoft.DotNet.Interactive.PackageManagement" Version="$(MicrosoftDotNetInteractive)" />
<PackageVersion Include="Google.Cloud.AIPlatform.V1" Version="3.11.0" />
<PackageVersion Include="OpenAI" Version="2.1.0-beta.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
Expand All @@ -112,4 +119,4 @@
<PackageVersion Include="Microsoft.PowerShell.SDK" Version="7.4.5" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.11" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions dotnet/samples/Hello/Hello.AppHost/Hello.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting" />
<PackageReference Include="Aspire.Hosting.Python" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 13 additions & 5 deletions dotnet/samples/Hello/Hello.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@

var builder = DistributedApplication.CreateBuilder(args);
var backend = builder.AddProject<Projects.Backend>("backend").WithExternalHttpEndpoints();
builder.AddProject<Projects.HelloAgent>("client")
var client = builder.AddProject<Projects.HelloAgent>("HelloAgentsDotNET")
.WithReference(backend)
.WithEnvironment("AGENT_HOST", $"{backend.GetEndpoint("https").Property(EndpointProperty.Url)}")
.WithEnvironment("AGENT_HOST", backend.GetEndpoint("https"))
.WithEnvironment("STAY_ALIVE_ON_GOODBYE", "true")
.WaitFor(backend);

#pragma warning disable ASPIREHOSTINGPYTHON001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// xlang is over http for now - in prod use TLS between containers
builder.AddPythonApp("HelloAgentsPython", "../../../../python/packages/autogen-core/samples/xlang/hello_python_agent", "hello_python_agent.py", "../../../../../.venv")
.WithReference(backend)
.WithEnvironment("AGENT_HOST", backend.GetEndpoint("http"))
.WithEnvironment("STAY_ALIVE_ON_GOODBYE", "true")
.WithEnvironment("GRPC_DNS_RESOLVER", "native")
.WithOtlpExporter()
.WaitFor(client);
#pragma warning restore ASPIREHOSTINGPYTHON001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
using var app = builder.Build();

await app.StartAsync();
var url = backend.GetEndpoint("http").Url;
Console.WriteLine("Backend URL: " + url);

await app.WaitForShutdownAsync();
2 changes: 1 addition & 1 deletion dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Extensions.AI;

namespace Hello;
[TopicSubscription("HelloAgents")]
[TopicSubscription("agents")]
public class HelloAIAgent(
IAgentRuntime context,
[FromKeyedServices("EventTypes")] EventTypes typeRegistry,
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/Hello/HelloAIAgents/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace Hello
{
[TopicSubscription("HelloAgents")]
[TopicSubscription("agents")]
public class HelloAgent(
IAgentRuntime context,
[FromKeyedServices("EventTypes")] EventTypes typeRegistry,
Expand Down
21 changes: 8 additions & 13 deletions dotnet/samples/Hello/HelloAgent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

// step 1: create in-memory agent runtime

// step 2: register HelloAgent to that agent runtime

// step 3: start the agent runtime

// step 4: send a message to the agent

// step 5: wait for the agent runtime to shutdown
var local = true;
if (Environment.GetEnvironmentVariable("AGENT_HOST") != null) { local = false; }
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
{
Message = "World"
}, local: true);
//var app = await AgentsApp.StartAsync();
}, local: local).ConfigureAwait(false);
await app.WaitForShutdownAsync();

namespace Hello
{
[TopicSubscription("HelloAgents")]
[TopicSubscription("agents")]
public class HelloAgent(
IAgentRuntime context, IHostApplicationLifetime hostApplicationLifetime,
[FromKeyedServices("EventTypes")] EventTypes typeRegistry) : AgentBase(
Expand Down Expand Up @@ -53,7 +45,10 @@ public async Task Handle(ConversationClosed item)
var goodbye = $"********************* {item.UserId} said {item.UserMessage} ************************";
var evt = new Output { Message = goodbye };
await PublishMessageAsync(evt).ConfigureAwait(true);
await PublishMessageAsync(new Shutdown()).ConfigureAwait(false);
if (Environment.GetEnvironmentVariable("STAY_ALIVE_ON_GOODBYE") != "true")
{
await PublishMessageAsync(new Shutdown()).ConfigureAwait(false);
}
}

public async Task Handle(Shutdown item)
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/Hello/HelloAgentState/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Hello
{
[TopicSubscription("HelloAgents")]
[TopicSubscription("agents")]
public class HelloAgent(
IAgentRuntime context,
IHostApplicationLifetime hostApplicationLifetime,
Expand Down
43 changes: 43 additions & 0 deletions dotnet/samples/Hello/protos/agent_events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";

package HelloAgents;

option csharp_namespace = "Microsoft.AutoGen.Abstractions";
message TextMessage {
string textMessage = 1;
string source = 2;
}
message Input {
string message = 1;
}
message InputProcessed {
string route = 1;
}
message Output {
string message = 1;
}
message OutputWritten {
string route = 1;
}
message IOError {
string message = 1;
}
message NewMessageReceived {
string message = 1;
}
message ResponseGenerated {
string response = 1;
}
message GoodBye {
string message = 1;
}
message MessageStored {
string message = 1;
}
message ConversationClosed {
string user_id = 1;
string user_message = 2;
}
message Shutdown {
string message = 1;
}
Loading

0 comments on commit c20298d

Please sign in to comment.