Repository navigation
Allow to export output of function as something else appart from $input #1540
Closed
Adrián Panella (ianchi)
started this conversation in
Ideas
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"] |
0 replies
|
Hi Adrián Panella (@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 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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)
$inputwould be useful:$inputgets 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
outputproperty in theconfig.jsonto specify an additional variable where to store the output (in addition to$input)outputparameter in the decorator, with the same logicIf you agree with the idea, I could send a PR implementing it for the Python version.
All reactions