mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Fix SKFunction.InvokeAsync to respect input when passed in explicitly. (#1757)
- The defaults for `mutableContext` are `true` which make it super easy to fall into this trap. I slammed my head against the wall for a while until realizing that the SK InvokeAsync method wasn't properly utilizing the `input` parameter. --------- Co-authored-by: Shawn Callegari <[email protected]>
This commit is contained in:
co-authored by
Shawn Callegari
parent
de9c202a72
commit
6a370e7d13
@@ -125,18 +125,14 @@ public static class SKFunctionExtensions
|
||||
function.SkillName, function.Name);
|
||||
}
|
||||
|
||||
if (mutableContext)
|
||||
if (!mutableContext)
|
||||
{
|
||||
context.Variables.Update(input);
|
||||
return function.InvokeAsync(context, settings);
|
||||
// Create a copy of the context, to avoid editing the original set of variables
|
||||
context = context.Clone();
|
||||
}
|
||||
|
||||
// Create a copy of the context, to avoid editing the original set of variables
|
||||
SKContext contextClone = context.Clone();
|
||||
|
||||
// Store the input in the context clone
|
||||
contextClone.Variables.Update(input);
|
||||
|
||||
return function.InvokeAsync(contextClone, settings);
|
||||
// Store the input in the context
|
||||
context.Variables.Update(input);
|
||||
return function.InvokeAsync(context, settings);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user