You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.Net: OpenAI function calling - enable auto execution of functions #2932
Expand on our function calling support to enable the kernel to automatically execute functions returned by the model. This needs further consideration on questions such as:
how to maintain separation between connector-specific constructs and the core kernel abstractions
how to differentiate between chat message results and function results
how this impacts flows/chaining
For context, the initial implementations of function calling (and some discussion on this topic) are here: #2842 & #2356
changed the title [-]OpenAI function calling - enable auto execution of functions[/-][+]Python: OpenAI function calling - enable auto execution of functions[/+]on Sep 21, 2023
changed the title [-]Python: OpenAI function calling - enable auto execution of functions[/-][+].Net: OpenAI function calling - enable auto execution of functions[/+]on Sep 21, 2023
I left a few comments at #2842 (comment), but FWIW, I think this is a key differentiator that SK can provide. It takes something that's otherwise filled with boilerplate and leverages SK's strengths and the knowledge already built up to reduce that boilerplate all down to a one-liner. We should make this happen :)
This is adding an IChatCompletionWithFunctions, which exposes a GetChatCompletionsAsync and GetStreamingChatCompletionsAsync that just takes an additional argument (in my commit, it's an SKContext, but it could be something else that includes functions). This makes it trivial for a consumer to just do the normal chatting but with planning integrated into the chat: in the case of OpenAI or Azure OpenAI, the implementation can choose to use the server-side functionality, or in the case of another provider, it could choose to use a client-side planner and proactively augment the chat information sent.
The difference in what consumption like is night and day. Take a look at the Example59_OpenAIFunctionCalling. There are four implementations there: automatic (using this new interface) vs manual (working at the message level directly), and non-streaming vs streaming. The automatic ones that leverage IChatCompletionWithFunctions make it a no-brainer to use. The manual ones are not only incredibly hard (and not all that much better than what you can do at the underlying OpenAIClient level), you can't even implement the manual streaming one today due to missing support in SK.
I would strongly urge us to make getting something like this in for 1.0 a priority.
Activity
[-]OpenAI function calling - enable auto execution of functions[/-][+]Python: OpenAI function calling - enable auto execution of functions[/+][-]Python: OpenAI function calling - enable auto execution of functions[/-][+].Net: OpenAI function calling - enable auto execution of functions[/+]stephentoub commentedon Oct 11, 2023
I left a few comments at #2842 (comment), but FWIW, I think this is a key differentiator that SK can provide. It takes something that's otherwise filled with boilerplate and leverages SK's strengths and the knowledge already built up to reduce that boilerplate all down to a one-liner. We should make this happen :)
stephentoub commentedon Oct 16, 2023
Here's approximately what I think we should do for v1:
main...stephentoub:semantic-kernel:chatcompletionwithfunctions
This is adding an
IChatCompletionWithFunctions, which exposes aGetChatCompletionsAsyncandGetStreamingChatCompletionsAsyncthat just takes an additional argument (in my commit, it's anSKContext, but it could be something else that includes functions). This makes it trivial for a consumer to just do the normal chatting but with planning integrated into the chat: in the case of OpenAI or Azure OpenAI, the implementation can choose to use the server-side functionality, or in the case of another provider, it could choose to use a client-side planner and proactively augment the chat information sent.The difference in what consumption like is night and day. Take a look at the
Example59_OpenAIFunctionCalling. There are four implementations there: automatic (using this new interface) vs manual (working at the message level directly), and non-streaming vs streaming. The automatic ones that leverage IChatCompletionWithFunctions make it a no-brainer to use. The manual ones are not only incredibly hard (and not all that much better than what you can do at the underlying OpenAIClient level), you can't even implement the manual streaming one today due to missing support in SK.I would strongly urge us to make getting something like this in for 1.0 a priority.
.Net: Pass Kernel to connectors and implement automatic OpenAI functi…