Skip to content

Commit 5b32dc1

Browse files
authored
Merge pull request #606 from westey-m/connector-lang-and-immutable-kernel
Update language around vectordata and add immutable kernel warning
2 parents 1b88a47 + f3499e2 commit 5b32dc1

4 files changed

Lines changed: 29 additions & 11 deletions

File tree

semantic-kernel/Frameworks/agent/agent-contextual-function-selection.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Contextual Function Selection is an advanced capability in the Semantic Kernel A
2222

2323
This approach addresses the challenge of function selection when dealing with a large number of available functions, where AI models may otherwise struggle to choose the appropriate function, leading to confusion and suboptimal performance.
2424

25+
> [!WARNING]
26+
> When using the `ContextualFunctionProvider`, the `UseImmutableKernel` setting on the agent has to be set to `true` as the feature requires cloning the kernel when invoking the agent.
27+
> Note that setting `UseImmutableKernel` to `true` will mean that any kernel data modifications done during the agent invocation by e.g. plugins, will not be retained after the invocation completes.
28+
2529
## How Contextual Function Selection Works
2630

2731
When an agent is configured with contextual function selection, it leverages a vector store and an embedding generator to semantically match the current conversation context (including previous messages and user input) with the descriptions and names of available functions. The most relevant functions, up to the specified limit, are then advertised to the AI model for invocation.
@@ -50,7 +54,9 @@ ChatCompletionAgent agent = new()
5054
Name = "ReviewGuru",
5155
Instructions = "You are a friendly assistant that summarizes key points and sentiments from customer reviews. For each response, list available functions.",
5256
Kernel = kernel,
53-
Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) })
57+
Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) }),
58+
// This setting must be set to true when using the ContextualFunctionProvider
59+
UseImmutableKernel = true
5460
};
5561

5662
// Create the agent thread and register the contextual function provider

semantic-kernel/Frameworks/agent/agent-rag.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ ChatCompletionAgent agent = new()
5757
{
5858
Name = "FriendlyAssistant",
5959
Instructions = "You are a friendly assistant",
60-
Kernel = kernel
60+
Kernel = kernel,
61+
// This setting must be set to true when using the on-demand RAG feature
62+
UseImmutableKernel = true
6163
};
6264

