From 601c88942a2fd4022f0546fc61f3044843a532c6 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Sun, 14 Jul 2024 22:48:00 -0700 Subject: [PATCH 1/6] use 8.0.x versin --- .github/workflows/dotnet-build.yml | 2 +- .github/workflows/dotnet-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index f4074b06169..ac1e5ac597e 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -56,7 +56,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - global-json-file: dotnet/global.json + dotnet-version: '8.0.x' - name: Restore dependencies run: | # dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 2877d058377..aacfd115bb7 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -32,7 +32,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - global-json-file: dotnet/global.json + dotnet-version: '8.0.x' - name: Restore dependencies run: | dotnet restore -bl From 0ecb469a7f0969e63b0b0bd95799bd65795cad14 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Sun, 14 Jul 2024 22:55:57 -0700 Subject: [PATCH 2/6] enable format check --- .github/workflows/dotnet-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index ac1e5ac597e..fd7408d0058 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -61,6 +61,10 @@ jobs: run: | # dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config dotnet restore -bl + - name: Format check + run: | + echo "Format check" + dotnet format --verify-no-changes -v diag --no-restore - name: Build run: | echo "Build AutoGen" From 4a391daab85c61af45d2159c21d7147ab34734bc Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Sun, 14 Jul 2024 22:59:38 -0700 Subject: [PATCH 3/6] change file header --- dotnet/src/AutoGen.Core/Message/ToolCallAggregateMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/AutoGen.Core/Message/ToolCallAggregateMessage.cs b/dotnet/src/AutoGen.Core/Message/ToolCallAggregateMessage.cs index 7781b785ef8..7d46d56135a 100644 --- a/dotnet/src/AutoGen.Core/Message/ToolCallAggregateMessage.cs +++ b/dotnet/src/AutoGen.Core/Message/ToolCallAggregateMessage.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// FunctionCallAggregateMessage.cs +// ToolCallAggregateMessage.cs using System.Collections.Generic; From 1ce5dce61832b688a55c2c3c8d7c75e8b7a1f02f Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Sun, 14 Jul 2024 23:02:15 -0700 Subject: [PATCH 4/6] apply code format --- .../AutoGen.Anthropic.Samples/Create_Anthropic_Agent.cs | 2 +- .../Create_Anthropic_Agent_With_Tool.cs | 2 +- .../CodeSnippet/MiddlewareAgentCodeSnippet.cs | 6 ++---- .../Example04_Dynamic_GroupChat_Coding_Task.cs | 4 ++++ .../Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs | 4 ++++ .../Example13_OpenAIAgent_JsonMode.cs | 2 +- .../Example15_GPT4V_BinaryDataImageMessage.cs | 2 ++ ...xample16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs | 2 +- .../GettingStart/Dynamic_Group_Chat.cs | 2 +- dotnet/sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs | 3 ++- dotnet/sample/AutoGen.OpenAI.Sample/Use_Json_Mode.cs | 2 +- .../src/AutoGen.Anthropic/Agent/AnthropicClientAgent.cs | 5 ++++- dotnet/src/AutoGen.Anthropic/AnthropicClient.cs | 2 ++ .../AutoGen.Anthropic/Converters/ContentBaseConverter.cs | 6 ++---- dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs | 2 +- .../src/AutoGen.Anthropic/DTO/ChatCompletionResponse.cs | 5 +++-- dotnet/src/AutoGen.Anthropic/DTO/Content.cs | 2 +- dotnet/src/AutoGen.Anthropic/DTO/ErrorResponse.cs | 2 +- dotnet/src/AutoGen.Anthropic/DTO/Tool.cs | 2 +- dotnet/src/AutoGen.Anthropic/Utils/AnthropicConstants.cs | 2 +- dotnet/src/AutoGen.Gemini/IGeminiClient.cs | 2 +- dotnet/src/AutoGen.Gemini/VertexGeminiClient.cs | 2 +- dotnet/src/AutoGen.Ollama/DTOs/Message.cs | 2 +- .../AutoGen.Ollama/Embeddings/ITextEmbeddingService.cs | 2 +- .../Embeddings/OllamaTextEmbeddingService.cs | 2 +- .../AutoGen.Ollama/Embeddings/TextEmbeddingsRequest.cs | 2 +- .../AutoGen.Ollama/Embeddings/TextEmbeddingsResponse.cs | 2 +- .../SourceGeneratorFunctionContract.cs | 2 +- dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIMessage.cs | 2 +- .../src/AutoGen.WebAPI/OpenAI/DTO/OpenAIStreamOptions.cs | 2 +- .../AutoGen.Anthropic.Tests/AnthropicClientAgentTest.cs | 2 +- .../test/AutoGen.Anthropic.Tests/AnthropicClientTest.cs | 7 ++++++- .../AutoGen.Anthropic.Tests/AnthropicTestFunctionCalls.cs | 2 +- dotnet/test/AutoGen.Gemini.Tests/GeminiAgentTests.cs | 8 ++++---- .../test/AutoGen.Gemini.Tests/VertexGeminiClientTests.cs | 2 +- .../OllamaTextEmbeddingServiceTests.cs | 2 +- .../FunctionCallTemplateEncodingTests.cs | 8 +++++--- dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs | 4 +++- dotnet/test/AutoGen.WebAPI.Tests/EchoAgent.cs | 2 +- 39 files changed, 69 insertions(+), 47 deletions(-) diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent.cs b/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent.cs index 031e5068548..6f32c3cb4a2 100644 --- a/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent.cs +++ b/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// AnthropicSamples.cs +// Create_Anthropic_Agent.cs using AutoGen.Anthropic.Extensions; using AutoGen.Anthropic.Utils; diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent_With_Tool.cs b/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent_With_Tool.cs index 26bd32dd12d..0324a39ffa5 100644 --- a/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent_With_Tool.cs +++ b/dotnet/sample/AutoGen.Anthropic.Samples/Create_Anthropic_Agent_With_Tool.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Single_Anthropic_Tool.cs +// Create_Anthropic_Agent_With_Tool.cs using AutoGen.Anthropic.DTO; using AutoGen.Anthropic.Extensions; diff --git a/dotnet/sample/AutoGen.BasicSamples/CodeSnippet/MiddlewareAgentCodeSnippet.cs b/dotnet/sample/AutoGen.BasicSamples/CodeSnippet/MiddlewareAgentCodeSnippet.cs index 795606ebc85..1b5a9a90320 100644 --- a/dotnet/sample/AutoGen.BasicSamples/CodeSnippet/MiddlewareAgentCodeSnippet.cs +++ b/dotnet/sample/AutoGen.BasicSamples/CodeSnippet/MiddlewareAgentCodeSnippet.cs @@ -20,8 +20,7 @@ public async Task CreateMiddlewareAgentAsync() var middlewareAgent = new MiddlewareAgent(innerAgent: agent); middlewareAgent.Use(async (messages, options, agent, ct) => { - var lastMessage = messages.Last() as TextMessage; - if (lastMessage != null && lastMessage.Content.Contains("Hello World")) + if (messages.Last() is TextMessage lastMessage && lastMessage.Content.Contains("Hello World")) { lastMessage.Content = $"[middleware 0] {lastMessage.Content}"; return lastMessage; @@ -39,8 +38,7 @@ public async Task CreateMiddlewareAgentAsync() #region register_middleware_agent middlewareAgent = agent.RegisterMiddleware(async (messages, options, agent, ct) => { - var lastMessage = messages.Last() as TextMessage; - if (lastMessage != null && lastMessage.Content.Contains("Hello World")) + if (messages.Last() is TextMessage lastMessage && lastMessage.Content.Contains("Hello World")) { lastMessage.Content = $"[middleware 0] {lastMessage.Content}"; return lastMessage; diff --git a/dotnet/sample/AutoGen.BasicSamples/Example04_Dynamic_GroupChat_Coding_Task.cs b/dotnet/sample/AutoGen.BasicSamples/Example04_Dynamic_GroupChat_Coding_Task.cs index 47dd8ce66c9..21605992840 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example04_Dynamic_GroupChat_Coding_Task.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example04_Dynamic_GroupChat_Coding_Task.cs @@ -17,14 +17,18 @@ public static async Task RunAsync() // setup dotnet interactive var workDir = Path.Combine(Path.GetTempPath(), "InteractiveService"); if (!Directory.Exists(workDir)) + { Directory.CreateDirectory(workDir); + } using var service = new InteractiveService(workDir); var dotnetInteractiveFunctions = new DotnetInteractiveFunction(service); var result = Path.Combine(workDir, "result.txt"); if (File.Exists(result)) + { File.Delete(result); + } await service.StartAsync(workDir, default); diff --git a/dotnet/sample/AutoGen.BasicSamples/Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs b/dotnet/sample/AutoGen.BasicSamples/Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs index 6584baa5fae..93b8bd816c0 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example07_Dynamic_GroupChat_Calculate_Fibonacci.cs @@ -224,7 +224,9 @@ public static async Task RunWorkflowAsync() long the39thFibonacciNumber = 63245986; var workDir = Path.Combine(Path.GetTempPath(), "InteractiveService"); if (!Directory.Exists(workDir)) + { Directory.CreateDirectory(workDir); + } using var service = new InteractiveService(workDir); var dotnetInteractiveFunctions = new DotnetInteractiveFunction(service); @@ -328,7 +330,9 @@ public static async Task RunAsync() long the39thFibonacciNumber = 63245986; var workDir = Path.Combine(Path.GetTempPath(), "InteractiveService"); if (!Directory.Exists(workDir)) + { Directory.CreateDirectory(workDir); + } using var service = new InteractiveService(workDir); var dotnetInteractiveFunctions = new DotnetInteractiveFunction(service); diff --git a/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs b/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs index 9e5b91ecc12..429a59ca665 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs @@ -1,3 +1,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Example13_OpenAIAgent_JsonMode.cs -// this example has been moved to https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Use_Json_Mode.cs \ No newline at end of file + diff --git a/dotnet/sample/AutoGen.BasicSamples/Example15_GPT4V_BinaryDataImageMessage.cs b/dotnet/sample/AutoGen.BasicSamples/Example15_GPT4V_BinaryDataImageMessage.cs index 788122d3f38..dee9915511d 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example15_GPT4V_BinaryDataImageMessage.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example15_GPT4V_BinaryDataImageMessage.cs @@ -50,7 +50,9 @@ private static void AddMessagesFromResource(string imageResourcePath, List CreateChatCompletionsAsync(ChatComplet var responseStream = await httpResponseMessage.Content.ReadAsStreamAsync(); if (httpResponseMessage.IsSuccessStatusCode) + { return await DeserializeResponseAsync(responseStream, cancellationToken); + } ErrorResponse res = await DeserializeResponseAsync(responseStream, cancellationToken); throw new Exception(res.Error?.Message); diff --git a/dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs b/dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs index b41a761dc4d..3e620f934c2 100644 --- a/dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs +++ b/dotnet/src/AutoGen.Anthropic/Converters/ContentBaseConverter.cs @@ -1,12 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// ContentConverter.cs - -using AutoGen.Anthropic.DTO; - +// ContentBaseConverter.cs using System; using System.Text.Json; using System.Text.Json.Serialization; +using AutoGen.Anthropic.DTO; namespace AutoGen.Anthropic.Converters; public sealed class ContentBaseConverter : JsonConverter diff --git a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs index b18461e697b..463ee7fc259 100644 --- a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs +++ b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // ChatCompletionRequest.cs -using System.Text.Json.Serialization; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace AutoGen.Anthropic.DTO; diff --git a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionResponse.cs b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionResponse.cs index 2c6fa100fd6..fc33aa0e26b 100644 --- a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionResponse.cs +++ b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionResponse.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. +// ChatCompletionResponse.cs -namespace AutoGen.Anthropic.DTO; using System.Collections.Generic; using System.Text.Json.Serialization; +namespace AutoGen.Anthropic.DTO; public class ChatCompletionResponse { [JsonPropertyName("content")] diff --git a/dotnet/src/AutoGen.Anthropic/DTO/Content.cs b/dotnet/src/AutoGen.Anthropic/DTO/Content.cs index ee7a745a141..353cf6ae824 100644 --- a/dotnet/src/AutoGen.Anthropic/DTO/Content.cs +++ b/dotnet/src/AutoGen.Anthropic/DTO/Content.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Content.cs using System.Text.Json.Nodes; diff --git a/dotnet/src/AutoGen.Anthropic/DTO/ErrorResponse.cs b/dotnet/src/AutoGen.Anthropic/DTO/ErrorResponse.cs index d02a8f6d1cf..1a94334c88f 100644 --- a/dotnet/src/AutoGen.Anthropic/DTO/ErrorResponse.cs +++ b/dotnet/src/AutoGen.Anthropic/DTO/ErrorResponse.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // ErrorResponse.cs using System.Text.Json.Serialization; diff --git a/dotnet/src/AutoGen.Anthropic/DTO/Tool.cs b/dotnet/src/AutoGen.Anthropic/DTO/Tool.cs index 41c20dc2a42..2a46bc42a35 100644 --- a/dotnet/src/AutoGen.Anthropic/DTO/Tool.cs +++ b/dotnet/src/AutoGen.Anthropic/DTO/Tool.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Tool.cs using System.Collections.Generic; diff --git a/dotnet/src/AutoGen.Anthropic/Utils/AnthropicConstants.cs b/dotnet/src/AutoGen.Anthropic/Utils/AnthropicConstants.cs index e70572cbddf..6fd70cb4ee3 100644 --- a/dotnet/src/AutoGen.Anthropic/Utils/AnthropicConstants.cs +++ b/dotnet/src/AutoGen.Anthropic/Utils/AnthropicConstants.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Constants.cs +// AnthropicConstants.cs namespace AutoGen.Anthropic.Utils; diff --git a/dotnet/src/AutoGen.Gemini/IGeminiClient.cs b/dotnet/src/AutoGen.Gemini/IGeminiClient.cs index 2e209e02b03..d391a450839 100644 --- a/dotnet/src/AutoGen.Gemini/IGeminiClient.cs +++ b/dotnet/src/AutoGen.Gemini/IGeminiClient.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// IVertexGeminiClient.cs +// IGeminiClient.cs using System.Collections.Generic; using System.Threading; diff --git a/dotnet/src/AutoGen.Gemini/VertexGeminiClient.cs b/dotnet/src/AutoGen.Gemini/VertexGeminiClient.cs index c54f2280dfd..12a11993cd6 100644 --- a/dotnet/src/AutoGen.Gemini/VertexGeminiClient.cs +++ b/dotnet/src/AutoGen.Gemini/VertexGeminiClient.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// IGeminiClient.cs +// VertexGeminiClient.cs using System.Collections.Generic; using System.Threading; diff --git a/dotnet/src/AutoGen.Ollama/DTOs/Message.cs b/dotnet/src/AutoGen.Ollama/DTOs/Message.cs index 2e0d891cc61..75f622ff7f0 100644 --- a/dotnet/src/AutoGen.Ollama/DTOs/Message.cs +++ b/dotnet/src/AutoGen.Ollama/DTOs/Message.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// ChatResponseUpdate.cs +// Message.cs using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/dotnet/src/AutoGen.Ollama/Embeddings/ITextEmbeddingService.cs b/dotnet/src/AutoGen.Ollama/Embeddings/ITextEmbeddingService.cs index 5ce0dc8cc40..cce6dbb8307 100644 --- a/dotnet/src/AutoGen.Ollama/Embeddings/ITextEmbeddingService.cs +++ b/dotnet/src/AutoGen.Ollama/Embeddings/ITextEmbeddingService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // ITextEmbeddingService.cs using System.Threading; diff --git a/dotnet/src/AutoGen.Ollama/Embeddings/OllamaTextEmbeddingService.cs b/dotnet/src/AutoGen.Ollama/Embeddings/OllamaTextEmbeddingService.cs index 2e431e7bcb8..ea4993eb813 100644 --- a/dotnet/src/AutoGen.Ollama/Embeddings/OllamaTextEmbeddingService.cs +++ b/dotnet/src/AutoGen.Ollama/Embeddings/OllamaTextEmbeddingService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // OllamaTextEmbeddingService.cs using System; diff --git a/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsRequest.cs b/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsRequest.cs index 7f2531c522a..d776b183db0 100644 --- a/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsRequest.cs +++ b/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsRequest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // TextEmbeddingsRequest.cs using System.Text.Json.Serialization; diff --git a/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsResponse.cs b/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsResponse.cs index 580059c033b..f3ce64b7032 100644 --- a/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsResponse.cs +++ b/dotnet/src/AutoGen.Ollama/Embeddings/TextEmbeddingsResponse.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // TextEmbeddingsResponse.cs using System.Text.Json.Serialization; diff --git a/dotnet/src/AutoGen.SourceGenerator/SourceGeneratorFunctionContract.cs b/dotnet/src/AutoGen.SourceGenerator/SourceGeneratorFunctionContract.cs index 24e42affa3b..aa4980379f4 100644 --- a/dotnet/src/AutoGen.SourceGenerator/SourceGeneratorFunctionContract.cs +++ b/dotnet/src/AutoGen.SourceGenerator/SourceGeneratorFunctionContract.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// FunctionContract.cs +// SourceGeneratorFunctionContract.cs namespace AutoGen.SourceGenerator { diff --git a/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIMessage.cs b/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIMessage.cs index 3cad9ae3633..24cbb72fb6c 100644 --- a/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIMessage.cs +++ b/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIMessage.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// OpenAIChatCompletionOption.cs +// OpenAIMessage.cs using System.Text.Json.Serialization; diff --git a/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIStreamOptions.cs b/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIStreamOptions.cs index 3c188b865b7..7a49851446b 100644 --- a/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIStreamOptions.cs +++ b/dotnet/src/AutoGen.WebAPI/OpenAI/DTO/OpenAIStreamOptions.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// +// OpenAIStreamOptions.cs using System.Text.Json.Serialization; diff --git a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientAgentTest.cs b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientAgentTest.cs index 552408f1d05..085917d419e 100644 --- a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientAgentTest.cs +++ b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientAgentTest.cs @@ -188,7 +188,7 @@ public async Task AnthropicAgentFunctionCallMessageTest() IMessage[] chatHistory = [ new TextMessage(Role.User, "what's the weather in Philadelphia?"), new ToolCallMessage([toolCall], from: "assistant"), - new ToolCallResultMessage([toolCall], from: "user" ), + new ToolCallResultMessage([toolCall], from: "user"), ]; var reply = await agent.SendAsync(chatHistory: chatHistory); diff --git a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientTest.cs b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientTest.cs index 66b7d007758..102e48b9b8a 100644 --- a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientTest.cs +++ b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicClientTest.cs @@ -1,4 +1,7 @@ -using System.Text; +// Copyright (c) Microsoft Corporation. All rights reserved. +// AnthropicClientTest.cs + +using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; @@ -59,7 +62,9 @@ public async Task AnthropicClientStreamingChatCompletionTestAsync() foreach (ChatCompletionResponse result in results) { if (result.Delta is not null && !string.IsNullOrEmpty(result.Delta.Text)) + { sb.Append(result.Delta.Text); + } } string resultContent = sb.ToString(); diff --git a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicTestFunctionCalls.cs b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicTestFunctionCalls.cs index 5f1c0971bf7..8b5466e3a51 100644 --- a/dotnet/test/AutoGen.Anthropic.Tests/AnthropicTestFunctionCalls.cs +++ b/dotnet/test/AutoGen.Anthropic.Tests/AnthropicTestFunctionCalls.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// AnthropicTestFunctions.cs +// AnthropicTestFunctionCalls.cs using System.Text.Json; using System.Text.Json.Serialization; diff --git a/dotnet/test/AutoGen.Gemini.Tests/GeminiAgentTests.cs b/dotnet/test/AutoGen.Gemini.Tests/GeminiAgentTests.cs index 6d095845f80..c076aee1837 100644 --- a/dotnet/test/AutoGen.Gemini.Tests/GeminiAgentTests.cs +++ b/dotnet/test/AutoGen.Gemini.Tests/GeminiAgentTests.cs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // GeminiAgentTests.cs -using AutoGen.Tests; -using Google.Cloud.AIPlatform.V1; using AutoGen.Core; -using FluentAssertions; using AutoGen.Gemini.Extension; -using static Google.Cloud.AIPlatform.V1.Part; +using AutoGen.Tests; +using FluentAssertions; +using Google.Cloud.AIPlatform.V1; using Xunit.Abstractions; +using static Google.Cloud.AIPlatform.V1.Part; namespace AutoGen.Gemini.Tests; public class GeminiAgentTests diff --git a/dotnet/test/AutoGen.Gemini.Tests/VertexGeminiClientTests.cs b/dotnet/test/AutoGen.Gemini.Tests/VertexGeminiClientTests.cs index 8063b707703..fba97aa522d 100644 --- a/dotnet/test/AutoGen.Gemini.Tests/VertexGeminiClientTests.cs +++ b/dotnet/test/AutoGen.Gemini.Tests/VertexGeminiClientTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// GeminiVertexClientTests.cs +// VertexGeminiClientTests.cs using AutoGen.Tests; using FluentAssertions; diff --git a/dotnet/test/AutoGen.Ollama.Tests/OllamaTextEmbeddingServiceTests.cs b/dotnet/test/AutoGen.Ollama.Tests/OllamaTextEmbeddingServiceTests.cs index 06522bdd823..b7186a3c6eb 100644 --- a/dotnet/test/AutoGen.Ollama.Tests/OllamaTextEmbeddingServiceTests.cs +++ b/dotnet/test/AutoGen.Ollama.Tests/OllamaTextEmbeddingServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // OllamaTextEmbeddingServiceTests.cs using AutoGen.Tests; diff --git a/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs b/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs index 8ca6e31a8a4..0b2e211c638 100644 --- a/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs +++ b/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs @@ -1,7 +1,9 @@ -// Using directives +// Copyright (c) Microsoft Corporation. All rights reserved. +// FunctionCallTemplateEncodingTests.cs + using System.Text.Json; // Needed for JsonSerializer -using Xunit; // Needed for Fact and Assert using AutoGen.SourceGenerator.Template; // Needed for FunctionCallTemplate +using Xunit; // Needed for Fact and Assert namespace AutoGen.SourceGenerator.Tests { @@ -89,4 +91,4 @@ public void ParameterDescription_Should_Encode_DoubleQuotes() Assert.Contains("Description = @\"This is a \"\"parameter\"\" description\"", result); } } -} \ No newline at end of file +} diff --git a/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs b/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs index 77e2c99dcd1..7eeea6743f0 100644 --- a/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs +++ b/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs @@ -1,4 +1,6 @@ - +// Copyright (c) Microsoft Corporation. All rights reserved. +// GraphTests.cs + using Xunit; namespace AutoGen.Tests diff --git a/dotnet/test/AutoGen.WebAPI.Tests/EchoAgent.cs b/dotnet/test/AutoGen.WebAPI.Tests/EchoAgent.cs index 64d48d2a00b..6f9d217b50c 100644 --- a/dotnet/test/AutoGen.WebAPI.Tests/EchoAgent.cs +++ b/dotnet/test/AutoGen.WebAPI.Tests/EchoAgent.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// OpenAIChatCompletionMiddlewareTests.cs +// EchoAgent.cs using System.Runtime.CompilerServices; using AutoGen.Core; From be4689838f1111673d5b20bc32738082b1197cc0 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Sun, 14 Jul 2024 23:04:54 -0700 Subject: [PATCH 5/6] add instructions in ci to fix format error --- .github/workflows/dotnet-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index fd7408d0058..7e50025917d 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -64,6 +64,7 @@ jobs: - name: Format check run: | echo "Format check" + echo "If you see any error in this step, please run 'dotnet format' locally to format the code." dotnet format --verify-no-changes -v diag --no-restore - name: Build run: | From d6428937cba6432dbc5ea4a8e5c055780584f72e Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 15 Jul 2024 12:26:09 -0700 Subject: [PATCH 6/6] add comment back --- .../AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs | 2 ++ .../Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs b/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs index 429a59ca665..596ab08d02a 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example13_OpenAIAgent_JsonMode.cs @@ -1,3 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Example13_OpenAIAgent_JsonMode.cs +// this example has been moved to https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Use_Json_Mode.cs + diff --git a/dotnet/sample/AutoGen.BasicSamples/Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs b/dotnet/sample/AutoGen.BasicSamples/Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs index 33321d9729c..969f7dc21c7 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs @@ -1,3 +1,4 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs +// this example has been moved to https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs