Skip to content

Commit d12a331

Browse files
authored
Update OnnxRuntimeGenAIChatClient to M.E.AI.Abstractions 9.7.0 (#1612)
1 parent c1cab7a commit d12a331

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

nuget/Microsoft.ML.OnnxRuntimeGenAI.Managed.nuspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
<tags>ONNX;ONNX Runtime;ONNX Runtime Gen AI;Machine Learning</tags>
1515
<dependencies>
1616
<group targetFramework="net8.0">
17-
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.5.0" />
17+
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.7.0" />
1818
</group>
1919
<group targetFramework="netstandard2.0">
20-
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.5.0" />
20+
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.7.0" />
2121
</group>
2222
<group targetFramework="net8.0-android31.0">
23-
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.5.0" />
23+
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.7.0" />
2424
</group>
2525
<group targetFramework="net8.0-ios15.4">
26-
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.5.0" />
26+
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.7.0" />
2727
</group>
2828
<group targetFramework="net8.0-maccatalyst14.0">
29-
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.5.0" />
29+
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.7.0" />
3030
</group>
3131
</dependencies>
3232
</metadata>

src/csharp/Microsoft.ML.OnnxRuntimeGenAI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</ItemGroup>
124124

125125
<ItemGroup>
126-
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.5.0" />
126+
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.7.0" />
127127
</ItemGroup>
128128

129129
</Project>

src/csharp/OnnxRuntimeGenAIChatClient.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using Microsoft.Extensions.AI;
45
using System;
56
using System.Collections.Generic;
67
using System.Runtime.CompilerServices;
@@ -9,7 +10,6 @@
910
using System.Text.Json.Serialization;
1011
using System.Threading;
1112
using System.Threading.Tasks;
12-
using Microsoft.Extensions.AI;
1313

1414
#nullable enable
1515

@@ -276,6 +276,15 @@ private string FormatPromptDefault(IEnumerable<ChatMessage> messages, ChatOption
276276
StringBuilder prompt = new();
277277
string separator = "";
278278
prompt.Append('[');
279+
280+
if (options?.Instructions is { } instructions)
281+
{
282+
m.Role = ChatRole.System.Value;
283+
m.Content = instructions;
284+
prompt.Append(JsonSerializer.Serialize(m, OnnxJsonContext.Default.SerializableMessage));
285+
separator = ",";
286+
}
287+
279288
foreach (var message in messages)
280289
{
281290
if (message.Text is string text)
@@ -288,6 +297,7 @@ private string FormatPromptDefault(IEnumerable<ChatMessage> messages, ChatOption
288297
prompt.Append(JsonSerializer.Serialize(m, OnnxJsonContext.Default.SerializableMessage));
289298
}
290299
}
300+
291301
prompt.Append(']');
292302

293303
return _tokenizer.ApplyChatTemplate(

0 commit comments

Comments
 (0)