From 5b2424b0c3e07ef294ce31a2611de76e712bf2e6 Mon Sep 17 00:00:00 2001 From: Thomas Gobin Date: Tue, 13 Jun 2023 22:01:05 +0200 Subject: [PATCH 1/5] Add Transform Output Skill --- .../CopilotChat/Controllers/ChatController.cs | 3 ++ .../TransformOutputSkill/config.json | 39 +++++++++++++++++++ .../TransformOutputSkill/skprompt.txt | 24 ++++++++++++ .../webapi/CopilotChatWebApi.csproj | 15 +++++++ 4 files changed, 81 insertions(+) create mode 100644 samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json create mode 100644 samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/skprompt.txt diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Controllers/ChatController.cs b/samples/apps/copilot-chat-app/webapi/CopilotChat/Controllers/ChatController.cs index b32af123299c..62d54b22c2e8 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChat/Controllers/ChatController.cs +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Controllers/ChatController.cs @@ -109,6 +109,9 @@ public async Task ChatAsync( /// private async Task RegisterPlannerSkillsAsync(CopilotChatPlanner planner, OpenApiSkillsAuthHeaders openApiSkillsAuthHeaders, ContextVariables variables) { + // Register Transform output skill + planner.Kernel.ImportSemanticSkillFromDirectory(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "CopilotChat", "Skills"), "DataTransformationSkills"); + // Register authenticated skills with the planner's kernel only if the request includes an auth header for the skill. // Klarna Shopping diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json new file mode 100644 index 000000000000..e7b5272c55e7 --- /dev/null +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json @@ -0,0 +1,39 @@ +{ + "schema": 1, + "description": "Apply a specific format or transformation to context variables inside a plan. This method must be used each time a specific format (such as specific format of list, specific JSON formatting from source data...) or transformation (such as filtering, capitalization...) is required for a parameter of a function in the plan and if another formatting or transformation function is not called instead. If a doubt exists about does the output format a function corresponds to the required input of another one, this methods must be called", + "type": "completion", + "completion": { + "max_tokens": 1000, + "temperature": 0.0, + "top_p": 0.0, + "presence_penalty": 0.0, + "frequency_penalty": 0.0, + "stop_sequences": [ + "[END FORMATTEDOUTPUT]" + ] + }, + "input": { + "parameters": [ + { + "name": "input", + "description": "User intent", + "defaultValue": "" + }, + { + "name": "rationale", + "description": "Description of the specific format or transformation that must be applied to inputVariable to respect the requested format or transformation. Must be as precized as possible and can contain examples of the expected result if available", + "defaultValue": "" + }, + { + "name": "outputFormat", + "description": "Description of the format of the output. Must be as precized as possible and can contain examples of the expected result if available (it can for example include the specific request format such a the JSON description or an example given in the parameter description of the called function)", + "defaultValue": "" + }, + { + "name": "inputVariable", + "description": "Input data, coming from a previous function, that must be formatted or transformed", + "defaultValue": "" + } + ] + } +} \ No newline at end of file diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/skprompt.txt b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/skprompt.txt new file mode 100644 index 000000000000..5eade9a7623d --- /dev/null +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/skprompt.txt @@ -0,0 +1,24 @@ +A function is composed of parameters, the goal is to apply a transformation or specific formatting to respect the requirement of a parameter function. Considering the description of the transformation or formatting to apply ([RATIONALE] section), format of the expected output ([outputFormat] section) and goal of the global plan ([GOAL] section), format the content of the input ([inputVariable] section) to respect all requirements. + +[START EXAMPLE] +[START inputVariable] +Here is the list of Stores: [Paris Saint Sulpice,Paris Auteuil, Cannes] +[END inputVariable] +[START outputFormat]Comma separated list of store names (example: Paris Saint Sulpice,Cannes)[END outputFormat] +[START GOAL]User intent: Please search for black t-shirts made of wool fabric and provide me with their availability at stores located in Paris.[END GOAL] +[START RATIONALE]Filter the list of stores to only include stores located in Paris[END RATIONALE] +[START FORMATTEDOUTPUT] +Paris Saint Sulpice,Paris Auteuil +[END FORMATTEDOUTPUT] +[END EXAMPLE] + +Real data start here : +[START inputVariable] +{{$inputVariable}} +[END inputVariable] +[START outputFormat] +{{$outputFormat}} +[END outputFormat] +[START GOAL]{{$planUserIntent}}[END GOAL] +[START RATIONALE]{{$rationale}}[END RATIONALE] +[START FORMATTEDOUTPUT] \ No newline at end of file diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj b/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj index de18436d48a5..04aae100539d 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj +++ b/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj @@ -8,6 +8,9 @@ SemanticKernel.Service aspnet-SKWebApi-1581687a-bee4-40ea-a886-ce22524aea88 + + + @@ -69,4 +72,16 @@ <_Parameter1>false + + + + Always + + + + + + Always + + From 4125433e4bd0d945eb14bfbe6e50e59ad7010cb7 Mon Sep 17 00:00:00 2001 From: thomasgobin Date: Wed, 14 Jun 2023 21:23:40 +0200 Subject: [PATCH 2/5] Update CopilotChatWebApi.csproj --- samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj b/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj index 04aae100539d..5e2477f4e071 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj +++ b/samples/apps/copilot-chat-app/webapi/CopilotChatWebApi.csproj @@ -8,9 +8,6 @@ SemanticKernel.Service aspnet-SKWebApi-1581687a-bee4-40ea-a886-ce22524aea88 - - - From 9feb3a0b7627649b0b6a8b4145e6f0df5db5355e Mon Sep 17 00:00:00 2001 From: thomasgobin Date: Wed, 14 Jun 2023 21:24:31 +0200 Subject: [PATCH 3/5] Update config.json --- .../DataTransformationSkills/TransformOutputSkill/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json index e7b5272c55e7..7ad9c525fa0c 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json @@ -21,7 +21,7 @@ }, { "name": "rationale", - "description": "Description of the specific format or transformation that must be applied to inputVariable to respect the requested format or transformation. Must be as precized as possible and can contain examples of the expected result if available", + "description": "Description of the specific format or transformation that must be applied to inputVariable to respect the requested format or transformation. Must be as precise as possible and can contain examples of the expected result if available", "defaultValue": "" }, { @@ -36,4 +36,4 @@ } ] } -} \ No newline at end of file +} From eac3a5715b83514e7e32a613fd36eb2d536731ff Mon Sep 17 00:00:00 2001 From: thomasgobin Date: Tue, 20 Jun 2023 16:20:11 +0200 Subject: [PATCH 4/5] Update config.json --- .../DataTransformationSkills/TransformOutputSkill/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json index 7ad9c525fa0c..c22fc98bb1d8 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json @@ -1,6 +1,6 @@ { "schema": 1, - "description": "Apply a specific format or transformation to context variables inside a plan. This method must be used each time a specific format (such as specific format of list, specific JSON formatting from source data...) or transformation (such as filtering, capitalization...) is required for a parameter of a function in the plan and if another formatting or transformation function is not called instead. If a doubt exists about does the output format a function corresponds to the required input of another one, this methods must be called", + "description": "Format or transform context variables for plan functions. Use this method when a function parameter requires a specific format (such as list or JSON string) or transformation (such as filtering or capitalization) that is not already done by another function. If unsure whether a function's output matches a subsequent function's input, use this method.", "type": "completion", "completion": { "max_tokens": 1000, From 1f3ffe72bcf2dc6913fd99125cee487f3f0f81df Mon Sep 17 00:00:00 2001 From: thomasgobin Date: Mon, 10 Jul 2023 10:01:22 +0200 Subject: [PATCH 5/5] Remove input variable --- .../TransformOutputSkill/config.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json index c22fc98bb1d8..bf7525a5b45c 100644 --- a/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json +++ b/samples/apps/copilot-chat-app/webapi/CopilotChat/Skills/DataTransformationSkills/TransformOutputSkill/config.json @@ -14,11 +14,6 @@ }, "input": { "parameters": [ - { - "name": "input", - "description": "User intent", - "defaultValue": "" - }, { "name": "rationale", "description": "Description of the specific format or transformation that must be applied to inputVariable to respect the requested format or transformation. Must be as precise as possible and can contain examples of the expected result if available",