From 943222bcbf2d511c6aa0d6a61087f6f28109b5fe Mon Sep 17 00:00:00 2001 From: Kosta Petan Date: Fri, 9 Jun 2023 17:10:41 +0200 Subject: [PATCH] extract skills to a classlib WIP --- cli/cli.csproj | 1 + sk-azfunc-server/.vscode/tasks.json | 2 +- sk-azfunc-server/ExecuteFunctionEndpoint.cs | 9 +++++ .../sk-csharp-azure-functions.csproj | 9 ++--- .../skills/DevLead/Plan/config.json | 12 ------ .../skills/DevLead/Plan/skprompt.txt | 9 ----- .../skills/Developer/Implement/config.json | 12 ------ .../skills/Developer/Implement/skprompt.txt | 6 --- .../skills/PM/BootstrapProject/config.json | 12 ------ .../skills/PM/BootstrapProject/skprompt.txt | 5 --- sk-azfunc-server/skills/PM/Readme/config.json | 12 ------ .../skills/PM/Readme/skprompt.txt | 5 --- skills/DevLead.cs | 25 ++++++++++++ skills/Developer.cs | 23 +++++++++++ skills/PM.cs | 40 +++++++++++++++++++ skills/SemanticFunctionConfig.cs | 13 ++++++ skills/skills.csproj | 9 +++++ 17 files changed, 125 insertions(+), 79 deletions(-) delete mode 100644 sk-azfunc-server/skills/DevLead/Plan/config.json delete mode 100644 sk-azfunc-server/skills/DevLead/Plan/skprompt.txt delete mode 100644 sk-azfunc-server/skills/Developer/Implement/config.json delete mode 100644 sk-azfunc-server/skills/Developer/Implement/skprompt.txt delete mode 100644 sk-azfunc-server/skills/PM/BootstrapProject/config.json delete mode 100644 sk-azfunc-server/skills/PM/BootstrapProject/skprompt.txt delete mode 100644 sk-azfunc-server/skills/PM/Readme/config.json delete mode 100644 sk-azfunc-server/skills/PM/Readme/skprompt.txt create mode 100644 skills/DevLead.cs create mode 100644 skills/Developer.cs create mode 100644 skills/PM.cs create mode 100644 skills/SemanticFunctionConfig.cs create mode 100644 skills/skills.csproj diff --git a/cli/cli.csproj b/cli/cli.csproj index a36d72b07..bcfba27de 100644 --- a/cli/cli.csproj +++ b/cli/cli.csproj @@ -12,6 +12,7 @@ + diff --git a/sk-azfunc-server/.vscode/tasks.json b/sk-azfunc-server/.vscode/tasks.json index 151a54f79..4e655aa3d 100644 --- a/sk-azfunc-server/.vscode/tasks.json +++ b/sk-azfunc-server/.vscode/tasks.json @@ -59,7 +59,7 @@ "type": "func", "dependsOn": "build (functions)", "options": { - "cwd": "${workspaceFolder}/bin/Debug/net6.0" + "cwd": "${workspaceFolder}/bin/Debug/net7.0" }, "command": "host start", "isBackground": true, diff --git a/sk-azfunc-server/ExecuteFunctionEndpoint.cs b/sk-azfunc-server/ExecuteFunctionEndpoint.cs index a88f378dc..a7edd4b48 100644 --- a/sk-azfunc-server/ExecuteFunctionEndpoint.cs +++ b/sk-azfunc-server/ExecuteFunctionEndpoint.cs @@ -45,7 +45,16 @@ public class ExecuteFunctionEndpoint 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); diff --git a/sk-azfunc-server/sk-csharp-azure-functions.csproj b/sk-azfunc-server/sk-csharp-azure-functions.csproj index 1407af1b8..a649fdfc5 100644 --- a/sk-azfunc-server/sk-csharp-azure-functions.csproj +++ b/sk-azfunc-server/sk-csharp-azure-functions.csproj @@ -6,11 +6,11 @@ - net6.0 + net7.0 v4 Exe - 10 + latest enable enable false @@ -24,8 +24,10 @@ + + PreserveNewest @@ -37,9 +39,6 @@ PreserveNewest - - PreserveNewest - diff --git a/sk-azfunc-server/skills/DevLead/Plan/config.json b/sk-azfunc-server/skills/DevLead/Plan/config.json deleted file mode 100644 index 6609514e8..000000000 --- a/sk-azfunc-server/skills/DevLead/Plan/config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "schema": 1, - "description": "From a simple description of an application output a development plan for building the application.", - "type": "completion", - "completion": { - "max_tokens": 4096, - "temperature": 0.0, - "top_p": 0.0, - "presence_penalty": 0.0, - "frequency_penalty": 0.0 - } -} \ No newline at end of file diff --git a/sk-azfunc-server/skills/DevLead/Plan/skprompt.txt b/sk-azfunc-server/skills/DevLead/Plan/skprompt.txt deleted file mode 100644 index 5de2bbb9b..000000000 --- a/sk-azfunc-server/skills/DevLead/Plan/skprompt.txt +++ /dev/null @@ -1,9 +0,0 @@ -You are a Dev Lead for an application team, building the application described below. -Please break down the steps and modules required to develop the complete application, describe each step in detail. -Make prescriptive architecture, language, and frameowrk choices, do not provide a range of choices. -For each step or module then break down the steps or subtasks required to complete that step or module. -For each subtask write an LLM prompt that would be used to tell a model to write the coee that will accomplish that subtask. If the subtask involves taking action/running commands tell the model to write the script that will run those commands. -In each LLM prompt restrict the model from outputting other text that is not in the form of code or code comments. -Please output a JSON data structure with a list of steps and a description of each step, and the steps or subtasks that each requires, and the LLM prompts for each subtask. -Do not output any other text. -Input: {{$input}} \ No newline at end of file diff --git a/sk-azfunc-server/skills/Developer/Implement/config.json b/sk-azfunc-server/skills/Developer/Implement/config.json deleted file mode 100644 index f55603460..000000000 --- a/sk-azfunc-server/skills/Developer/Implement/config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "schema": 1, - "description": "From a description of a coding task out put the code or scripts necessary to complete the task.", - "type": "completion", - "completion": { - "max_tokens": 4096, - "temperature": 0.0, - "top_p": 0.0, - "presence_penalty": 0.0, - "frequency_penalty": 0.0 - } -} \ No newline at end of file diff --git a/sk-azfunc-server/skills/Developer/Implement/skprompt.txt b/sk-azfunc-server/skills/Developer/Implement/skprompt.txt deleted file mode 100644 index c396228a8..000000000 --- a/sk-azfunc-server/skills/Developer/Implement/skprompt.txt +++ /dev/null @@ -1,6 +0,0 @@ -You are a Developer for an application. -Please output the code required to accomplish the task assigned to you below and wrap it in a bash script that creates the files. -Do not use any IDE commands and do not build and run the code. -Make specific choices about implementation. Do not offer a range of options. -Use comments in the code to describe the intent. Do not include other text other than code and code comments. -Input: {{$input}} \ No newline at end of file diff --git a/sk-azfunc-server/skills/PM/BootstrapProject/config.json b/sk-azfunc-server/skills/PM/BootstrapProject/config.json deleted file mode 100644 index 54819924a..000000000 --- a/sk-azfunc-server/skills/PM/BootstrapProject/config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "schema": 1, - "description": "Output a script that will help bootstrap a new code project in .NET", - "type": "completion", - "completion": { - "max_tokens": 7000, - "temperature": 0.0, - "top_p": 0.0, - "presence_penalty": 0.0, - "frequency_penalty": 0.0 - } -} \ No newline at end of file diff --git a/sk-azfunc-server/skills/PM/BootstrapProject/skprompt.txt b/sk-azfunc-server/skills/PM/BootstrapProject/skprompt.txt deleted file mode 100644 index de1547e5d..000000000 --- a/sk-azfunc-server/skills/PM/BootstrapProject/skprompt.txt +++ /dev/null @@ -1,5 +0,0 @@ -Please write a bash script with the commands that would be required to generate applications as described in the following input. -You may add comments to the script and the generated output but do not add any other text except the bash script. -You may include commands to build the applications but do not run them. -Do not include any git commands. -Input: {{$input}} \ No newline at end of file diff --git a/sk-azfunc-server/skills/PM/Readme/config.json b/sk-azfunc-server/skills/PM/Readme/config.json deleted file mode 100644 index 37c37a035..000000000 --- a/sk-azfunc-server/skills/PM/Readme/config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "schema": 1, - "description": "From a simple description output a README.md file for a GitHub repository.", - "type": "completion", - "completion": { - "max_tokens": 7600, - "temperature": 0.0, - "top_p": 0.0, - "presence_penalty": 0.0, - "frequency_penalty": 0.0 - } -} \ No newline at end of file diff --git a/sk-azfunc-server/skills/PM/Readme/skprompt.txt b/sk-azfunc-server/skills/PM/Readme/skprompt.txt deleted file mode 100644 index aad14347d..000000000 --- a/sk-azfunc-server/skills/PM/Readme/skprompt.txt +++ /dev/null @@ -1,5 +0,0 @@ -You are a program manager on a software development team. You are working on an app described below. -Based on the input below, and any dialog or other context, please output a raw README.MD markdown file documenting the main features of the app and the architecture or code organization. -Do not describe how to create the application. -Write the README as if it were documenting the features and architecture of the application. You may include instructions for how to run the application. -Input: {{$input}} \ No newline at end of file diff --git a/skills/DevLead.cs b/skills/DevLead.cs new file mode 100644 index 000000000..2f84dc613 --- /dev/null +++ b/skills/DevLead.cs @@ -0,0 +1,25 @@ +namespace skills; +public static class DevLead { + public static SemanticFunctionConfig Plan = new SemanticFunctionConfig + { + PromptTemplate = """ + You are a Dev Lead for an application team, building the application described below. + Please break down the steps and modules required to develop the complete application, describe each step in detail. + Make prescriptive architecture, language, and frameowrk choices, do not provide a range of choices. + For each step or module then break down the steps or subtasks required to complete that step or module. + For each subtask write an LLM prompt that would be used to tell a model to write the coee that will accomplish that subtask. If the subtask involves taking action/running commands tell the model to write the script that will run those commands. + In each LLM prompt restrict the model from outputting other text that is not in the form of code or code comments. + Please output a JSON data structure with a list of steps and a description of each step, and the steps or subtasks that each requires, and the LLM prompts for each subtask. + Do not output any other text. + Input: {{$input}} + """, + Name = nameof(Plan), + SkillName = nameof(DevLead), + Description = "From a simple description of an application output a development plan for building the application.", + MaxTokens = 4096, + Temperature = 0.0, + TopP = 0.0, + PPenalty = 0.0, + FPenalty = 0.0 + }; +} diff --git a/skills/Developer.cs b/skills/Developer.cs new file mode 100644 index 000000000..fd63cc29b --- /dev/null +++ b/skills/Developer.cs @@ -0,0 +1,23 @@ + +namespace skills; +public static class Developer { + public static SemanticFunctionConfig Implement = new SemanticFunctionConfig + { + PromptTemplate = """ + You are a Developer for an application. + Please output the code required to accomplish the task assigned to you below and wrap it in a bash script that creates the files. + Do not use any IDE commands and do not build and run the code. + Make specific choices about implementation. Do not offer a range of options. + Use comments in the code to describe the intent. Do not include other text other than code and code comments. + Input: {{$input}} + """, + Name = nameof(Implement), + SkillName = nameof(Developer), + Description = "From a description of a coding task out put the code or scripts necessary to complete the task.", + MaxTokens = 4096, + Temperature = 0.0, + TopP = 0.0, + PPenalty = 0.0, + FPenalty = 0.0 + }; +} diff --git a/skills/PM.cs b/skills/PM.cs new file mode 100644 index 000000000..766e4b8e4 --- /dev/null +++ b/skills/PM.cs @@ -0,0 +1,40 @@ +namespace skills; +public static class PM +{ + public static SemanticFunctionConfig BootstrapProject = new SemanticFunctionConfig + { + PromptTemplate = """ + Please write a bash script with the commands that would be required to generate applications as described in the following input. + You may add comments to the script and the generated output but do not add any other text except the bash script. + You may include commands to build the applications but do not run them. + Do not include any git commands. + Input: {{$input}} + """, + Name = nameof(BootstrapProject), + SkillName = nameof(PM), + Description = "Bootstrap a new project", + MaxTokens = 7000, + Temperature = 0.0, + TopP = 0.0, + PPenalty = 0.0, + FPenalty = 0.0 + }; + public static SemanticFunctionConfig Readme = new SemanticFunctionConfig + { + PromptTemplate = """ + You are a program manager on a software development team. You are working on an app described below. + Based on the input below, and any dialog or other context, please output a raw README.MD markdown file documenting the main features of the app and the architecture or code organization. + Do not describe how to create the application. + Write the README as if it were documenting the features and architecture of the application. You may include instructions for how to run the application. + Input: {{$input}} + """, + Name = nameof(Readme), + SkillName = nameof(PM), + Description = "From a simple description output a README.md file for a GitHub repository.", + MaxTokens = 7600, + Temperature = 0.0, + TopP = 0.0, + PPenalty = 0.0, + FPenalty = 0.0 + }; +} diff --git a/skills/SemanticFunctionConfig.cs b/skills/SemanticFunctionConfig.cs new file mode 100644 index 000000000..f472dfc6e --- /dev/null +++ b/skills/SemanticFunctionConfig.cs @@ -0,0 +1,13 @@ +namespace skills; +public class SemanticFunctionConfig +{ + public string PromptTemplate { get; set; } + public string Name { get; set; } + public string SkillName { get; set; } + public string Description { get; set; } + public int MaxTokens { get; set; } + public double Temperature { get; set; } + public double TopP { get; set; } + public double PPenalty { get; set; } + public double FPenalty { get; set; } +} \ No newline at end of file diff --git a/skills/skills.csproj b/skills/skills.csproj new file mode 100644 index 000000000..fd4d5df51 --- /dev/null +++ b/skills/skills.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + skills + +