Skip to content
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

Native Python function is calling _invoke_semantic_async instead of _invoke_native_async #782

Closed
goodsky opened this issue May 3, 2023 · 2 comments
Assignees
Labels
python Pull requests for the Python Semantic Kernel

Comments

@goodsky
Copy link

goodsky commented May 3, 2023

Describe the bug
When trying to invoke a native function in Python, I am running into this error:

File [...\site-packages\semantic_kernel\orchestration\sk_function.py:311] in SKFunction.invoke(self, input, variables, context, memory, settings, log)
    309         return self._runThread(self._invoke_semantic_async(context, settings))
    310     else:
--> 311         return self._runThread(self._invoke_semantic_async(context))
    312 else:
    313     if self.is_semantic:

TypeError: SKFunction._invoke_semantic_async() missing 1 required positional argument: 'settings'

Looking at line 310 of sk_function.py it appears that there is a typo. It seems we should be invoking self._invoke_native_async(context) instead of self._invoke_semantic_async.

To Reproduce
Steps to reproduce the behavior:

  1. Load a native function.
  2. Execute it

Sample Script
This is the script I am running to reproduce:

nativeFunctions = kernel.import_native_skill_from_directory("skills", "GenerateNumber")
randomFunction = nativeFunctions["Random"]
result = randomFunction.invoke(input="10")

Where the 'GenerateNumber' skill looks like this:

class GenerateNumberSkill:
    """
    Description: Generates numbers
    """

    @sk_function(description="Generates a random number between 1 - <input>", name="Random")
    def random_number(self, input: str) -> str:
        """
        Description: Generates a random number between 1 - <input>
        """
        try:
            return str(random.randint(1, int(input)))
        except ValueError as e:
            print(f"Invalid upper bound for random value: {input}")
            raise e
@alexchaomander alexchaomander added the python Pull requests for the Python Semantic Kernel label May 3, 2023
@alexchaomander
Copy link
Contributor

@mkarle can you take a look at this?

@mkarle
Copy link
Contributor

mkarle commented May 4, 2023

Thanks for finding this typo! I'll submit a fix for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

No branches or pull requests

3 participants