.Net: Support function calling#2842
Merged
gitri-ms merged 46 commits intomicrosoft:mainfrom Sep 28, 2023
Merged
Conversation
dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
Sep 15, 2023
dotnet/samples/KernelSyntaxExamples/Example58_FunctionCalling.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatRequestSettings.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/FunctionsViewExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/FunctionViewExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/KernelSyntaxExamples/Example58_FunctionCalling.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/KernelSyntaxExamples/Example58_FunctionCalling.cs
Outdated
Show resolved
Hide resolved
30c3da7 to
3bae074
Compare
…/semantic-kernel into gitri-ms-function-calling-dotnet
deeef26 to
3ed31d7
Compare
Change Console.WriteLine to use GetValue<string>() instead of Result property in Example59_OpenAIFunctionCalling.cs. This improves the output handling and ensures proper string conversion.
Replace `OpenApiPluginExecutionParameters` with `OpenApiFunctionExecutionParameters` in the import of the KlarnaShoppingPlugin.
gitri-ms
commented
Sep 25, 2023
gitri-ms
commented
Sep 25, 2023
crickman
approved these changes
Sep 27, 2023
stephentoub
reviewed
Sep 27, 2023
SOE-YoungS
pushed a commit
to SOE-YoungS/semantic-kernel
that referenced
this pull request
Nov 1, 2023
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Enable the use of [OpenAI's function calling capability](https://platform.openai.com/docs/guides/gpt/function-calling) with SK. However, since this feature is limited to OpenAI chat completion models, we want to do so without widespread changes to the kernel. Fixes microsoft#2315 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Add ability to pass functions to chat completion model via request settings. If the model does not support function calling, this will be ignored. - Add OpenAIFunction class to store function information when passing to the model. This reduces coupling with OpenAI's FunctionDefinition, but adds an extra layer of translation. - Add translation layer between FunctionView and OpenAIFunction to easily utilize functions already registered with the kernel - Add example demonstrating how to include functions, parse response, and invoke chosen function if registered with the kernel - Add required field to ParameterView (default false). This improves the chances of getting correct function arguments from OpenAI. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 - [x] Design decisions captured in MADR --------- Co-authored-by: Lee Miller <lemiller@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Enable the use of OpenAI's function calling capability with SK. However, since this feature is limited to OpenAI chat completion models, we want to do so without widespread changes to the kernel.
Fixes #2315
Description
Contribution Checklist