semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: Bug: Function called with wrong parameters in planner

Open florath opened this issue 1 year ago • 0 comments

Describe the bug Running a planner using the task from one of the python examples: "What is 387 minus 22? Email the solution to John and Mary."

This is what the LLM returns during the planner call:

<xml>Here is an XML plan to satisfy the given goal:
```xml
<plan>
    <!-- Get the current date -->
    <function.TimePlugin-date setContextVariable="CURRENT_DATE"/>

    <!-- Calculate the answer -->
    <function.MathPlugin-Subtract input="387" amount="22" appendToResult="RESULT__ANSWER"/>

    <!-- Get the email addresses of John and Mary -->
    <function.EmailPlugin-GetEmailAddress input="John" setContextVariable="JOHN_EMAIL"/>
    <function.EmailPlugin-GetEmailAddress input="Mary" setContextVariable="MARY_EMAIL"/>

    <!-- Send the email with the solution -->
    <function.EmailPlugin-SendEmail subject="Math Problem Solution" body="The answer is $RESULT__ANSWER." to="$JOHN_EMAIL,$MARY_EMAIL"/>

    <!-- END -->
</plan>
```</xml>

The call to function.TimePlugin-date is not needed - but it should not harm.

The output of the plan:

- Get the current date using TimePlugin-date with parameters: {}
- Subtracts value to a value using MathPlugin-Subtract with parameters: {'input': '387', 'amount': '22'}
- Given a name, find the email address using EmailPlugin-GetEmailAddress with parameters: {'input': 'John'}
- Given a name, find the email address using EmailPlugin-GetEmailAddress with parameters: {'input': 'Mary'}
- Given an e-mail and message body, send an e-email using EmailPlugin-SendEmail with parameters: {'subject': 'Math Problem Solution', 'body': 'The answer is $RESULT__ANSWER.', 'to': '$JOHN_EMAIL,$MARY_EMAIL'}

But then somethings fails when executing the plan:

Something went wrong in plan step MathPlugin.Subtract:'Parameter input is expected to be parsed to <class 'int'> but is not.'
Traceback (most recent call last):
  File "/ai/runtime/miniconda3/envs/semkern/lib/python3.11/site-packages/semantic_kernel/functions/kernel_function_from_method.py", line 158, in gather_function_parameters
    value = param.type_object(value)
            ^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'Monday, 17 June, 2024'

MathPlugin-Subtract should work on the parameters 387 and 22 - and not on the current date.

To Reproduce As I'm using a temperature != 1, this is mostly not directly reproducible. I think you need to inject the above XML directly as result of the planing step.

Expected behavior MathPlugin-Subtract should subtract 22 from 387. It should not work on a date.

Screenshots n/a

Platform

  • OS: Linux Debian 12
  • IDE: emacs
  • Language: python
  • Source: pip: semantic-kernel 1.1.1

Additional context I'm using ollama and "aya:35b".

Available plugins:

Plugin: EmailPlugin, Function: GetEmailAddress
Plugin: EmailPlugin, Function: SendEmail
Plugin: MathPlugin, Function: Add
Plugin: MathPlugin, Function: Subtract
Plugin: TimePlugin, Function: date
Plugin: TimePlugin, Function: date_matching_last_day_name
Plugin: TimePlugin, Function: day
Plugin: TimePlugin, Function: dayOfWeek
Plugin: TimePlugin, Function: days_ago
Plugin: TimePlugin, Function: hour
Plugin: TimePlugin, Function: hourNumber
Plugin: TimePlugin, Function: iso_date
Plugin: TimePlugin, Function: minute
Plugin: TimePlugin, Function: month
Plugin: TimePlugin, Function: month_number
Plugin: TimePlugin, Function: now
Plugin: TimePlugin, Function: second
Plugin: TimePlugin, Function: time
Plugin: TimePlugin, Function: timeZoneName
Plugin: TimePlugin, Function: timeZoneOffset
Plugin: TimePlugin, Function: today
Plugin: TimePlugin, Function: utcNow
Plugin: TimePlugin, Function: year

florath avatar Jun 17 '24 07:06 florath