Skip to content

A programming framework for agentic AI

switch to lib skills

Kosta Petanf8485dc0115d
diff --git a/sk-azfunc-server/ExecuteFunctionEndpoint.cs b/sk-azfunc-server/ExecuteFunctionEndpoint.cs
index a7edd4b48..6f54bc5e5 100644
--- a/sk-azfunc-server/ExecuteFunctionEndpoint.cs
+++ b/sk-azfunc-server/ExecuteFunctionEndpoint.cs
@@ -6,6 +6,7 @@ using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Orchestration;
using Models;
+using skills;
public class ExecuteFunctionEndpoint
{
@@ -31,36 +32,14 @@ public class ExecuteFunctionEndpoint
HttpRequestData requestData,
FunctionContext executionContext, string skillName, string functionName)
{
-#pragma warning disable CA1062
try
{
var functionRequest = await JsonSerializer.DeserializeAsync<ExecuteFunctionRequest>(requestData.Body, s_jsonOptions).ConfigureAwait(false);
-#pragma warning disable CA1062
- // note: using skills from the repo
- var skillsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "skills");
-
- var skillDirectory = Path.Combine(skillsDirectory, skillName);
- if (!System.IO.Directory.Exists(skillDirectory))
- {
- return await CreateResponseAsync(requestData, HttpStatusCode.NotFound, new ErrorResponse() { Message = $"Unable to find {skillName}" }).ConfigureAwait(false);
- }
-
-
- //var pmReadme = _kernel.CreateSemanticFunction(skills.PM.Readme.PromptTemplate,);
-
-
- var skill = this._kernel.ImportSemanticSkillFromDirectory(skillsDirectory, skillName);
-
-
-
-
- if (!skill.ContainsKey(functionName))
- {
- return await CreateResponseAsync(requestData, HttpStatusCode.NotFound, new ErrorResponse() { Message = $"Unable to find {skillName}.{functionName}" }).ConfigureAwait(false);
- }
-
- var function = skill[functionName];
+ 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 context = new ContextVariables();
foreach (var v in functionRequest.Variables)
@@ -80,8 +59,6 @@ public class ExecuteFunctionEndpoint
return await CreateResponseAsync(requestData, HttpStatusCode.BadRequest, new ErrorResponse() { Message = $"Invalid request body." }).ConfigureAwait(false);
}
-
-
}
private static async Task<HttpResponseData> CreateResponseAsync(HttpRequestData requestData, HttpStatusCode statusCode, object responseBody)
diff --git a/skills/SemanticFunctionConfig.cs b/skills/SemanticFunctionConfig.cs
index f472dfc6e..f09612880 100644
--- a/skills/SemanticFunctionConfig.cs
+++ b/skills/SemanticFunctionConfig.cs
@@ -1,4 +1,5 @@
namespace skills;
+
public class SemanticFunctionConfig
{
public string PromptTemplate { get; set; }
@@ -10,4 +11,13 @@ public class SemanticFunctionConfig
public double TopP { get; set; }
public double PPenalty { get; set; }
public double FPenalty { get; set; }
+ private static SemanticFunctionConfig 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,
+ _ => throw new ArgumentException($"Unable to find {skillName}.{functionName}")
+ };
}
\ No newline at end of file
diff --git a/skills/skills.csproj b/skills/skills.csproj
index fd4d5df51..351d9eceb 100644
--- a/skills/skills.csproj
+++ b/skills/skills.csproj
@@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
<RootNamespace>skills</RootNamespace>
</PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.SemanticKernel" Version="0.14.547.1-preview" />
+ </ItemGroup>
</Project>