-
Notifications
You must be signed in to change notification settings - Fork 4k
.Net: Function calling abstraction #6083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
SergeyMenshykh
wants to merge
141
commits into
microsoft:main
from
SergeyMenshykh:function-calling-abstraction-poc
Closed
Changes from 74 commits
Commits
Show all changes
141 commits
Select commit
Hold shift + click to select a range
19254dc
FunctionCallContent and FunctionResultContent classes are added.
SergeyMenshykh 0a8a616
Merge with latest main
SergeyMenshykh 6a03050
Unnecessary warning suppressions removed
SergeyMenshykh a23f5e7
Fix funciton calling example
SergeyMenshykh a05d88d
Fix for unit tests
SergeyMenshykh 704111c
FunctionCallContent.FunctionCall property removed.
SergeyMenshykh 3267573
Adding FunctionResultContent items to the chat message for auto funct…
SergeyMenshykh 79df688
Update dotnet/src/Connectors/Connectors.OpenAI/AzureSdk/ClientCore.cs
SergeyMenshykh 88b1f03
Update dotnet/src/InternalUtilities/src/System/IListExtensions.cs
SergeyMenshykh e5c327b
Update dotnet/samples/KernelSyntaxExamples/Example59_OpenAIFunctionCa…
SergeyMenshykh b732256
Update dotnet/src/SemanticKernel.Abstractions/Contents/FunctionResult…
SergeyMenshykh 8823ebd
A few minor improvments.
SergeyMenshykh e06c070
Merge branch 'function-call-content-types' of https://github.com/Serg…
SergeyMenshykh ddbb7c2
Update dotnet/src/InternalUtilities/src/System/IListExtensions.cs
SergeyMenshykh 8569dc4
Debug.Assert instead of null checks.
SergeyMenshykh 145968f
New ChatHsitory.AddMessage method removed.
SergeyMenshykh b996eb4
New ChatMessageContent.GetFunctionCalls method removed.
SergeyMenshykh 28c8ac3
The fully qualified name parsing logic is encapsulated in the FullyQu…
SergeyMenshykh 397795b
The `FunctionResultContent.Result` property setter is removed.
SergeyMenshykh f9c493d
Default null value of the `executionSettings` parameter is removed fo…
SergeyMenshykh 900e213
Merge branch 'main' into function-call-content-types
crickman 795c197
The unnecessary check for the result of the OfType method call is rem…
SergeyMenshykh 9b952c0
Merge branch 'function-call-content-types' of https://github.com/Serg…
SergeyMenshykh 055a194
The `FunctionCallContent.GetFullyQualifiedName` method is moved to th…
SergeyMenshykh cab73c5
Logging function parameters deserialization failure
SergeyMenshykh f6d3e96
The ChatHistory.AddMessage method usage is replaced by ChatHistory.Ad…
SergeyMenshykh ef6a55c
ChatHistory.AddMessage method usage is replaced by the ChatHistory.Ad…
SergeyMenshykh 636a22e
non-existing project is removed
SergeyMenshykh b377b50
Fix for unit tests
SergeyMenshykh ffb8467
Merge branch 'main' into function-call-content-types
SergeyMenshykh c29954d
FunctionCallContent class is renamed to FunctionCallRequestContent
SergeyMenshykh d555b29
FunctionResultContent class is renamed to FunctionCallResultContent
SergeyMenshykh 8e2ae55
More efficient handling of the FunctionCallResultContent items
SergeyMenshykh b66874f
Preserving function call request argument deserialization exception t…
SergeyMenshykh d015196
ClientCore refactored not to add funciton calls and function results …
SergeyMenshykh f9aed8d
Changes of the OpenAIChatMessageContent class are rolled back because…
SergeyMenshykh 4bdf395
1. More optimal deduplication mechanism for function call requests ad…
SergeyMenshykh e53dd29
To convenience methods `FunctionCallResultContent.ToChatMessage` and …
SergeyMenshykh 4dbdb2f
Merge with latest main
SergeyMenshykh b3d3518
Fix for test coverage and ignoring serialization of null properties
SergeyMenshykh 1a29be6
Merge branch 'main' into function-call-content-types
SergeyMenshykh a128df2
Merge branch 'main' into function-call-content-types
crickman c179a6f
Simulated function example added + integration tests updated to use n…
SergeyMenshykh 642f4f0
Merge branch 'function-call-content-types' of https://github.com/Serg…
SergeyMenshykh 2e9efa9
Update dotnet/src/SemanticKernel.UnitTests/Utilities/FunctionNameTest…
SergeyMenshykh cd607bc
Update dotnet/src/SemanticKernel.UnitTests/Contents/FunctionCallResul…
SergeyMenshykh db1b353
Update dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompleti…
SergeyMenshykh 2c4e482
Update dotnet/src/Connectors/Connectors.OpenAI/AzureSdk/ClientCore.cs
SergeyMenshykh 29b8d41
Update dotnet/src/Connectors/Connectors.UnitTests/OpenAI/ChatCompleti…
SergeyMenshykh e724c98
Merge with latest main.
SergeyMenshykh 69a8437
Fix to support non-string funciton arguments in additiojn to string o…
SergeyMenshykh 43f1976
Merge branch 'main' into function-call-content-types
SergeyMenshykh f5ab032
POC with polymorphic deserialization of tool behaviors and function c…
SergeyMenshykh ac7bec9
POC for polymorphic deserialization of tool behaviors and function ca…
SergeyMenshykh 0c088d8
Old example removed
SergeyMenshykh 09feb8d
ConfigureFunctionCallingOptions method moved down to simplify review
SergeyMenshykh ebabb7e
renaming
SergeyMenshykh 15e98e3
Solution item name change
SergeyMenshykh 78c59ff
Breaking glass scenario is desabled
SergeyMenshykh fb39b44
The PromptExecutionSettings.ToolBehaviors property has been renamed t…
SergeyMenshykh 7cbaaf5
fix: remove function call behavior and use function call choice instead
SergeyMenshykh afaf066
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 3188795
cleanup
SergeyMenshykh 47da286
fix: Use the 'type' discriminator for polymorphic deserialization fro…
SergeyMenshykh 7cd1685
small improvments
SergeyMenshykh 7beccc0
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 6698219
* Add XML comments to classes and their members.
SergeyMenshykh 90cc4ea
Merge with latest main
SergeyMenshykh 827e50f
* Rename Alias const to TypeDiscriminator
SergeyMenshykh 348ecde
* GetConfiguration methods refactored to handle all cases
SergeyMenshykh fa5525e
a few small fixes
SergeyMenshykh 019f418
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 399f0a3
small fixes + first portion of unit tests
SergeyMenshykh 96465da
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh b6b5b03
fix: Address PR feedback
SergeyMenshykh e3e82b8
fix: improve exception message
SergeyMenshykh 58a5cb5
* Add tests for auto/required/none function choice behaviors
SergeyMenshykh 581765f
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 79b068a
fix: add tests to check that non-kernel funcitions can be used for ma…
SergeyMenshykh 13a5515
Add unit tests for {Azure}OpenAI chat completion services.
SergeyMenshykh 3ef3816
Merge with latest main
SergeyMenshykh c9ca569
fix merge issues
SergeyMenshykh af08e8b
provide reason for function check in auto-invocation mode.
SergeyMenshykh bc146a8
1. Initialize Functions collection by functions supplied via construc…
SergeyMenshykh 04005b7
fix compilation warnings
SergeyMenshykh 6fe921f
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh b986dfe
add unit tests for yaml and json converters
SergeyMenshykh f61f00d
1. Add function choice to function choice behavior config
SergeyMenshykh 81d459f
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh f280a7e
add support for functions to the none funciton choice behavior
SergeyMenshykh e85dfe4
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh a514842
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 4b5148b
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh e6e6009
remove MaximumAutoInvokeAttempts and MaximumUseAttempts properties fr…
SergeyMenshykh 4181b82
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 19bda55
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 73e5bc5
remove FunctionChoiceBehaviorConfiguration.MaximumAutoInvokeAttempts …
SergeyMenshykh 025d893
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 4284e26
remove FunctionChoiceBehaviorConfiguration.MaximumUseAttempts property
SergeyMenshykh 5a25659
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh c3b8f18
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 5e7eebb
Merge with latest
SergeyMenshykh a2d2bd3
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 2bbfaf1
fix formatting warning
SergeyMenshykh 3e21fc5
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 2e04fcd
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh a3527d7
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 162a948
Update dotnet/src/SemanticKernel.Abstractions/AI/FunctionChoiceBehavi…
SergeyMenshykh 63619a8
address PR comments
SergeyMenshykh d59bf15
merge with latest
SergeyMenshykh 0eb5cd9
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 960176b
fix: put more detailed failure response to code comment.
SergeyMenshykh b3fc4db
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 21e2f49
fix: remove the "FunctionChoice" suffix from the `FunctionChoiceBehav…
SergeyMenshykh 1f13f35
fix: address PR comments
SergeyMenshykh b4fc6ed
Revert "fix: address PR comments"
SergeyMenshykh 9e433dd
fix: restrict constraining extensibility of choice behavior-related c…
SergeyMenshykh c9af87d
Merge with latest main
SergeyMenshykh 058895a
fix: fix compilation warnings
SergeyMenshykh d1af7ff
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh a0de345
fix: address PR comments
SergeyMenshykh 7df6570
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh b90d1a1
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh abed585
fix: IDE0005 formatting issue
SergeyMenshykh c629d70
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 955777b
Update dotnet/src/SemanticKernel.Abstractions/AI/FunctionChoiceBehavi…
SergeyMenshykh 85a4fce
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 12df1e0
fix: fix compilation warning
SergeyMenshykh 41448b5
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 4d748b9
fix: restoring lost logic in OpenAI connector to disable function cal…
SergeyMenshykh 25309ba
Merge remote-tracking branch 'origin/main' into function-calling-abst…
SergeyMenshykh 7530cef
fix: fix unit test and samples
SergeyMenshykh 4d89a50
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh 1801926
feat: add options to funciton choice behavior classes to supply diffe…
SergeyMenshykh 138db30
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh e892848
fix: remove duplication of function resolution functionality.
SergeyMenshykh 6cad710
Merge branch 'function-calling-abstraction-poc' of https://github.com…
SergeyMenshykh 2680bb6
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh a3f11ee
Mergewith lates main
SergeyMenshykh 1c60fbb
Merge branch 'main' into function-calling-abstraction-poc
SergeyMenshykh a72ee47
fix: remove the [Experimental("SKEXP0001")] tag from all ne funciton …
SergeyMenshykh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
194 changes: 140 additions & 54 deletions
194
dotnet/src/Connectors/Connectors.OpenAI/AzureSdk/ClientCore.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
43 changes: 0 additions & 43 deletions
43
dotnet/src/Functions/Functions.Yaml/PromptExecutionSettingsNodeDeserializer.cs
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
dotnet/src/Functions/Functions.Yaml/PromptExecutionSettingsTypeConverter.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using YamlDotNet.Core; | ||
using YamlDotNet.Core.Events; | ||
using YamlDotNet.Serialization; | ||
using YamlDotNet.Serialization.NamingConventions; | ||
|
||
namespace Microsoft.SemanticKernel; | ||
|
||
/// <summary> | ||
/// Allows custom deserialization for <see cref="PromptExecutionSettings"/> from YAML prompts. | ||
/// </summary> | ||
internal sealed class PromptExecutionSettingsTypeConverter : IYamlTypeConverter | ||
{ | ||
private static IDeserializer? s_deserializer; | ||
|
||
/// <inheritdoc/> | ||
public bool Accepts(Type type) | ||
{ | ||
return type == typeof(PromptExecutionSettings); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public object? ReadYaml(IParser parser, Type type) | ||
{ | ||
s_deserializer ??= new DeserializerBuilder() | ||
.WithNamingConvention(UnderscoredNamingConvention.Instance) | ||
.IgnoreUnmatchedProperties() // Required to ignore the 'type' property used as type discrimination in the WithTypeDiscriminatingNodeDeserializer method below. | ||
// Otherwise, the "Property '{name}' not found on type '{type.FullName}'" exception is thrown. | ||
.WithTypeDiscriminatingNodeDeserializer((options) => | ||
{ | ||
#pragma warning disable SKEXP0001 | ||
options.AddKeyValueTypeDiscriminator<FunctionChoiceBehavior>("type", new Dictionary<string, Type> | ||
{ | ||
{ AutoFunctionChoiceBehavior.TypeDiscriminator, typeof(AutoFunctionChoiceBehavior) }, | ||
{ RequiredFunctionChoiceBehavior.TypeDiscriminator, typeof(RequiredFunctionChoiceBehavior) }, | ||
{ NoneFunctionChoiceBehavior.TypeDiscriminator, typeof(NoneFunctionChoiceBehavior) } | ||
}); | ||
#pragma warning restore SKEXP0010 | ||
}) | ||
.Build(); | ||
|
||
parser.MoveNext(); // Move to the first property | ||
|
||
var executionSettings = new PromptExecutionSettings(); | ||
while (parser.Current is not MappingEnd) | ||
{ | ||
var propertyName = parser.Consume<Scalar>().Value; | ||
switch (propertyName) | ||
{ | ||
case "model_id": | ||
executionSettings.ModelId = s_deserializer.Deserialize<string>(parser); | ||
break; | ||
case "function_choice_behavior": | ||
executionSettings.FunctionChoiceBehavior = s_deserializer.Deserialize<FunctionChoiceBehavior>(parser); | ||
break; | ||
default: | ||
(executionSettings.ExtensionData ??= new Dictionary<string, object>()).Add(propertyName, s_deserializer.Deserialize<object>(parser)); | ||
break; | ||
} | ||
} | ||
parser.MoveNext(); // Move past the MappingEnd event | ||
return executionSettings; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void WriteYaml(IEmitter emitter, object? value, Type type) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.