python/10-Chaining-Functions sample error, "No return type specified, unable to infer DelegateType"
rockbotclub opened this issue · comments
rockbotclub commented
Hi there, it seems that the official sample has a bug, when I execute the 10-Chaining-Functions python script, there is an error like this:
the correct version:
@sk_function(
description="Extracts numbers from JSON",
name="ExtractNumbersFromJson",
)
## add "-> str" ##
def extract_numbers_from_json(self, context: SKContext) -> str:
numbers = json.loads(context["input"])
# Loop through numbers and add them to the context
for key, value in numbers.items():
if key == "number1":
# Add the first number to the input variable
context["input"] = str(value)
else:
# Add the rest of the numbers to the context
context[key] = str(value)
## add ["input"] ##
return context["input"]