mirror of
https://github.com/microsoft/autogen.git
synced 2025-12-27 15:09:41 +00:00
update compiles
This commit is contained in:
parent
b2a5c9a447
commit
d18296f800
@ -154,10 +154,8 @@ class Program
|
||||
{
|
||||
wafContext += $"\n {memory.Metadata.Text}";
|
||||
}
|
||||
var skillConfig = SemanticFunctionConfig.ForSkillAndFunction(skillName, functionName);
|
||||
var function = kernel.CreateSemanticFunction(skillConfig.PromptTemplate, skillConfig.Name, skillConfig.SkillName,
|
||||
skillConfig.Description, skillConfig.MaxTokens, skillConfig.Temperature,
|
||||
skillConfig.TopP, skillConfig.PPenalty, skillConfig.FPenalty);
|
||||
var promptTemplate = Skills.ForSkillAndFunction(skillName, functionName);
|
||||
var function = kernel.CreateSemanticFunction(promptTemplate);
|
||||
|
||||
var context = new ContextVariables();
|
||||
context.Set("input", input);
|
||||
|
||||
@ -97,8 +97,8 @@ public class SKWebHookEventProcessor : WebhookEventProcessor
|
||||
|
||||
private async Task<string> RunSkill(string skillName, string functionName, string input)
|
||||
{
|
||||
var prompt = ForSkillAndFunction(skillName, functionName);
|
||||
var function = _kernel.CreateSemanticFunction(prompt, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
var prompt = Skills.ForSkillAndFunction(skillName, functionName);
|
||||
var function = _kernel.CreateSemanticFunction(prompt, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });
|
||||
|
||||
var interestingMemories = _kernel.Memory.SearchAsync("waf-pages", input, 2);
|
||||
var wafContext = "Consider the following architectural guidelines:";
|
||||
@ -114,15 +114,4 @@ public class SKWebHookEventProcessor : WebhookEventProcessor
|
||||
var result = await _kernel.RunAsync(context, function);
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static string ForSkillAndFunction(string skillName, string functionName) =>
|
||||
(skillName, functionName) switch
|
||||
{
|
||||
(nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,
|
||||
(nameof(PM), nameof(PM.Readme)) => PM.Readme,
|
||||
(nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan,
|
||||
(nameof(Developer), nameof(Developer.Implement)) => Developer.Implement,
|
||||
(nameof(Developer), nameof(Developer.Improve)) => Developer.Improve,
|
||||
_ => throw new ArgumentException($"Unable to find {skillName}.{functionName}")
|
||||
};
|
||||
}
|
||||
@ -8,8 +8,10 @@ using Elsa.Extensions;
|
||||
using Elsa.Workflows.Core;
|
||||
using Elsa.Workflows.Core.Contracts;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Microsoft.AI.DevTeam.Skills;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.Connectors.AI.OpenAI;
|
||||
using Microsoft.SemanticKernel.Orchestration;
|
||||
|
||||
namespace Elsa.SemanticKernel;
|
||||
@ -164,19 +166,11 @@ public class SemanticKernelActivityProvider : IActivityProvider
|
||||
string field = function.FieldType.ToString();
|
||||
if (field.Equals("Microsoft.SKDevTeam.SemanticFunctionConfig"))
|
||||
{
|
||||
var skillConfig = SemanticFunctionConfig.ForSkillAndFunction(skillType.Name, function.Name);
|
||||
var promptTemplate = Skills.ForSkillAndFunction(skillType.Name, function.Name);
|
||||
var skfunc = kernel.CreateSemanticFunction(
|
||||
skillConfig.PromptTemplate,
|
||||
skillConfig.Name,
|
||||
skillConfig.SkillName,
|
||||
skillConfig.Description,
|
||||
skillConfig.MaxTokens,
|
||||
skillConfig.Temperature,
|
||||
skillConfig.TopP,
|
||||
skillConfig.PPenalty,
|
||||
skillConfig.FPenalty);
|
||||
promptTemplate, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });
|
||||
|
||||
Console.WriteLine($"SKActivityProvider Added SK function: {skfunc.SkillName}.{skfunc.Name}");
|
||||
Console.WriteLine($"SKActivityProvider Added SK function: {skfunc.PluginName}.{skfunc.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,9 +86,9 @@ public class SemanticKernelSkill : CodeActivity<string>
|
||||
var kernel = KernelBuilder();
|
||||
|
||||
// load the skill
|
||||
var promptTemplate = ForSkillAndFunction(skillName, functionName);
|
||||
var promptTemplate = Skills.ForSkillAndFunction(skillName, functionName);
|
||||
|
||||
var function = kernel.CreateSemanticFunction(promptTemplate, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
var function = kernel.CreateSemanticFunction(promptTemplate, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });
|
||||
|
||||
// set the context (our prompt)
|
||||
var contextVars = new ContextVariables();
|
||||
@ -151,17 +151,6 @@ public class SemanticKernelSkill : CodeActivity<string>
|
||||
return list.ToString();
|
||||
}
|
||||
|
||||
private static string ForSkillAndFunction(string skillName, string functionName) =>
|
||||
(skillName, functionName) switch
|
||||
{
|
||||
(nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,
|
||||
(nameof(PM), nameof(PM.Readme)) => PM.Readme,
|
||||
(nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan,
|
||||
(nameof(Developer), nameof(Developer.Implement)) => Developer.Implement,
|
||||
(nameof(Developer), nameof(Developer.Improve)) => Developer.Improve,
|
||||
_ => throw new ArgumentException($"Unable to find {skillName}.{functionName}")
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets a semantic kernel instance
|
||||
/// </summary>
|
||||
@ -209,9 +198,9 @@ public class SemanticKernelSkill : CodeActivity<string>
|
||||
string field = function.FieldType.ToString();
|
||||
if (field.Equals("Microsoft.SKDevTeam.SemanticFunctionConfig"))
|
||||
{
|
||||
var prompt = ForSkillAndFunction(skillType.Name, function.Name);
|
||||
var prompt = Skills.ForSkillAndFunction(skillType.Name, function.Name);
|
||||
var skfunc = kernel.CreateSemanticFunction(
|
||||
prompt, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
prompt, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });
|
||||
|
||||
Console.WriteLine($"SK Added function: {skfunc.SkillName}.{skfunc.Name}");
|
||||
}
|
||||
|
||||
24
src/libs/Microsoft.AI.DevTeam.Skills/Extensions.cs
Normal file
24
src/libs/Microsoft.AI.DevTeam.Skills/Extensions.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace Microsoft.AI.DevTeam.Skills;
|
||||
|
||||
public static class Skills
|
||||
{
|
||||
public static string ForSkillAndFunction(string skillName, string functionName) =>
|
||||
(skillName, functionName) switch
|
||||
{
|
||||
(nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,
|
||||
(nameof(PM), nameof(PM.Readme)) => PM.Readme,
|
||||
(nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan,
|
||||
(nameof(Developer), nameof(Developer.Implement)) => Developer.Implement,
|
||||
(nameof(Developer), nameof(Developer.Improve)) => Developer.Improve,
|
||||
_ => throw new ArgumentException($"Unable to find {skillName}.{functionName}")
|
||||
};
|
||||
}
|
||||
|
||||
public interface IFunction
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
string PluginName { get; }
|
||||
string DefaultValue { get; }
|
||||
string[] Parameters { get; }
|
||||
}
|
||||
@ -23,7 +23,7 @@ public class DeveloperLead : SemanticPersona, ILeadDevelopment
|
||||
// var review = architect.ReviewPlan(plan);
|
||||
// return Task.FromResult(plan);
|
||||
|
||||
var function = _kernel.CreateSemanticFunction(DevLead.Plan, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
var function = _kernel.CreateSemanticFunction(DevLead.Plan, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.4, TopP = 1 });
|
||||
var context = new ContextVariables();
|
||||
context.Set("input", ask);
|
||||
if (_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();
|
||||
|
||||
@ -18,7 +18,7 @@ public class Dev : SemanticPersona, IDevelopCode
|
||||
|
||||
public async Task<string> GenerateCode(string ask)
|
||||
{
|
||||
var function = _kernel.CreateSemanticFunction(Developer.Implement, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
var function = _kernel.CreateSemanticFunction(Developer.Implement, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.8, TopP = 1 });
|
||||
var context = new ContextVariables();
|
||||
if (_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();
|
||||
_state.State.History.Add(new ChatHistoryItem
|
||||
|
||||
@ -16,7 +16,7 @@ public class ProductManager : SemanticPersona, IManageProduct
|
||||
}
|
||||
public async Task<string> CreateReadme(string ask)
|
||||
{
|
||||
var function = _kernel.CreateSemanticFunction(PM.Readme, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });
|
||||
var function = _kernel.CreateSemanticFunction(PM.Readme, new OpenAIRequestSettings { MaxTokens = 10000, Temperature = 0.6, TopP = 1 });
|
||||
var context = new ContextVariables();
|
||||
context.Set("input", ask);
|
||||
if(_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user