diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93ecd67..4f3f3a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-14, windows-latest] + os: [ubuntu-latest, macos-15, windows-latest] steps: - uses: actions/checkout@v3 @@ -75,6 +75,9 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - name: Download Linux artifacts uses: actions/download-artifact@v3 with: @@ -83,7 +86,7 @@ jobs: - name: Download macOS artifacts uses: actions/download-artifact@v3 with: - name: native-library-macos-14 + name: native-library-macos-15 path: artifacts/macos - name: Download Windows artifacts uses: actions/download-artifact@v3 diff --git a/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineChatClient.cs b/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineChatClient.cs index 4580738..81bbd41 100644 --- a/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineChatClient.cs +++ b/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineChatClient.cs @@ -94,12 +94,9 @@ private ConversationContext GetConversationContext(IList messages) var phiEngineMessages = head.Where(m => m.Role != ChatRole.System && m.Role != ChatRole.Tool) .Select(m => m.ToConversationMessage()).ToList(); var systemInstruction = head.LastOrDefault(m => m.Role == ChatRole.System)?.Text ?? _systemInstruction; - - Console.WriteLine($"Using system instruction: {systemInstruction}"); return new ConversationContext(phiEngineMessages, systemInstruction); } - Console.WriteLine($"Using default system instruction: {_systemInstruction}"); return new ConversationContext([], _systemInstruction); } diff --git a/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineExtensions.cs b/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineExtensions.cs new file mode 100644 index 0000000..2ef465c --- /dev/null +++ b/packages/csharp/Strathweb.Phi.Engine.Microsoft.Extensions.AI/PhiEngineExtensions.cs @@ -0,0 +1,7 @@ +namespace Strathweb.Phi.Engine.Microsoft.Extensions.AI; + +public static class PhiEngineExtensions +{ + public static PhiEngineChatClient AsChatClient(this PhiEngine engine, string id, StreamingEventHandler handler, string systemInstruction = null, InferenceOptions inferenceOptions = null) => + new(id, engine, handler, systemInstruction, inferenceOptions); +} \ No newline at end of file diff --git a/samples/csharp/chatclient/Program.cs b/samples/csharp/chatclient/Program.cs index 1f74461..238f02b 100644 --- a/samples/csharp/chatclient/Program.cs +++ b/samples/csharp/chatclient/Program.cs @@ -10,7 +10,10 @@ modelBuilder.WithEventHandler(new BoxedPhiEventHandler(handler)); var model = modelBuilder.Build(cacheDir); -var chatClient = new PhiEngineChatClient("Local Phi-3 Demo", model, handler, systemInstruction: "You convert what user said to all uppercase."); +var chatClient = model.AsChatClient("Local Phi-3 Demo", handler, + systemInstruction: "You convert what user said to all uppercase."); +// or alternatively +//var chatClient = new PhiEngineChatClient("Local Phi-3 Demo", model, handler, systemInstruction: "You convert what user said to all uppercase."); var message = new ChatMessage(ChatRole.User, "hello world"); var response = await chatClient.CompleteAsync([message]); diff --git a/samples/csharp/chatclient/chatclient.console.csproj b/samples/csharp/chatclient/chatclient.console.csproj index 4ccfc6e..0effbc1 100644 --- a/samples/csharp/chatclient/chatclient.console.csproj +++ b/samples/csharp/chatclient/chatclient.console.csproj @@ -8,7 +8,7 @@ - +