Ryan Sweet 458d273fc4
Refactoring the services and implementing an in-memory runtime for .NET (#4005)
closes #3950 closes #3702

What this is doing:

I am refactoring the services on the .NET runtime and attempting to clarify the naming and organization.
I added this doc to help capture the naming and concepts.
AgentRuntime / Worker should work similar to the python version and enables running the whole agent system in one process. For remote the system uses the versions of the services in the grpc folder.
lots of other bug fixes/threading cleanup - passing cancellation token throughout
Services update clarifies the naming and roles:

Worker: Hosts the Agents and is a client to the Gateway
Gateway:
-- RPC gateway for the other services APIs
-- Provides an RPC bridge between the workers and the Event Bus
Registry: keeps track of the agents in the system and which events they can handle
AgentState: persistent state for agents
2024-11-12 11:04:59 -08:00

58 lines
2.6 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved.
// AzureGenie.cs
using DevTeam.Backend;
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Memory;
namespace Microsoft.AI.DevTeam;
public class AzureGenie(IAgentRuntime context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, IManageAzure azureService)
: SKAiAgent<object>(context, memory, kernel, typeRegistry),
IHandle<ReadmeCreated>,
IHandle<CodeCreated>
{
public async Task Handle(ReadmeCreated item)
{
// TODO: Not sure we need to store the files if we use ACA Sessions
// //var data = item.ToData();
// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "readme", "md", "output", data["readme"]);
// await PublishEventAsync(new Event
// {
// Namespace = item.Namespace,
// Type = nameof(EventTypes.ReadmeStored),
// Data = item.Data
// });
// break;
await Task.CompletedTask;
}
public async Task Handle(CodeCreated item)
{
// TODO: Not sure we need to store the files if we use ACA Sessions
// //var data = item.ToData();
// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "run", "sh", "output", data["code"]);
// // await RunInSandbox(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"));
// await PublishEventAsync(new Event
// {
// Namespace = item.Namespace,
// Type = nameof(EventTypes.SandboxRunCreated),
// Data = item.Data
// });
// break;
await Task.CompletedTask;
}
public async Task Store(string org, string repo, long parentIssueNumber, long issueNumber, string filename, string extension, string dir, string output)
{
await azureService.Store(org, repo, parentIssueNumber, issueNumber, filename, extension, dir, output);
}
public async Task RunInSandbox(string org, string repo, long parentIssueNumber, long issueNumber)
{
await azureService.RunInSandbox(org, repo, parentIssueNumber, issueNumber);
}
}