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

Python: Ignore certain parameters when using get_tool_call_object #6065

Open
cecheta opened this issue Apr 30, 2024 · 0 comments
Open

Python: Ignore certain parameters when using get_tool_call_object #6065

cecheta opened this issue Apr 30, 2024 · 0 comments
Assignees
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel

Comments

@cecheta
Copy link
Member

cecheta commented Apr 30, 2024

When using get_tool_call_object, it would be good if it were possible to exclude certain parameters from being included in the responding tool object, namely the parameters that are automatically passed in by the kernel (e.g. kernel, service, etc.)

Consider the following example:

import asyncio
import json
from typing import Annotated

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai.utils import get_tool_call_object
from semantic_kernel.functions import kernel_function


class MyPlugin:
    @kernel_function(description="My function")
    def my_func(
        self,
        param: Annotated[str, "The parameter"],
        kernel: Kernel,
    ): ...


async def main():
    kernel = Kernel()

    kernel.add_plugin(plugin=MyPlugin(), plugin_name="MyPlugin")

    print(json.dumps(get_tool_call_object(kernel, filter={}), indent=2))


asyncio.run(main())

The function includes kernel, which will automatically be passed in when the function is called, however it also appears in the tool object:

[
  {
    "type": "function",
    "function": {
      "name": "MyPlugin-my_func",
      "description": "My function",
      "parameters": {
        "type": "object",
        "properties": {
          "param": {
            "description": "The parameter",
            "type": "string"
          },
          "kernel": {
            "description": "",
            "type": "string"
          }
        },
        "required": [
          "param",
          "kernel"
        ]
      }
    }
  }
]

This could mean that the LLM attempts to pass a value for kernel, when it shouldn't be coming from the LLM.

@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels Apr 30, 2024
@matthewbolanos matthewbolanos added bug Something isn't working and removed triage labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

No branches or pull requests

4 participants