Replies: 2 comments
-
As a workarround I built a factory for volatile SKFunction to put in the middle of the chain and copy to new variable: Helperdef copy_variable(destination: str, source: str = "input") -> SKFunction:
def helper_function(input_: str, context: SKContext) -> str:
context.variables[destination] = context.variables[source]
return input_
return SKFunction(
delegate_type=DelegateInference.infer_delegate_type(helper_function),
delegate_function=helper_function,
parameters=[ParameterView("input", "Input", "")],
description="Copy source context variable to destination",
skill_name="",
function_name="copy_variable",
is_semantic=False,
) Usage:result = await kernel.run_async(
semantic_functions["extractFunction"],
copy_variable("entities"),
native_function["get_sources"],
copy_variable("sources"),
semantic_functions["answer"],
input_vars=context,
)
# get intermediate values
sources = result.variables["sources"]
entities = result.variables["entities"] |
Beta Was this translation helpful? Give feedback.
-
Hi @ianchi, we've made a ton of updates to the Python code since this question was asked. For example, in our latest beta package, we return a |
Beta Was this translation helpful? Give feedback.
-
Current Situtation
There are many scenarios in which allowing a function (semantic or native) to export the output result as something else (in addition to)
$input
would be useful:$input
gets overwritten with the result of the following chain, and so it is lost.All these scenarios cannot be accomplished now using a single chain of functions. They all force to break the chain into smaller blocks, and then manually manipulate the context for the next step(s) and run a new subchain.
This completely ruins a very elegant piping design.
Proposed idea
output
property in theconfig.json
to specify an additional variable where to store the output (in addition to$input
)output
parameter in the decorator, with the same logicIf you agree with the idea, I could send a PR implementing it for the Python version.
Beta Was this translation helpful? Give feedback.
All reactions