Skip to content

A programming framework for agentic AI

add json_mode to DevLead, simplify AzureGenie (#71)

Kosta Petan9d5830032d66
diff --git a/README.md b/README.md
index e925413eb..a6f49299b 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ At the moment the library resides in `src/` only, but we plan to publish them as
We have created a few examples to help you get started with the framework and to explore its capabilities.
- [GitHub Dev Team Sample](samples/gh-flow/README.md): Build an AI Developer Team using event-driven agents, that help you automate the requirements engineering, planning, and coding process on GitHub.
+- [Marketing Team Sample](samples/marketing/README.md): Create a marketing campaign using a content writer, graphic designer and social media manager.
## Contributing
diff --git a/readme.md b/readme.md
deleted file mode 100644
index e925413eb..000000000
--- a/readme.md
+++ /dev/null
@@ -1,44 +0,0 @@
-> ⚠️ This project is still an experimentation phase and is not intended to be used in production yet.
-
-# AI Agents Framework
-
-An opinionated .NET framework, that is built on top of Semantic Kernel and Orleans, which helps creating and hosting event-driven AI Agents.
-
-At the moment the library resides in `src/` only, but we plan to publish them as a Nuget Package in the future.
-
-## Examples
-
-We have created a few examples to help you get started with the framework and to explore its capabilities.
-
-- [GitHub Dev Team Sample](samples/gh-flow/README.md): Build an AI Developer Team using event-driven agents, that help you automate the requirements engineering, planning, and coding process on GitHub.
-
-## Contributing
-
-This project welcomes contributions and suggestions. Most contributions require you to agree to a
-Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
-the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
-
-When you submit a pull request, a CLA bot will automatically determine whether you need to provide
-a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
-provided by the bot. You will only need to do this once across all repos using our CLA.
-
-This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
-For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
-contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
-
-## Legal Notices
-
-Microsoft and any contributors grant you a license to the Microsoft documentation and other content
-in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode),
-see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the
-[LICENSE-CODE](LICENSE-CODE) file.
-
-Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation
-may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries.
-The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
-Microsoft's general trademark guidelines can be found at <http://go.microsoft.com/fwlink/?LinkID=254653>.
-
-Privacy information can be found at <https://privacy.microsoft.com/en-us/>
-
-Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents,
-or trademarks, whether by implication, estoppel or otherwise.
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/AzureGenie.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/AzureGenie.cs
index 0730e8ac9..76940f251 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/AzureGenie.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/AzureGenie.cs
@@ -2,7 +2,6 @@
using Microsoft.AI.Agents.Orleans;
using Microsoft.AI.DevTeam.Events;
using Microsoft.AI.DevTeam.Extensions;
-using System.Globalization;
namespace Microsoft.AI.DevTeam;
@@ -24,44 +23,36 @@ public class AzureGenie : Agent
throw new ArgumentNullException(nameof(item));
}
- var data = item.Data ?? throw new ArgumentNullException(nameof(item));
- var parentNumber = data.TryParseLong("parentNumber");
- var issueNumber = data.TryParseLong("issueNumber");
- var org = data["org"].ToString();
- var repo = data["repo"].ToString();
- var subject = $"{org}/{repo}/{issueNumber}";
-
switch (item.Type)
{
case nameof(GithubFlowEventType.ReadmeCreated):
- await Store(org, repo, parentNumber, issueNumber, "readme", "md", "output", data["readme"].ToString());
+ {
+ var context = item.ToGithubContext();
+ await Store(context.Org,context.Repo, context.ParentNumber.Value, context.IssueNumber, "readme", "md", "output", item.Data["readme"]);
await PublishEvent(Consts.MainNamespace, this.GetPrimaryKeyString(), new Event
{
Type = nameof(GithubFlowEventType.ReadmeStored),
- Subject = subject,
- Data = new Dictionary<string, string> {
- { "org", org },
- { "repo", repo },
- { "issueNumber", $"{issueNumber}" },
- { "parentNumber", $"{parentNumber}" }
- }
+ Subject = context.Subject,
+ Data = context.ToData()
});
- break;
+ break;
+ }
+
+
case nameof(GithubFlowEventType.CodeCreated):
- await Store(org, repo, parentNumber, issueNumber, "run", "sh", "output", data["code"].ToString());
- await RunInSandbox(org, repo, parentNumber, issueNumber);
+ {
+ var context = item.ToGithubContext();
+ await Store(context.Org,context.Repo, context.ParentNumber.Value, context.IssueNumber, "run", "sh", "output", item.Data["code"]);
+ await RunInSandbox(context.Org,context.Repo, context.ParentNumber.Value, context.IssueNumber);
await PublishEvent(Consts.MainNamespace, this.GetPrimaryKeyString(), new Event
{
Type = nameof(GithubFlowEventType.SandboxRunCreated),
- Subject = subject,
- Data = new Dictionary<string, string> {
- { "org", org },
- { "repo", repo },
- { "issueNumber", $"{issueNumber}" },
- { "parentNumber", $"{parentNumber}" }
- }
+ Subject = context.Subject,
+ Data = context.ToData()
});
- break;
+ break;
+ }
+
default:
break;
}
diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/DeveloperLead/DeveloperLead.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/DeveloperLead/DeveloperLead.cs
index 81fac1354..bb87db69c 100644
--- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/DeveloperLead/DeveloperLead.cs
+++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Agents/DeveloperLead/DeveloperLead.cs
@@ -2,6 +2,7 @@ using Microsoft.AI.Agents.Abstractions;
using Microsoft.AI.Agents.Orleans;
using Microsoft.AI.DevTeam.Events;
using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
using Orleans.Runtime;
@@ -65,7 +66,13 @@ public class DeveloperLead : AiAgent<DeveloperLeadState>, ILeadDevelopers
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(DevLeadSkills.Plan, enhancedContext);
+ var settings = new OpenAIPromptExecutionSettings{
+ ResponseFormat = "json_object",
+ MaxTokens = 4096,
+ Temperature = 0.8,
+ TopP = 1
+ };
+ return await CallFunction(DevLeadSkills.Plan, enhancedContext, settings);
}
catch (Exception ex)
{
diff --git a/src/Microsoft.AI.Agents.Orleans/AiAgent.cs b/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
index eaef38a7b..6d7294c60 100644
--- a/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
+++ b/src/Microsoft.AI.Agents.Orleans/AiAgent.cs
@@ -45,7 +45,8 @@ public abstract class AiAgent<T> : Agent, IAiAgent where T : class, new()
public virtual async Task<string> CallFunction(string template, KernelArguments arguments, OpenAIPromptExecutionSettings? settings = null)
{
- var propmptSettings = settings ?? new OpenAIPromptExecutionSettings { MaxTokens = 18000, Temperature = 0.8, TopP = 1 };
+ // TODO: extract this to be configurable
+ var propmptSettings = settings ?? new OpenAIPromptExecutionSettings { MaxTokens = 4096, Temperature = 0.8, TopP = 1 };
var function = _kernel.CreateFunctionFromPrompt(template, propmptSettings);
var result = (await _kernel.InvokeAsync(function, arguments)).ToString();
AddToHistory(result, ChatUserType.Agent);