semantic-kernel
semantic-kernel copied to clipboard
Generate variables from one skill(Native/Semantic) output for pipeline execution.
While running the skills in a pipeline the generated output of one skill is put into the variable INPUT
in the ContextVariables(calling the context variable's update method) and then before running the next skill prompt template engine will create blocks and replace the input variable with the last skill execution output.
But in example let's say
skillOne -> Generates some context and set the output in variable1
skillTwo -> Generates some context and set the output to variable2
skillThree -> The prompt looks like " Write a paragraph on topic {{variable1}} to create XXX and use {{variable2}} as the different inputs"
So instead of calling the skills separately and setting the variables in context
outputOne = kernel.RunAsync(skillOne, input);
outputTwo= kernel.RunAsync(skillTwo, input);
contextVariables.Set("variable1", outputOne );
contextVariables.Set("variable2", outputTwo);
kernel.RunAsync(skillThree, contextVariables);
What I want want to do is
kernel.RunAsync(input, skillOne, skillTwo, skillThree)
The config of skills should handle the information of output variables. Just like we can mention input variables for a skill we should be able to add output variables and the engine should handle the generation of output variables and setting them into the context. This might be not feasible to do as we might face problems like generating multiple output variables from selecting the completed text but wanted to hear more thoughts on this.
There's definitely work we want to do to improve the visibility of outputs from functions.
In the short term, I'd try using the Plan
object.
var prompt = "Write a {{$input}} on topic {{$variable1}} and use {{$variable2}} as the voice of the {{$input}}.";
// Import Skills
var summarize = kernel.CreateSemanticFunction(prompt);
var testSkill = kernel.ImportSkill(new TestSkill(), "TestSkill");
// Create PLan
Plan plan = new("Create a text using skills");
plan.AddSteps(testSkill["SkillOne"], testSkill["SkillTwo"], summarize);
plan.Steps[0].Outputs.Add("variable1");
plan.Steps[1].Outputs.Add("variable2");
// Execute Plan
var result = await plan.InvokeAsync("poem");
Console.WriteLine(result.Result);`
Closing old issues, please re-open if you have more to add to the issue.