[Python] Arguments Not Reaching Plugin Methods When Invoked via Kernel in Semantic Kernel...

Discussão em 'Python' iniciado por Stack, Julho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with the Python SDK of Microsoft Semantic Kernel and trying to invoke a plugin function with arguments using agent.invoke(messages, arguments). However, the arguments don't seem to be passed to the plugin method.

    1. Defined a plugin and added kernel function
    2. Created and added a service - AzureChatCompletion
    3. Created a 'ChatCompletionAgent' using the Kernel, Plugin and AzureChatCompletion Service

    # Create a Plugin
    class DatabrickConnector:
    @kernel_function(description="This function gives description about the asked topic")
    async def multiply(self, prompt: str, **kwargs) -> str:
    return self.client.beta.chat.completions.parse(
    model=openai_gpt_deployment_name,
    messages=[
    {"role": "user", "content": question + kwargs['topic']}
    ],
    )

    # Create AzureChatCompletion Service
    from semantic_kernel.connectors.ai.open_ai.services.azure_chat_completion import AzureChatCompletion
    service_id = "azure-openai"
    chat_service = AzureChatCompletion(
    service_id=service_id,
    deployment_name=openai_gpt_deployment_name,
    api_key = openai_api_key,
    api_version = openai_api_version,
    endpoint = openai_api_base
    )

    # Creating the kernel and add service, plugin
    from semantic_kernel.kernel import Kernel

    kernel_RAG = Kernel()
    kernel_RAG.add_service(chat_service)
    kernel_RAG.add_plugin(DatabrickConnector(), plugin_name="DatabrickConnector")

    # Initialize the agent
    from semantic_kernel.agents import ChatCompletionAgent

    agent = ChatCompletionAgent(
    kernel=kernel_RAG,
    name="Response_Agent",
    instructions="Provide description about the asked topic"
    )


    response = agent.invoke(messages="Provide very detailed description about ", arguments = KernelArguments(topic = "Semantic Kernel")


    Here, the kernel function is getting invoked, but KernelArgument is not getting passed to the function. How do I ensure that kernel function is invoked with the right arguments?

    Continue reading...

Compartilhe esta Página