mirror of https://github.com/microsoft/autogen.git
[.Net] update dotnet-ci and dotnet-release to use 8.0.x version when setting up .NET. And enable format check (#3136)
* use 8.0.x versin * enable format check * change file header * apply code format * add instructions in ci to fix format error * add comment back
This commit is contained in:
parent
7205ccc3b9
commit
970c1961dd
|
@ -56,11 +56,16 @@ 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
|
||||
dotnet restore -bl
|
||||
- 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: |
|
||||
echo "Build AutoGen"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -20,8 +20,7 @@ public class MiddlewareAgentCodeSnippet
|
|||
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 class MiddlewareAgentCodeSnippet
|
|||
#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;
|
||||
|
|
|
@ -17,14 +17,18 @@ public partial class Example04_Dynamic_GroupChat_Coding_Task
|
|||
// 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);
|
||||
|
||||
|
|
|
@ -225,7 +225,9 @@ public partial class Example07_Dynamic_GroupChat_Calculate_Fibonacci
|
|||
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);
|
||||
|
@ -329,7 +331,9 @@ public partial class Example07_Dynamic_GroupChat_Calculate_Fibonacci
|
|||
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);
|
||||
|
|
|
@ -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
|
||||
|
||||
// this example has been moved to https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Use_Json_Mode.cs
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ public static class Example15_GPT4V_BinaryDataImageMessage
|
|||
foreach (string file in Directory.GetFiles(imageResourcePath))
|
||||
{
|
||||
if (!_mediaTypeMappings.TryGetValue(Path.GetExtension(file).ToLowerInvariant(), out var mediaType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using var fs = new FileStream(file, FileMode.Open, FileAccess.Read);
|
||||
var ms = new MemoryStream();
|
||||
|
|
|
@ -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
|
||||
|
||||
// this example has been moved to https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Dynamic_GroupChat.cs
|
||||
// Dynamic_Group_Chat.cs
|
||||
|
||||
using AutoGen.Core;
|
||||
using AutoGen.OpenAI;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs
|
||||
// Connect_To_Ollama.cs
|
||||
|
||||
#region using_statement
|
||||
using AutoGen.Core;
|
||||
using AutoGen.OpenAI.Extension;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Example13_OpenAIAgent_JsonMode.cs
|
||||
// Use_Json_Mode.cs
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AnthropicClientAgent.cs
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
|
|
@ -48,7 +48,9 @@ public sealed class AnthropicClient : IDisposable
|
|||
var responseStream = await httpResponseMessage.Content.ReadAsStreamAsync();
|
||||
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
return await DeserializeResponseAsync<ChatCompletionResponse>(responseStream, cancellationToken);
|
||||
}
|
||||
|
||||
ErrorResponse res = await DeserializeResponseAsync<ErrorResponse>(responseStream, cancellationToken);
|
||||
throw new Exception(res.Error?.Message);
|
||||
|
|
|
@ -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<ContentBase>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Tool.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Constants.cs
|
||||
// AnthropicConstants.cs
|
||||
|
||||
namespace AutoGen.Anthropic.Utils;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// FunctionCallAggregateMessage.cs
|
||||
// ToolCallAggregateMessage.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// IVertexGeminiClient.cs
|
||||
// IGeminiClient.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// IGeminiClient.cs
|
||||
// VertexGeminiClient.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ChatResponseUpdate.cs
|
||||
// Message.cs
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ITextEmbeddingService.cs
|
||||
|
||||
using System.Threading;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// OllamaTextEmbeddingService.cs
|
||||
|
||||
using System;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// FunctionContract.cs
|
||||
// SourceGeneratorFunctionContract.cs
|
||||
|
||||
namespace AutoGen.SourceGenerator
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// OpenAIChatCompletionOption.cs
|
||||
// OpenAIMessage.cs
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// OpenAIStreamOptions.cs
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ public class AnthropicClientAgentTest
|
|||
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);
|
||||
|
|
|
@ -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 class AnthropicClientTests
|
|||
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();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// AnthropicTestFunctions.cs
|
||||
// AnthropicTestFunctionCalls.cs
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GeminiVertexClientTests.cs
|
||||
// VertexGeminiClientTests.cs
|
||||
|
||||
using AutoGen.Tests;
|
||||
using FluentAssertions;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// OllamaTextEmbeddingServiceTests.cs
|
||||
|
||||
using AutoGen.Tests;
|
||||
|
|
|
@ -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 @@ namespace AutoGen.SourceGenerator.Tests
|
|||
Assert.Contains("Description = @\"This is a \"\"parameter\"\" description\"", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// GraphTests.cs
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace AutoGen.Tests
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// OpenAIChatCompletionMiddlewareTests.cs
|
||||
// EchoAgent.cs
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using AutoGen.Core;
|
||||
|
|
Loading…
Reference in New Issue