-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Labels
Description
In Semantic Kernel Auto invocation works as follows (link):
- Serialize functions: All of the available functions (and its input parameters) in the kernel are serialized using JSON schema.
- Send the messages and functions to the model: The serialized functions (and the current chat history) are sent to the model as part of the input.
- Model processes the input: The model processes the input and generates a response. The response can either be a chat message or one or more function calls.
- Handle the response: If the response is a chat message, it is returned to the caller. If the response is a function call, however, Semantic Kernel extracts the function name and its parameters.
- Invoke the function: The extracted function name and parameters are used to invoke the function in the kernel.
- Return the function result: The result of the function is then sent back to the model as part of the chat history. Steps 2-6 are then repeated until the model returns a chat message or the max iteration number has been reached.
If a ChatMessageContent
is the last message in the chat history and a parameter is passed, e.g. AllowFunctionInvocationFirst = true
, then skip to step 5 and invoke the functions in that final message before continuing with the auto loop.
Use Case
For our invocation we may want to get feedback from the user before continuing with the chat. Think, for example, distructiveHint in MCP but our own version.
Current Work Around
Our current workaround is to decorate the IChatCompletionService
with a service that returns the ChatMessageContent
first as a "fake" invocation of the model, but it would be great to add this to the framework directly somehow.