Jack Gerrits da759b6aed
Dotnet - core framework rework (rebased) (#511)
* dotnet rework

* add dotnet workload update to startup

* fix build

* interim fixup

* this is the stuff that was missing

* renaming the .net classes

* more build fixup

* port dev-team sample WIP

* add proto messages and IHandle to agents

* add github variables

* remove OAgents gh-flow

* remove OAgents library

* add .vs to gitignore

---------

Co-authored-by: Kosta Petan <kostapetan@gmail.com>
Co-authored-by: Ryan Sweet <rysweet@microsoft.com>
2024-09-17 13:01:49 +00:00

55 lines
1.8 KiB
C#

using DevTeam.Shared;
using Microsoft.AI.Agents.Abstractions;
using Microsoft.AI.Agents.Worker.Client;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Memory;
namespace DevTeam.Agents;
[TopicSubscription("devteam")]
public class ProductManager(IAgentContext context, Kernel kernel, ISemanticTextMemory memory, [FromKeyedServices("EventTypes")] EventTypes typeRegistry, ILogger<ProductManager> logger)
: AiAgent<ProductManagerState>(context, 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
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt);
}
public async Task Handle(ReadmeRequested item)
{
var readme = await CreateReadme(item.Ask);
var evt = new ReadmeGenerated
{
Readme = readme
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(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);
}