Skip to content

python/10-Chaining-Functions sample error, "No return type specified, unable to infer DelegateType" #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rockbotclub opened this issue Nov 6, 2023 · 0 comments

Comments

@rockbotclub
Copy link

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:
image

https://github.com/MicrosoftDocs/semantic-kernel-docs/blob/main/samples/python/10-Chaining-Functions/plugins/OrchestratorPlugin/Orchestrator.py

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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant