diff --git a/samples/cs/Directory.Build.props b/samples/cs/Directory.Build.props new file mode 100644 index 000000000..82f8d28ce --- /dev/null +++ b/samples/cs/Directory.Build.props @@ -0,0 +1,16 @@ + + + + + win-arm64 + win-x64 + + win-x64 + win-arm64 + + + diff --git a/samples/cs/Directory.Packages.props b/samples/cs/Directory.Packages.props index 77b68c4cc..431b27a82 100644 --- a/samples/cs/Directory.Packages.props +++ b/samples/cs/Directory.Packages.props @@ -6,7 +6,7 @@ - + diff --git a/samples/cs/audio-transcription-example/AudioTranscriptionExample.csproj b/samples/cs/audio-transcription-example/AudioTranscriptionExample.csproj index 4f048e152..d05b98731 100644 --- a/samples/cs/audio-transcription-example/AudioTranscriptionExample.csproj +++ b/samples/cs/audio-transcription-example/AudioTranscriptionExample.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/embeddings/Embeddings.csproj b/samples/cs/embeddings/Embeddings.csproj index 870c34acd..fc96873b9 100644 --- a/samples/cs/embeddings/Embeddings.csproj +++ b/samples/cs/embeddings/Embeddings.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/foundry-local-web-server/FoundryLocalWebServer.csproj b/samples/cs/foundry-local-web-server/FoundryLocalWebServer.csproj index a7c1a3766..89275aca3 100644 --- a/samples/cs/foundry-local-web-server/FoundryLocalWebServer.csproj +++ b/samples/cs/foundry-local-web-server/FoundryLocalWebServer.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/live-audio-transcription/LiveAudioTranscriptionExample.csproj b/samples/cs/live-audio-transcription/LiveAudioTranscriptionExample.csproj index 1a276b73d..655551d1f 100644 --- a/samples/cs/live-audio-transcription/LiveAudioTranscriptionExample.csproj +++ b/samples/cs/live-audio-transcription/LiveAudioTranscriptionExample.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/model-management-example/ModelManagementExample.csproj b/samples/cs/model-management-example/ModelManagementExample.csproj index 870c34acd..fc96873b9 100644 --- a/samples/cs/model-management-example/ModelManagementExample.csproj +++ b/samples/cs/model-management-example/ModelManagementExample.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/native-chat-completions/NativeChatCompletions.csproj b/samples/cs/native-chat-completions/NativeChatCompletions.csproj index 870c34acd..fc96873b9 100644 --- a/samples/cs/native-chat-completions/NativeChatCompletions.csproj +++ b/samples/cs/native-chat-completions/NativeChatCompletions.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tool-calling-foundry-local-sdk/ToolCallingFoundryLocalSdk.csproj b/samples/cs/tool-calling-foundry-local-sdk/ToolCallingFoundryLocalSdk.csproj index 870c34acd..fc96873b9 100644 --- a/samples/cs/tool-calling-foundry-local-sdk/ToolCallingFoundryLocalSdk.csproj +++ b/samples/cs/tool-calling-foundry-local-sdk/ToolCallingFoundryLocalSdk.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tool-calling-foundry-local-web-server/ToolCallingFoundryLocalWebServer.csproj b/samples/cs/tool-calling-foundry-local-web-server/ToolCallingFoundryLocalWebServer.csproj index a7c1a3766..89275aca3 100644 --- a/samples/cs/tool-calling-foundry-local-web-server/ToolCallingFoundryLocalWebServer.csproj +++ b/samples/cs/tool-calling-foundry-local-web-server/ToolCallingFoundryLocalWebServer.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tutorial-chat-assistant/TutorialChatAssistant.csproj b/samples/cs/tutorial-chat-assistant/TutorialChatAssistant.csproj index f07da7a75..44e48b154 100644 --- a/samples/cs/tutorial-chat-assistant/TutorialChatAssistant.csproj +++ b/samples/cs/tutorial-chat-assistant/TutorialChatAssistant.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tutorial-document-summarizer/TutorialDocumentSummarizer.csproj b/samples/cs/tutorial-document-summarizer/TutorialDocumentSummarizer.csproj index f07da7a75..44e48b154 100644 --- a/samples/cs/tutorial-document-summarizer/TutorialDocumentSummarizer.csproj +++ b/samples/cs/tutorial-document-summarizer/TutorialDocumentSummarizer.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj b/samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj index f07da7a75..44e48b154 100644 --- a/samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj +++ b/samples/cs/tutorial-tool-calling/TutorialToolCalling.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj b/samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj index f07da7a75..44e48b154 100644 --- a/samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj +++ b/samples/cs/tutorial-voice-to-text/TutorialVoiceToText.csproj @@ -19,10 +19,6 @@ net9.0 - - $(NETCoreSdkRuntimeIdentifier) - - diff --git a/sdk_v2/cs/test/FoundryLocal.Tests/ChatSessionTests.cs b/sdk_v2/cs/test/FoundryLocal.Tests/ChatSessionTests.cs index 8cdf8ec4f..19777b085 100644 --- a/sdk_v2/cs/test/FoundryLocal.Tests/ChatSessionTests.cs +++ b/sdk_v2/cs/test/FoundryLocal.Tests/ChatSessionTests.cs @@ -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() { @@ -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); @@ -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; @@ -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; @@ -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); @@ -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);