mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-23 17:01:35 +00:00

* moves AgentId into Agent * Renames AgentRuntime to AgentMessenger (more accurate name) * Remove IAgentRuntime Interface * changes constructor of Agent to take IAgentWorker instead of IAgentRuntime
64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// ProductManager.cs
|
|
|
|
using DevTeam.Shared;
|
|
using Microsoft.AutoGen.Agents;
|
|
using Microsoft.AutoGen.Contracts;
|
|
using Microsoft.AutoGen.Core;
|
|
using Microsoft.SemanticKernel;
|
|
using Microsoft.SemanticKernel.Memory;
|
|
|
|
namespace DevTeam.Agents;
|
|
|
|
[TopicSubscription("devteam")]
|
|
public class ProductManager(IAgentWorker worker, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<ProductManager> logger)
|
|
: SKAiAgent<ProductManagerState>(worker, memory, kernel, typeRegistry), IManageProducts,
|
|
IHandle<ReadmeChainClosed>,
|
|
IHandle<ReadmeRequested>
|
|
{
|
|
public async Task Handle(ReadmeChainClosed item)
|
|
{
|
|
// TODO: Get readme from state
|
|
var lastReadme = ""; // _state.State.History.Last().Message
|
|
var evt = new ReadmeCreated
|
|
{
|
|
Readme = lastReadme
|
|
};
|
|
await PublishMessageAsync(evt);
|
|
}
|
|
|
|
public async Task Handle(ReadmeRequested item)
|
|
{
|
|
var readme = await CreateReadme(item.Ask);
|
|
var evt = new ReadmeGenerated
|
|
{
|
|
Readme = readme,
|
|
Org = item.Org,
|
|
Repo = item.Repo,
|
|
IssueNumber = item.IssueNumber
|
|
};
|
|
await PublishMessageAsync(evt);
|
|
}
|
|
|
|
public async Task<string> CreateReadme(string ask)
|
|
{
|
|
try
|
|
{
|
|
var context = new KernelArguments { ["input"] = AppendChatHistory(ask) };
|
|
var instruction = "Consider the following architectural guidelines:!waf!";
|
|
var enhancedContext = await AddKnowledge(instruction, "waf", context);
|
|
return await CallFunction(PMSkills.Readme, enhancedContext);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "Error creating readme");
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public interface IManageProducts
|
|
{
|
|
public Task<string> CreateReadme(string ask);
|
|
}
|