Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions samples/cs/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>

<!-- Align RuntimeIdentifier with the selected Platform on Windows so PlatformTarget
(derived from $(Platform)) and RID don't conflict (NETSDK1032).
Note: $(NETCoreSdkRuntimeIdentifier) is intentionally NOT used here because
Directory.Build.props is evaluated before Sdk.props initializes that property.
Instead, use static OS architecture detection which is always available. -->
<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier Condition="$([MSBuild]::IsOSPlatform('Windows')) And '$(Platform)'=='ARM64'">win-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::IsOSPlatform('Windows')) And '$(Platform)'=='x64'">win-x64</RuntimeIdentifier>
<!-- When Platform is not explicitly set, infer the RID from the OS architecture -->
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)'=='' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)'=='' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</RuntimeIdentifier>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/cs/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<PackageVersion Include="Microsoft.AI.Foundry.Local" Version="*-*" />
<PackageVersion Include="Microsoft.AI.Foundry.Local.WinML" Version="*-*" />
<PackageVersion Include="Betalgo.Ranul.OpenAI" Version="9.2.0" />
<PackageVersion Include="Betalgo.Ranul.OpenAI" Version="9.1.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.15" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.15" />
<PackageVersion Include="NAudio" Version="2.2.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
4 changes: 0 additions & 4 deletions samples/cs/embeddings/Embeddings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
4 changes: 0 additions & 4 deletions samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
4 changes: 0 additions & 4 deletions samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)'==''">
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<!-- Windows: WinML for hardware acceleration -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<PackageReference Include="Microsoft.AI.Foundry.Local.WinML" />
Expand Down
10 changes: 10 additions & 0 deletions sdk_v2/cs/test/FoundryLocal.Tests/ChatSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ internal sealed class ChatSessionTests
{
private static IModel? model;

// Greedy decoding for content-asserting tests so the small (0.5B) model produces a
// stable response across runs. Mirrors the C++ ChatSessionTest fixture.
private static RequestOptions DeterministicOptions(int maxTokens) =>
new() { Search = new SearchOptions { Temperature = 0f, MaxOutputTokens = maxTokens } };

[Before(Class)]
public static async Task Setup()
{
Expand All @@ -41,6 +46,7 @@ public async Task Chat_NoStreaming_Succeeds()

using var request = new Request();
request.AddItem(MessageItem.User("You are a calculator. Be precise. What is the answer to 7 multiplied by 6?"));
request.SetOptions(DeterministicOptions(maxTokens: 32));

using var response = await session.ProcessRequestAsync(request).ConfigureAwait(false);

Expand Down Expand Up @@ -80,6 +86,7 @@ public async Task Chat_Streaming_Succeeds()
// reorder; requiring a subset stays robust.
using var request = new Request();
request.AddItem(MessageItem.User("Name the countries in the United Kingdom."));
request.SetOptions(DeterministicOptions(maxTokens: 128));

var sb = new StringBuilder();
int itemCount = 0;
Expand Down Expand Up @@ -113,6 +120,7 @@ public async Task Chat_Streaming_Succeeds()
// content check.
using var request2 = new Request();
request2.AddItem(MessageItem.User("What is the capital of each?"));
request2.SetOptions(DeterministicOptions(maxTokens: 128));

var sb2 = new StringBuilder();
int itemCount2 = 0;
Expand Down Expand Up @@ -149,6 +157,7 @@ public async Task Chat_MultiTurn_Succeeds()
// First turn
using var request1 = new Request();
request1.AddItem(MessageItem.User("You are a calculator. Be precise. What is the answer to 7 multiplied by 6?"));
request1.SetOptions(DeterministicOptions(maxTokens: 32));

using var response1 = await session.ProcessRequestAsync(request1).ConfigureAwait(false);

Expand Down Expand Up @@ -178,6 +187,7 @@ public async Task Chat_MultiTurn_Succeeds()
request2.AddItem(MessageItem.User("You are a calculator. Be precise. What is the answer to 7 multiplied by 6?"));
request2.AddItem(MessageItem.Assistant(firstContent!));
request2.AddItem(MessageItem.User("Is the answer a real number?"));
request2.SetOptions(DeterministicOptions(maxTokens: 64));

using var response2 = await session.ProcessRequestAsync(request2).ConfigureAwait(false);

Expand Down