Skip to content

Commit b45637a

Browse files
Merge branch 'main' into feature-itextsearch-alignment
2 parents d46004b + 02d52ea commit b45637a

File tree

897 files changed

+25026
-20615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

897 files changed

+25026
-20615
lines changed

docs/decisions/0067-hybrid-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Each DB has different keyword search capabilities. Some only support a very basi
8181

8282
|Feature|Azure AI Search|Weaviate|PostgreSql|Qdrant|Elasticsearch|CosmosDB NoSql|MongoDB|
8383
|-|-|-|-|-|-|-|-|
84-
|<p>string[] keyword</p><p>One word per element</p><p>Any matching word boosts ranking.</p>|Y|Y (have to join with spaces)|[Y (have to join with spaces)](https://www.postgresql.org/docs/current/textsearch-controls.html)|Y (via filter with multiple OR'd matches)|Y|Y|[Y (have to join with spaces)](https://www.mongodb.com/docs/drivers/node/current/fundamentals/crud/read-operations/text/)|
84+
|<p>string[] keyword</p><p>One word per element</p><p>Any matching word boosts ranking.</p>|Y|Y (have to join with spaces)|[Y (have to join with spaces)](https://www.postgresql.org/docs/current/textsearch-controls.html)|Y (via filter with multiple OR'd matches)|Y|Y|[Y (have to join with spaces)](https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.find_one)|
8585
|<p>string[] keyword</p><p>One or more words per element</p><p>All words in a single element have to be present to boost the ranking.</p>|Y|N|Y|Y (via filter with multiple OR'd matches and FTS Index)|-|N|N|
8686
|<p>string[] keyword</p><p>One or more words per element</p><p>Multiple words in a single element is a phrase that must match exactly to boost the ranking.</p>|Y|N|Y|Only via filter with multiple OR'd matches and NO Index|-|N|Y|
8787
|<p>string keyword</p><p>Space separated words</p><p>Any matching word boosts ranking.</p>|Y|Y|Y|N (would need to split words)|-|N (would need to split words)|Y|

dotnet/Directory.Packages.props

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<PackageVersion Include="Grpc.AspNetCore.Server.Reflection" Version="2.70.0" />
3636
<PackageVersion Include="Grpc.AspNetCore.Web" Version="2.70.0" />
3737
<PackageVersion Include="Grpc.Tools" Version="2.71.0" />
38-
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.11" />
38+
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.12" />
3939
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13" />
4040
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.14" />
4141
<PackageVersion Include="Microsoft.ML.Tokenizers.Data.Cl100kBase" Version="1.0.1" />
@@ -87,16 +87,17 @@
8787
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
8888
<PackageVersion Include="System.Numerics.Tensors" Version="9.0.0" />
8989
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
90+
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
9091
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
9192
<!-- Tokenizers -->
9293
<PackageVersion Include="Microsoft.ML.Tokenizers" Version="1.0.1" />
9394
<PackageVersion Include="Microsoft.DeepDev.TokenizerLib" Version="1.3.3" />
9495
<PackageVersion Include="SharpToken" Version="2.0.3" />
9596
<!-- Microsoft.Extensions.* -->
96-
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.4.0-preview.1.25207.5" />
97-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.4.0-preview.1.25207.5" />
98-
<PackageVersion Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.4.0-preview.1.25207.5" />
99-
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.0-preview.1.25207.5" />
97+
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.4.3-preview.1.25230.7" />
98+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.4.3-preview.1.25230.7" />
99+
<PackageVersion Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.4.3-preview.1.25230.7" />
100+
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.3-preview.1.25230.7" />
100101
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
101102
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
102103
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />

dotnet/SK-dotnet.sln

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{958AD708-F04
107107
EndProject
108108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Diagnostics", "Diagnostics", "{29E7D971-1308-4171-9872-E8E4669A1134}"
109109
ProjectSection(SolutionItems) = preProject
110+
src\InternalUtilities\src\Diagnostics\ActivityExtensions.cs = src\InternalUtilities\src\Diagnostics\ActivityExtensions.cs
110111
src\InternalUtilities\src\Diagnostics\CompilerServicesAttributes.cs = src\InternalUtilities\src\Diagnostics\CompilerServicesAttributes.cs
111112
src\InternalUtilities\src\Diagnostics\DynamicallyAccessedMembersAttribute.cs = src\InternalUtilities\src\Diagnostics\DynamicallyAccessedMembersAttribute.cs
112113
src\InternalUtilities\src\Diagnostics\ExceptionExtensions.cs = src\InternalUtilities\src\Diagnostics\ExceptionExtensions.cs
113114
src\InternalUtilities\src\Diagnostics\ExperimentalAttribute.cs = src\InternalUtilities\src\Diagnostics\ExperimentalAttribute.cs
114115
src\InternalUtilities\src\Diagnostics\IsExternalInit.cs = src\InternalUtilities\src\Diagnostics\IsExternalInit.cs
116+
src\InternalUtilities\src\Diagnostics\KernelVerify.cs = src\InternalUtilities\src\Diagnostics\KernelVerify.cs
117+
src\InternalUtilities\src\Diagnostics\LoggingExtensions.cs = src\InternalUtilities\src\Diagnostics\LoggingExtensions.cs
115118
src\InternalUtilities\src\Diagnostics\NullableAttributes.cs = src\InternalUtilities\src\Diagnostics\NullableAttributes.cs
116119
src\InternalUtilities\src\Diagnostics\RequiresDynamicCodeAttribute.cs = src\InternalUtilities\src\Diagnostics\RequiresDynamicCodeAttribute.cs
117120
src\InternalUtilities\src\Diagnostics\RequiresUnreferencedCodeAttribute.cs = src\InternalUtilities\src\Diagnostics\RequiresUnreferencedCodeAttribute.cs
@@ -537,15 +540,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runtime", "Runtime", "{A70E
537540
EndProject
538541
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Abstractions", "src\Agents\Runtime\Abstractions\Runtime.Abstractions.csproj", "{B9C86C5D-EB4C-8A16-E567-27025AC59A28}"
539542
EndProject
540-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Abstractions.Tests", "src\Agents\Runtime\Abstractions.Tests\Runtime.Abstractions.Tests.csproj", "{BB74EEE2-F048-A1A4-F53E-2B384A6F8BC4}"
543+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Abstractions.UnitTests", "src\Agents\Runtime\Abstractions.Tests\Runtime.Abstractions.UnitTests.csproj", "{BB74EEE2-F048-A1A4-F53E-2B384A6F8BC4}"
541544
EndProject
542545
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Core", "src\Agents\Runtime\Core\Runtime.Core.csproj", "{19DC60E6-AD08-4BCB-A4DF-B80E0941B458}"
543546
EndProject
544-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Core.Tests", "src\Agents\Runtime\Core.Tests\Runtime.Core.Tests.csproj", "{A4F05541-7D23-A5A9-033D-382F1E13D0FE}"
547+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Core.UnitTests", "src\Agents\Runtime\Core.Tests\Runtime.Core.UnitTests.csproj", "{A4F05541-7D23-A5A9-033D-382F1E13D0FE}"
545548
EndProject
546549
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.InProcess", "src\Agents\Runtime\InProcess\Runtime.InProcess.csproj", "{CCC909E4-5269-A31E-0BFD-4863B4B29BBB}"
547550
EndProject
548-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.InProcess.Tests", "src\Agents\Runtime\InProcess.Tests\Runtime.InProcess.Tests.csproj", "{DA6B4ED4-ED0B-D25C-889C-9F940E714891}"
551+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.InProcess.UnitTests", "src\Agents\Runtime\InProcess.Tests\Runtime.InProcess.UnitTests.csproj", "{DA6B4ED4-ED0B-D25C-889C-9F940E714891}"
552+
EndProject
553+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorData.UnitTests", "src\Connectors\VectorData.UnitTests\VectorData.UnitTests.csproj", "{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}"
549554
EndProject
550555
Global
551556
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -1508,6 +1513,12 @@ Global
15081513
{DA6B4ED4-ED0B-D25C-889C-9F940E714891}.Publish|Any CPU.Build.0 = Release|Any CPU
15091514
{DA6B4ED4-ED0B-D25C-889C-9F940E714891}.Release|Any CPU.ActiveCfg = Release|Any CPU
15101515
{DA6B4ED4-ED0B-D25C-889C-9F940E714891}.Release|Any CPU.Build.0 = Release|Any CPU
1516+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1517+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Debug|Any CPU.Build.0 = Debug|Any CPU
1518+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
1519+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Publish|Any CPU.Build.0 = Debug|Any CPU
1520+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Release|Any CPU.ActiveCfg = Release|Any CPU
1521+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84}.Release|Any CPU.Build.0 = Release|Any CPU
15111522
EndGlobalSection
15121523
GlobalSection(SolutionProperties) = preSolution
15131524
HideSolutionNode = FALSE
@@ -1713,6 +1724,7 @@ Global
17131724
{A4F05541-7D23-A5A9-033D-382F1E13D0FE} = {A70ED5A7-F8E1-4A57-9455-3C05989542DA}
17141725
{CCC909E4-5269-A31E-0BFD-4863B4B29BBB} = {A70ED5A7-F8E1-4A57-9455-3C05989542DA}
17151726
{DA6B4ED4-ED0B-D25C-889C-9F940E714891} = {A70ED5A7-F8E1-4A57-9455-3C05989542DA}
1727+
{AAC7B5E8-CC4E-49D0-AF6A-2B4F7B43BD84} = {5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}
17161728
EndGlobalSection
17171729
GlobalSection(ExtensibilityGlobals) = postSolution
17181730
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}

dotnet/docs/EXPERIMENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ You can use the following diagnostic IDs to ignore warnings or errors for a part
2525
| SKEXP0100 | Advanced Semantic Kernel features |
2626
| SKEXP0110 | Semantic Kernel Agents |
2727
| SKEXP0120 | Native-AOT |
28+
| MEVD9000 | Microsoft.Extensions.VectorData experimental user-facing APIs |
29+
| MEVD9001 | Microsoft.Extensions.VectorData experimental connector-facing APIs |
2830

2931
## Experimental Features Tracking
3032

dotnet/nuget/nuget-package.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project>
22
<PropertyGroup>
33
<!-- Central version prefix - applies to all nuget packages. -->
4-
<VersionPrefix>1.47.0</VersionPrefix>
4+
<VersionPrefix>1.48.0</VersionPrefix>
55
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
66
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>
77

88
<Configurations>Debug;Release;Publish</Configurations>
99
<IsPackable>true</IsPackable>
1010

1111
<!-- Package validation. Baseline Version should be the latest version available on NuGet. -->
12-
<PackageValidationBaselineVersion>1.46.0</PackageValidationBaselineVersion>
12+
<PackageValidationBaselineVersion>1.47.0</PackageValidationBaselineVersion>
1313
<!-- Validate assembly attributes only for Publish builds -->
1414
<NoWarn Condition="'$(Configuration)' != 'Publish'">$(NoWarn);CP0003</NoWarn>
1515
<!-- Do not validate reference assemblies -->

dotnet/samples/Concepts/Caching/SemanticCachingWithFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ public async Task OnPromptRenderAsync(PromptRenderContext context, Func<PromptRe
199199
await collection.CreateCollectionIfNotExistsAsync();
200200

201201
// Search for similar prompts in cache.
202-
var searchResults = await collection.VectorizedSearchAsync(promptEmbedding, new() { Top = 1 }, context.CancellationToken);
203-
var searchResult = (await searchResults.Results.FirstOrDefaultAsync())?.Record;
202+
var searchResult = (await collection.SearchEmbeddingAsync(promptEmbedding, top: 1, cancellationToken: context.CancellationToken)
203+
.FirstOrDefaultAsync())?.Record;
204204

205205
// If result exists, return it.
206206
if (searchResult is not null)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using Microsoft.SemanticKernel;
4+
using Microsoft.SemanticKernel.ChatCompletion;
5+
using Resources;
6+
7+
namespace ChatCompletion;
8+
9+
/// <summary>
10+
/// This example shows how to use binary files input with OpenAI's chat completion.
11+
/// </summary>
12+
public class OpenAI_ChatCompletionWithFile(ITestOutputHelper output) : BaseTest(output)
13+
{
14+
/// <summary>
15+
/// This uses a local file as input for your chat
16+
/// </summary>
17+
[Fact]
18+
public async Task UsingLocalFileInChatCompletion()
19+
{
20+
var fileBytes = await EmbeddedResource.ReadAllAsync("employees.pdf");
21+
22+
var kernel = Kernel.CreateBuilder()
23+
.AddOpenAIChatCompletion(TestConfiguration.OpenAI.ChatModelId, TestConfiguration.OpenAI.ApiKey)
24+
.Build();
25+
26+
var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
27+
28+
var chatHistory = new ChatHistory("You are a friendly assistant.");
29+
30+
chatHistory.AddUserMessage(
31+
[
32+
new TextContent("What's in this file?"),
33+
new BinaryContent(fileBytes, "application/pdf")
34+
]);
35+
36+
var reply = await chatCompletionService.GetChatMessageContentAsync(chatHistory);
37+
38+
Console.WriteLine(reply.Content);
39+
}
40+
41+
/// <summary>
42+
/// This uses a Base64 data URI as a binary file input for your chat
43+
/// </summary>
44+
[Fact]
45+
public async Task UsingBase64DataUriInChatCompletion()
46+
{
47+
var fileBytes = await EmbeddedResource.ReadAllAsync("employees.pdf");
48+
var fileBase64 = Convert.ToBase64String(fileBytes.ToArray());
49+
var dataUri = $"data:application/pdf;base64,{fileBase64}";
50+
51+
var kernel = Kernel.CreateBuilder()
52+
.AddOpenAIChatCompletion(TestConfiguration.OpenAI.ChatModelId, TestConfiguration.OpenAI.ApiKey)
53+
.Build();
54+
55+
var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
56+
57+
var chatHistory = new ChatHistory("You are a friendly assistant.");
58+
59+
chatHistory.AddUserMessage(
60+
[
61+
new TextContent("What's in this file?"),
62+
new BinaryContent(dataUri)
63+
]);
64+
65+
var reply = await chatCompletionService.GetChatMessageContentAsync(chatHistory);
66+
67+
Console.WriteLine(reply.Content);
68+
}
69+
}

dotnet/samples/Concepts/Concepts.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<IsPackable>false</IsPackable>
99
<IsTestProject>true</IsTestProject>
1010
<!-- Suppress: "Declare types in namespaces", "Require ConfigureAwait", "Experimental" -->
11-
<NoWarn>$(NoWarn);CS8618,IDE0009,IDE1006,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0020,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110,OPENAI001,CA1724</NoWarn>
11+
<NoWarn>$(NoWarn);CS8618,IDE0009,IDE1006,CA1051,CA1050,CA1707,CA1054,CA2007,VSTHRD111,CS1591,RCS1110,RCS1243,CA5394,SKEXP0001,SKEXP0010,SKEXP0040,SKEXP0050,SKEXP0060,SKEXP0070,SKEXP0101,SKEXP0110,OPENAI001,CA1724,MEVD9000</NoWarn>
1212
<OutputType>Library</OutputType>
1313
<UserSecretsId>5ee045b0-aea3-4f08-8d31-32d1a6f8fed0</UserSecretsId>
1414
</PropertyGroup>

dotnet/samples/Concepts/FunctionCalling/Gemini_FunctionCalling.cs

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3+
using System.ComponentModel;
34
using Microsoft.SemanticKernel;
45
using Microsoft.SemanticKernel.ChatCompletion;
56
using Microsoft.SemanticKernel.Connectors.Google;
@@ -10,7 +11,7 @@ namespace FunctionCalling;
1011
/// <summary>
1112
/// These examples demonstrate two ways functions called by the Gemini LLM can be invoked using the SK streaming and non-streaming AI API:
1213
///
13-
/// 1. Automatic Invocation by SK:
14+
/// 1. Automatic Invocation by SK (with and without nullable properties):
1415
/// Functions called by the LLM are invoked automatically by SK. The results of these function invocations
1516
/// are automatically added to the chat history and returned to the LLM. The LLM reasons about the chat history
1617
/// and generates the final response.
@@ -86,6 +87,92 @@ public async Task VertexAIChatCompletionWithFunctionCalling()
8687
await this.RunSampleAsync(kernel);
8788
}
8889

90+
[RetryFact]
91+
public async Task GoogleAIFunctionCallingNullable()
92+
{
93+
Console.WriteLine("============= Google AI - Gemini Chat Completion with function calling (nullable properties) =============");
94+
95+
Assert.NotNull(TestConfiguration.GoogleAI.ApiKey);
96+
97+
var kernelBuilder = Kernel.CreateBuilder()
98+
.AddGoogleAIGeminiChatCompletion(
99+
modelId: TestConfiguration.VertexAI.Gemini.ModelId,
100+
apiKey: TestConfiguration.GoogleAI.ApiKey);
101+
102+
kernelBuilder.Plugins.AddFromType<MyWeatherPlugin>();
103+
104+
var promptExecutionSettings = new GeminiPromptExecutionSettings()
105+
{
106+
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),
107+
};
108+
109+
var kernel = kernelBuilder.Build();
110+
111+
var response = await kernel.InvokePromptAsync("Hi, what's the weather in New York?", new(promptExecutionSettings));
112+
113+
Console.WriteLine(response.ToString());
114+
}
115+
116+
private sealed class MyWeatherPlugin
117+
{
118+
[KernelFunction]
119+
[Description("Get the weather for a given location.")]
120+
private string GetWeather(WeatherRequest request)
121+
{
122+
return $"The weather in {request?.Location} is sunny.";
123+
}
124+
}
125+
126+
[RetryFact]
127+
public async Task VertexAIFunctionCallingNullable()
128+
{
129+
Console.WriteLine("============= Vertex AI - Gemini Chat Completion with function calling (nullable properties) =============");
130+
131+
Assert.NotNull(TestConfiguration.VertexAI.BearerKey);
132+
Assert.NotNull(TestConfiguration.VertexAI.Location);
133+
Assert.NotNull(TestConfiguration.VertexAI.ProjectId);
134+
135+
var kernelBuilder = Kernel.CreateBuilder()
136+
.AddVertexAIGeminiChatCompletion(
137+
modelId: TestConfiguration.VertexAI.Gemini.ModelId,
138+
bearerKey: TestConfiguration.VertexAI.BearerKey,
139+
location: TestConfiguration.VertexAI.Location,
140+
projectId: TestConfiguration.VertexAI.ProjectId);
141+
142+
// To generate bearer key, you need installed google sdk or use Google web console with command:
143+
//
144+
// gcloud auth print-access-token
145+
//
146+
// Above code pass bearer key as string, it is not recommended way in production code,
147+
// especially if IChatCompletionService will be long-lived, tokens generated by google sdk lives for 1 hour.
148+
// You should use bearer key provider, which will be used to generate token on demand:
149+
//
150+
// Example:
151+
//
152+
// Kernel kernel = Kernel.CreateBuilder()
153+
// .AddVertexAIGeminiChatCompletion(
154+
// modelId: TestConfiguration.VertexAI.Gemini.ModelId,
155+
// bearerKeyProvider: () =>
156+
// {
157+
// // This is just example, in production we recommend using Google SDK to generate your BearerKey token.
158+
// // This delegate will be called on every request,
159+
// // when providing the token consider using caching strategy and refresh token logic when it is expired or close to expiration.
160+
// return GetBearerKey();
161+
// },
162+
// location: TestConfiguration.VertexAI.Location,
163+
// projectId: TestConfiguration.VertexAI.ProjectId);
164+
165+
kernelBuilder.Plugins.AddFromType<MyWeatherPlugin>();
166+
167+
var promptExecutionSettings = new GeminiPromptExecutionSettings()
168+
{
169+
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),
170+
};
171+
var kernel = kernelBuilder.Build();
172+
var response = await kernel.InvokePromptAsync("Hi, what's the weather in New York?", new(promptExecutionSettings));
173+
Console.WriteLine(response.ToString());
174+
}
175+
89176
private async Task RunSampleAsync(Kernel kernel)
90177
{
91178
// Add a plugin with some helper functions we want to allow the model to utilize.
@@ -214,4 +301,9 @@ private async Task RunSampleAsync(Kernel kernel)
214301
}
215302
*/
216303
}
304+
305+
private sealed class WeatherRequest
306+
{
307+
public string? Location { get; set; }
308+
}
217309
}

dotnet/samples/Concepts/Memory/HuggingFace_TextEmbeddingCustomHttpHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Memory;
1515
/// For example, the <a href="https://huggingface.co/cointegrated/LaBSE-en-ru">cointegrated/LaBSE-en-ru</a> model returns results as a 1 * 1 * 4 * 768 matrix, which is different from Hugging Face embedding generation service implementation.
1616
/// To address this, a custom <see cref="HttpClientHandler"/> can be used to modify the response before sending it back.
1717
/// </summary>
18+
[Obsolete("The IMemoryStore abstraction is being obsoleted")]
1819
public class HuggingFace_TextEmbeddingCustomHttpHandler(ITestOutputHelper output) : BaseTest(output)
1920
{
2021
public async Task RunInferenceApiEmbeddingCustomHttpHandlerAsync()

0 commit comments

Comments
 (0)