-
Hi, I’m working with the Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Hi @vslepakov, we only broadcast the kernel function's arguments to the model, so it knows what is required/not required. We are not broadcasting kernel argument values. As a note, can you please have a look at the follow doc: https://learn.microsoft.com/en-us/semantic-kernel/concepts/ai-services/chat-completion/function-calling/?pivots=programming-language-python#custom-reserved-parameter-names-for-auto-function-calling In a code sample there, we show Separately, you could have an auth callback in your kernel function that gets the required access token. This would remove the input param to the kernel function related to auth. See an example here: |
Beta Was this translation helpful? Give feedback.
-
Hi @vslepakov, let's take the following kernel function example: class MenuPlugin:
"""A sample Menu Plugin used for the concept sample."""
@kernel_function(description="Provides a list of specials from the menu.")
def get_specials(
self, api_key: Annotated[str, {"include_in_function_choices": False}]
) -> Annotated[str, "Returns the specials from the menu."]:
print(f"API Key: {api_key}")
return """
Special Soup: Clam Chowder
Special Salad: Cobb Salad
Special Drink: Chai Tea
""" You can see I added When we broadcast the json to the model, it sees: {
"type": "function",
"function":
{
"name": "MenuPlugin-get_specials",
"description": "Provides a list of specials from the menu.",
"parameters":
{
"type": "object",
"properties":
{},
"required":
[]
}
}
} No mention of And when we actually call the function with the following script: USER_INPUTS = [
"Hello",
"What is the special soup?",
"What does that cost?",
"Thank you",
]
async def main():
# 1. Create the agent
agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="Host",
instructions="Answer questions about the menu.",
plugins=[MenuPlugin()],
)
# 2. Create a thread to hold the conversation
# If no thread is provided, a new thread will be
# created and returned with the initial response
thread: ChatHistoryAgentThread = None
for user_input in USER_INPUTS:
print(f"# User: {user_input}")
# 4. Invoke the agent for a response
arguments = KernelArguments(api_key="12345")
response = await agent.get_response(messages=user_input, thread=thread, arguments=arguments)
print(f"# {response.name}: {response} ")
thread = response.thread
# 4. Cleanup: Clear the thread
await thread.delete() if thread else None I see:
|
Beta Was this translation helpful? Give feedback.
Hi @vslepakov, we only broadcast the kernel function's arguments to the model, so it knows what is required/not required. We are not broadcasting kernel argument values.
As a note, can you please have a look at the follow doc: https://learn.microsoft.com/en-us/semantic-kernel/concepts/ai-services/chat-completion/function-calling/?pivots=programming-language-python#custom-reserved-parameter-names-for-auto-function-calling
In a code sample there, we show
special_arg: Annotated[str, {"include_in_function_choices": False}
- where you can now provide the Annotated metadata. This tells the model that the argument is not required, and thus can be handled as a kernel argument and not have the mod…