-
Notifications
You must be signed in to change notification settings - Fork 4k
.Net: Contextual function provider #12254
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
.Net: Contextual function provider #12254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a contextual function selection capability by vectorizing available functions and retrieving only those relevant to the current chat context.
- Introduces
FunctionStore
and its options to index and search functions via a vector store - Adds
ContextualFunctionProvider
and corresponding options to plug into chat-based agents - Updates sample project to demonstrate usage and adds a new ModelContextProtocol dependency
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStoreOptions.cs | Defines options for function vectorization and retrieval |
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs | Implements vector store indexing and search logic |
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/ContextualFunctionProviderOptions.cs | Defines public options for the contextual provider |
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/ContextualFunctionProvider.cs | Wraps FunctionStore to provide an AI context with relevant functions |
dotnet/samples/Concepts/Concepts.csproj | Adds ModelContextProtocol package reference |
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs | Sample showing how to wire up the contextual provider |
Comments suppressed due to low confidence (1)
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs:38
- [nitpick] The agent name uses
GithubAssistant
; update it toGitHubAssistant
to match correct casing of the GitHub brand.
Name = "GithubAssistant",
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStoreOptions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStoreOptions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
…unctionStore.cs Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
…/microsoft/semantic-kernel into add-contextual-function-provider
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/ContextualFunctionProvider.cs
Outdated
Show resolved
Hide resolved
…ontextualFunctionProvider.cs Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/ContextualFunctionProvider.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs
Show resolved
Hide resolved
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStore.cs
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Core/Functions/ContextualSelection/FunctionStoreOptions.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Agents/ChatCompletion_ContextualFunctionSelection.cs
Outdated
Show resolved
Hide resolved
...t/src/SemanticKernel.Core/Functions/ContextualSelection/ContextualFunctionProviderOptions.cs
Outdated
Show resolved
Hide resolved
9c91a7e
into
contextual-function-selection
Motivation, Context, and Description
This PR adds functionality that allows AI agents to advertise functions relevant to the current context, rather than advertising all available functions.
The functionality is implemented by two components:
FunctionStore
class is responsible for the vectorization of functions, upserting them into the provided vector store, and performing vector searches. This class is internal at the moment as it's used only by theContextualFunctionProvider
class. Later, it might be promoted to public if required.ContextualFunctionProvider
class delegates function vectorization and persistence to theFunctionStore
. It vectorizes the current context and delegates the vector search to theFunctionStore
class again.Logging will be added in follow-up PRs.
Contributes to: #10074