6365
// Create an agent thread and add the TextSearchProvider.
@@ -124,6 +126,10 @@ var options = new TextSearchProviderOptions
124126
var provider = new TextSearchProvider(mockTextSearch.Object, options: options);
125127
```
126128

129+
> [!WARNING]
130+
> When using the `TextSearchProvider` with `OnDemandFunctionCalling`, the `UseImmutableKernel` setting on the agent has to be set to `true` as the feature requires cloning the kernel when invoking the agent.
131+
> Note that setting `UseImmutableKernel` to `true` will mean that any kernel data modifications done during the agent invocation by e.g. plugins, will not be retained after the invocation completes.
132+
127133
## TextSearchProvider options
128134

129135
The `TextSearchProvider` can be configured with various options to customize its behavior. Options are provided using the `TextSearchProviderOptions` class to the `TextSearchProvider` constructor.

semantic-kernel/concepts/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
href: ai-services/TOC.yml
77
- name: Enterprise Components
88
href: enterprise-readiness/TOC.yml
9-
- name: Memory (Vector Stores)
9+
- name: Vector Stores
1010
href: vector-store-connectors/TOC.yml
1111
- name: Prompts
1212
href: prompts/TOC.yml

semantic-kernel/concepts/vector-store-connectors/index.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: What are Semantic Kernel Vector Store connectors? (Preview)
2+
title: What are Semantic Kernel Vector Stores? (Preview)
33
description: Describes what a Semantic Kernel Vector Store is, and provides a basic example of how to use one and how to get started.
44
zone_pivot_groups: programming-languages
55
author: westey-m
@@ -8,7 +8,7 @@ ms.author: westey
88
ms.date: 07/08/2024
99
ms.service: semantic-kernel
1010
---
11-
# What are Semantic Kernel Vector Store connectors? (Preview)
11+
# What are Semantic Kernel Vector Stores? (Preview)
1212

1313
::: zone pivot="programming-language-csharp"
1414

@@ -35,24 +35,30 @@ One use case for storing information in a vector database is to enable large lan
3535

3636
For example, if you want to write a blog post about the latest trends in AI, you can use a vector database to store the latest information about that topic and pass the information along with the ask to a LLM in order to generate a blog post that leverages the latest information.
3737

38-
Semantic Kernel and .net provides an abstraction for interacting with Vector Stores and a list of out-of-the-box connectors that implement these abstractions. Features include creating, listing and deleting collections of records, and uploading, retrieving and deleting records. The abstraction makes it easy to experiment with a free or locally hosted Vector Store and then switch to a service when needing to scale up.
38+
Semantic Kernel and .net provides an abstraction for interacting with Vector Stores and a list of out-of-the-box implementations that implement these abstractions for various databases. Features include creating, listing and deleting collections of records, and uploading, retrieving and deleting records. The abstraction makes it easy to experiment with a free or locally hosted Vector Store and then switch to a service when needing to scale up.
39+
40+
The out-of-the-box implementations can be used with Semantic Kernel, but do not depend on the core Semantic Kernel stack and can also therefore be used completely independently if required.
41+
The Semantic Kernel provided imlementations are referred to as 'connectors'.
3942

4043
::: zone pivot="programming-language-csharp"
4144

4245
## Retrieval Augmented Generation (RAG) with Vector Stores
4346

44-
The vector store abstractions are a low level api for adding and retrieving data from vector stores.
47+
The vector store abstraction is a low level api for adding and retrieving data from vector stores.
4548
Semantic Kernel has built-in support for using any one of the Vector Store implementations for RAG.
4649
This is achieved by wrapping `IVectorSearchable<TRecord>` and exposing it as a Text Search implementation.
4750

4851
> [!TIP]
4952
> To learn more about how to use vector stores for RAG see [How to use Vector Stores with Semantic Kernel Text Search](../text-search/text-search-vector-stores.md).
5053
> [!TIP]
5154
> To learn more about text search see [What is Semantic Kernel Text Search?](../text-search/index.md)
55+
> [!TIP]
56+
> To learn more about how to quickly add RAG into your agent see [Adding Retrieval Augmented Generation (RAG) to Semantic Kernel Agents](../../Frameworks/agent/agent-rag.md).
5257
5358
## The Vector Store Abstraction
5459

55-
The main abstract base classes and interfaces in the Vector Store abstraction are the following.
60+
The Vector Store abstractions are provided in the [`Microsoft.Extensions.VectorData.Abstractions`](https://www.nuget.org/packages/Microsoft.Extensions.VectorData.Abstractions/) nuget package.
61+
The following are the main abstract base classes and interfaces.
5662

5763
### Microsoft.Extensions.VectorData.VectorStore
5864

@@ -120,7 +126,7 @@ by select connectors.
120126

121127
::: zone-end
122128

123-
## Getting started with Vector Store connectors
129+
## Getting started with Vector Stores
124130

125131
::: zone pivot="programming-language-csharp"
126132

@@ -143,7 +149,7 @@ dotnet add package Microsoft.Extensions.VectorData.Abstractions
143149

144150
### Define your data model
145151

146-
The Semantic Kernel Vector Store connectors use a model first approach to interacting with databases. This means that the first step is to define a data model that maps to the storage schema. To help the connectors create collections of records and map to the storage schema, the model can be annotated to indicate the function of each property.
152+
The Vector Store abstractions use a model first approach to interacting with databases. This means that the first step is to define a data model that maps to the storage schema. To help the implementations create collections of records and map to the storage schema, the model can be annotated to indicate the function of each property.
147153

148154
::: zone pivot="programming-language-csharp"
149155

@@ -340,7 +346,7 @@ public class Main {
340346
::: zone-end
341347

342348
> [!TIP]
343-
> For more information on what key and field types each Vector Store connector supports, refer to [the documentation for each connector](./out-of-the-box-connectors/index.md).
349+
> For more information on what key and field types each Vector Store implementation supports, refer to [the documentation for each implementation](./out-of-the-box-connectors/index.md).
344350
345351
::: zone pivot="programming-language-csharp"
346352

0 commit comments

Comments
 (0)