diff --git a/.editorconfig b/.editorconfig index 6b17d25..644e447 100644 --- a/.editorconfig +++ b/.editorconfig @@ -384,5 +384,5 @@ dotnet_naming_style.s_camelcase.capitalization = camel_case indent_size = 2 tab_width = 2 -[*.{props,targets,config,nuspec,json}] +[*.{props,targets,config,nuspec,json,yml}] indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ab7c15..0af6bf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,15 +7,25 @@ on: branches: [ "main" ] jobs: - test: + test-net6: runs-on: ubuntu-latest - container: mcr.microsoft.com/dotnet/sdk:8.0 + container: mcr.microsoft.com/dotnet/sdk:6.0 steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build - run: dotnet build -c Release - - name: Test - run: dotnet test -c Release + - name: Checkout + uses: actions/checkout@v4 + - name: Build + run: dotnet build src/Cnblogs.DashScope.AspNetCore -c Release + - name: Test + run: dotnet test test/Cnblogs.DashScope.Sdk.UnitTests -c Release + test-net8: + runs-on: ubuntu-latest + container: mcr.microsoft.com/dotnet/sdk:8.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build + run: dotnet build src/Cnblogs.DashScope.AI -c Release + - name: Test + run: dotnet test test/Cnblogs.DashScope.AI.UnitTests -c Release diff --git a/Cnblogs.DashScope.Sdk.sln b/Cnblogs.DashScope.Sdk.sln index 26d0161..165038d 100644 --- a/Cnblogs.DashScope.Sdk.sln +++ b/Cnblogs.DashScope.Sdk.sln @@ -20,6 +20,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.Sdk.Snaps EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.AI", "src\Cnblogs.DashScope.AI\Cnblogs.DashScope.AI.csproj", "{5D5AD75A-8084-4738-AC56-B8A23E649452}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.AI.UnitTests", "test\Cnblogs.DashScope.AI.UnitTests\Cnblogs.DashScope.AI.UnitTests.csproj", "{25EE79E1-147B-42FD-AFEA-E1550EDD1D36}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.Tests.Shared", "test\Cnblogs.DashScope.Tests.Shared\Cnblogs.DashScope.Tests.Shared.csproj", "{06F0AF23-445B-4C6F-9E19-570DA9B7435D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +37,8 @@ Global {CC389455-A3EA-4F09-B524-4DC351A1E1AA} = {008988ED-0A3B-4272-BCC3-7B4110699345} {5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1} = {CFC8ECB3-5248-46CD-A56C-EC088F2A3804} {5D5AD75A-8084-4738-AC56-B8A23E649452} = {008988ED-0A3B-4272-BCC3-7B4110699345} + {25EE79E1-147B-42FD-AFEA-E1550EDD1D36} = {CFC8ECB3-5248-46CD-A56C-EC088F2A3804} + {06F0AF23-445B-4C6F-9E19-570DA9B7435D} = {CFC8ECB3-5248-46CD-A56C-EC088F2A3804} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FA6A118A-8D26-4B7A-9952-8504B8A0025B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -63,5 +69,13 @@ Global {5D5AD75A-8084-4738-AC56-B8A23E649452}.Debug|Any CPU.Build.0 = Debug|Any CPU {5D5AD75A-8084-4738-AC56-B8A23E649452}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D5AD75A-8084-4738-AC56-B8A23E649452}.Release|Any CPU.Build.0 = Release|Any CPU + {25EE79E1-147B-42FD-AFEA-E1550EDD1D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25EE79E1-147B-42FD-AFEA-E1550EDD1D36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25EE79E1-147B-42FD-AFEA-E1550EDD1D36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25EE79E1-147B-42FD-AFEA-E1550EDD1D36}.Release|Any CPU.Build.0 = Release|Any CPU + {06F0AF23-445B-4C6F-9E19-570DA9B7435D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06F0AF23-445B-4C6F-9E19-570DA9B7435D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06F0AF23-445B-4C6F-9E19-570DA9B7435D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06F0AF23-445B-4C6F-9E19-570DA9B7435D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Directory.Build.props b/Directory.Build.props index f39a7b6..3eaabd9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - net8.0 + net6.0 enable enable Cnblogs diff --git a/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj b/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj index d8cdc9f..ba80da7 100644 --- a/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj +++ b/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj @@ -20,7 +20,7 @@ - + diff --git a/sample/Cnblogs.DashScope.Sample/Program.cs b/sample/Cnblogs.DashScope.Sample/Program.cs index 8841af4..d003cd3 100644 --- a/sample/Cnblogs.DashScope.Sample/Program.cs +++ b/sample/Cnblogs.DashScope.Sample/Program.cs @@ -177,7 +177,7 @@ async Task ChatWithToolsAsync() "获得当前天气", new JsonSchemaBuilder().FromType().Build())) }; - var chatParameters = new TextGenerationParameters() { ResultFormat = ResultFormats.Message, Tools = tools }; + var chatParameters = new TextGenerationParameters { ResultFormat = ResultFormats.Message, Tools = tools }; var question = TextChatMessage.User("请问现在杭州的天气如何?"); history.Add(question); Console.WriteLine($"{question.Role} > {question.Content}"); @@ -214,10 +214,7 @@ async Task ChatWithMicrosoftExtensions() Console.WriteLine("Requesting model..."); var chatClient = dashScopeClient.AsChatClient("qwen-max"); List conversation = - [ - new(ChatRole.System, "You are a helpful AI assistant"), - new(ChatRole.User, "What is AI?") - ]; + new() { new(ChatRole.System, "You are a helpful AI assistant"), new(ChatRole.User, "What is AI?") }; var response = await chatClient.GetResponseAsync(conversation); var serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web) { WriteIndented = true }; Console.WriteLine(JsonSerializer.Serialize(response, serializerOptions)); @@ -225,7 +222,7 @@ async Task ChatWithMicrosoftExtensions() async Task ApplicationCallAsync(string applicationId, string prompt) { - var request = new ApplicationRequest() { Input = new ApplicationInput() { Prompt = prompt } }; + var request = new ApplicationRequest { Input = new ApplicationInput { Prompt = prompt } }; var response = await dashScopeClient.GetApplicationResponseAsync(applicationId, request); Console.WriteLine(response.Output.Text); } diff --git a/sample/Cnblogs.DashScope.Sample/ToolCallWithExtensions.cs b/sample/Cnblogs.DashScope.Sample/ToolCallWithExtensions.cs index 0c30cd4..72ccc1e 100644 --- a/sample/Cnblogs.DashScope.Sample/ToolCallWithExtensions.cs +++ b/sample/Cnblogs.DashScope.Sample/ToolCallWithExtensions.cs @@ -12,7 +12,7 @@ public static async Task ToolCallWithExtensionAsync(this IDashScopeClient dashSc [Description("Gets the weather")] string GetWeather(string location) => Random.Shared.NextDouble() > 0.5 ? "It's sunny" : "It's raining"; - var chatOptions = new ChatOptions { Tools = [AIFunctionFactory.Create(GetWeather)] }; + var chatOptions = new ChatOptions { Tools = new List { AIFunctionFactory.Create(GetWeather) } }; var client = dashScopeClient.AsChatClient("qwen-max").AsBuilder().UseFunctionInvocation().Build(); await foreach (var message in client.GetStreamingResponseAsync("What is weather of LA today?", chatOptions)) diff --git a/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj b/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj index a06683f..8de1ebd 100644 --- a/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj +++ b/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj @@ -1,5 +1,6 @@  + net8.0 Cnblogs.DashScope.AI true Cnblogs;Dashscope;Microsoft.Extensions.AI;Sdk;Embedding; @@ -10,7 +11,8 @@ - + + diff --git a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs index d85031b..c8a0d0f 100644 --- a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs +++ b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs @@ -17,7 +17,7 @@ public sealed class DashScopeChatClient : IChatClient private readonly string _modelId; private static readonly JsonSchema EmptyObjectSchema = - JsonSchema.FromText("""{"type":"object","required":[],"properties":{}}"""); + JsonSchema.FromText("{\"type\":\"object\",\"required\":[],\"properties\":{}}"); private static readonly TextGenerationParameters DefaultTextGenerationParameter = new() { ResultFormat = "message" }; @@ -55,7 +55,7 @@ public async Task GetResponseAsync( if (useVl) { var response = await _dashScopeClient.GetMultimodalGenerationAsync( - new ModelRequest() + new ModelRequest { Input = new MultimodalInput { Messages = ToMultimodalMessages(chatMessages) }, Parameters = ToMultimodalParameters(options), @@ -63,7 +63,7 @@ public async Task GetResponseAsync( }, cancellationToken); - var returnMessage = new ChatMessage() + var returnMessage = new ChatMessage { RawRepresentation = response, Role = ToChatRole(response.Output.Choices[0].Message.Role), }; @@ -80,7 +80,7 @@ public async Task GetResponseAsync( if (response.Usage != null) { - completion.Usage = new UsageDetails() + completion.Usage = new UsageDetails { InputTokenCount = response.Usage.InputTokens, OutputTokenCount = response.Usage.OutputTokens, }; @@ -92,7 +92,7 @@ public async Task GetResponseAsync( { var parameters = ToTextGenerationParameters(options) ?? DefaultTextGenerationParameter; var response = await _dashScopeClient.GetTextCompletionAsync( - new ModelRequest() + new ModelRequest { Input = new TextGenerationInput { @@ -116,7 +116,7 @@ public async Task GetResponseAsync( if (response.Usage != null) { - completion.Usage = new UsageDetails() + completion.Usage = new UsageDetails { InputTokenCount = response.Usage.InputTokens, OutputTokenCount = response.Usage.OutputTokens, @@ -147,7 +147,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( var parameter = ToMultimodalParameters(options); parameter.IncrementalOutput = true; var stream = _dashScopeClient.GetMultimodalGenerationStreamAsync( - new ModelRequest() + new ModelRequest { Input = new MultimodalInput { Messages = ToMultimodalMessages(chatMessages) }, Parameters = parameter, @@ -164,7 +164,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( : ToFinishReason(response.Output.Choices[0].FinishReason); completionId ??= response.RequestId; - var update = new ChatResponseUpdate() + var update = new ChatResponseUpdate { ResponseId = completionId, CreatedAt = DateTimeOffset.Now, @@ -199,7 +199,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( { // qwen does not support streaming with function call, fallback to non-streaming var completion = await GetResponseAsync(chatMessages, options, cancellationToken); - yield return new ChatResponseUpdate() + yield return new ChatResponseUpdate { ResponseId = completion.ResponseId, Role = completion.Messages[0].Role, @@ -216,7 +216,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( var parameters = ToTextGenerationParameters(options) ?? DefaultTextGenerationParameter; parameters.IncrementalOutput = true; var stream = _dashScopeClient.GetTextCompletionStreamAsync( - new ModelRequest() + new ModelRequest { Input = new TextGenerationInput { @@ -238,7 +238,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( : ToFinishReason(response.Output.Choices[0].FinishReason); completionId ??= response.RequestId; - var update = new ChatResponseUpdate() + var update = new ChatResponseUpdate { ResponseId = completionId, CreatedAt = DateTimeOffset.Now, @@ -257,7 +257,7 @@ public async IAsyncEnumerable GetStreamingResponseAsync( { update.Contents.Add( new UsageContent( - new UsageDetails() + new UsageDetails { InputTokenCount = response.Usage.InputTokens, OutputTokenCount = response.Usage.OutputTokens, @@ -299,7 +299,7 @@ public void Dispose() private static ChatMessage ToChatMessage(TextChatMessage message) { - var returnMessage = new ChatMessage() + var returnMessage = new ChatMessage { RawRepresentation = message, Role = ToChatRole(message.Role), }; @@ -485,7 +485,7 @@ private IEnumerable ToTextChatMessages( format = "json_object"; } - return new TextGenerationParameters() + return new TextGenerationParameters { ResultFormat = format, Temperature = options.Temperature, diff --git a/src/Cnblogs.DashScope.AI/DashScopeTextEmbeddingGenerator.cs b/src/Cnblogs.DashScope.AI/DashScopeTextEmbeddingGenerator.cs index 06c28d7..f735844 100644 --- a/src/Cnblogs.DashScope.AI/DashScopeTextEmbeddingGenerator.cs +++ b/src/Cnblogs.DashScope.AI/DashScopeTextEmbeddingGenerator.cs @@ -44,7 +44,7 @@ public async Task>> GenerateAsync( e => new Embedding(e.Embedding) { ModelId = _modelId, CreatedAt = DateTimeOffset.Now }); var rawUsage = rawResponse.Usage; var usage = rawUsage != null - ? new UsageDetails() { InputTokenCount = rawUsage.TotalTokens, TotalTokenCount = rawUsage.TotalTokens } + ? new UsageDetails { InputTokenCount = rawUsage.TotalTokens, TotalTokenCount = rawUsage.TotalTokens } : null; return new GeneratedEmbeddings>(embeddings) { diff --git a/src/Cnblogs.DashScope.Core/ApplicationInput.cs b/src/Cnblogs.DashScope.Core/ApplicationInput.cs index 965124b..fc537e6 100644 --- a/src/Cnblogs.DashScope.Core/ApplicationInput.cs +++ b/src/Cnblogs.DashScope.Core/ApplicationInput.cs @@ -44,4 +44,6 @@ public class ApplicationInput /// /// Inputs for application call. /// -public class ApplicationInput : ApplicationInput>; +public class ApplicationInput : ApplicationInput> +{ +} diff --git a/src/Cnblogs.DashScope.Core/ApplicationRequest.cs b/src/Cnblogs.DashScope.Core/ApplicationRequest.cs index bdafef5..c1980e7 100644 --- a/src/Cnblogs.DashScope.Core/ApplicationRequest.cs +++ b/src/Cnblogs.DashScope.Core/ApplicationRequest.cs @@ -13,7 +13,7 @@ public class ApplicationRequest : IDashScopeWorkspaceConfig /// /// Content of this call. /// - public required ApplicationInput Input { get; set; } + public ApplicationInput Input { get; set; } = new(); /// /// Optional configurations. @@ -30,4 +30,6 @@ public class ApplicationRequest : IDashScopeWorkspaceConfig /// /// Request body for an application call with dictionary biz_content. /// -public class ApplicationRequest : ApplicationRequest>; +public class ApplicationRequest : ApplicationRequest> +{ +} diff --git a/src/Cnblogs.DashScope.Core/BackgroundGenerationInput.cs b/src/Cnblogs.DashScope.Core/BackgroundGenerationInput.cs index bd820dc..dd5b2b3 100644 --- a/src/Cnblogs.DashScope.Core/BackgroundGenerationInput.cs +++ b/src/Cnblogs.DashScope.Core/BackgroundGenerationInput.cs @@ -8,7 +8,7 @@ public class BackgroundGenerationInput /// /// The image url to generation background on. /// - public required string BaseImageUrl { get; set; } + public string BaseImageUrl { get; set; } = string.Empty; /// /// The reference image url for. diff --git a/src/Cnblogs.DashScope.Core/BatchGetEmbeddingsInput.cs b/src/Cnblogs.DashScope.Core/BatchGetEmbeddingsInput.cs index b9ab6e0..36b04cd 100644 --- a/src/Cnblogs.DashScope.Core/BatchGetEmbeddingsInput.cs +++ b/src/Cnblogs.DashScope.Core/BatchGetEmbeddingsInput.cs @@ -8,5 +8,5 @@ public class BatchGetEmbeddingsInput /// /// The url of text file to compute embeddings from. /// - public required string Url { get; set; } + public string Url { get; set; } = string.Empty; } diff --git a/src/Cnblogs.DashScope.Core/Cnblogs.DashScope.Core.csproj b/src/Cnblogs.DashScope.Core/Cnblogs.DashScope.Core.csproj index 791029d..7d46d37 100644 --- a/src/Cnblogs.DashScope.Core/Cnblogs.DashScope.Core.csproj +++ b/src/Cnblogs.DashScope.Core/Cnblogs.DashScope.Core.csproj @@ -8,11 +8,11 @@ - + - + diff --git a/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs b/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs index 7cca41f..fdbed71 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs @@ -18,7 +18,7 @@ public class DashScopeClientCore : IDashScopeClient new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + PropertyNamingPolicy = JsonSnakeCaseLowerNamingPolicy.SnakeCaseLower, }; private readonly HttpClient _httpClient; @@ -332,7 +332,7 @@ private static HttpRequestMessage BuildRequest( { var response = await GetSuccessResponseAsync( message, - r => new DashScopeError() + r => new DashScopeError { Code = r.Error.Type, Message = r.Error.Message, @@ -367,7 +367,7 @@ private async IAsyncEnumerable StreamAsync( if (cancellationToken.IsCancellationRequested) throw new TaskCanceledException(); - var line = await reader.ReadLineAsync(cancellationToken); + var line = await reader.ReadLineAsync(); if (line != null && line.StartsWith("data:")) { var data = line["data:".Length..]; diff --git a/src/Cnblogs.DashScope.Core/DashScopeException.cs b/src/Cnblogs.DashScope.Core/DashScopeException.cs index d4aba49..3826f87 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeException.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeException.cs @@ -3,24 +3,35 @@ /// /// Represents error detail for DashScope API calls. /// -/// The requested api url. -/// The status code of response. Would be 0 if no response is received. -/// The error detail returned by server. -/// The error message. -public class DashScopeException(string? apiUrl, int status, DashScopeError? error, string message) : Exception(message) +public class DashScopeException : Exception { + /// + /// Represents error detail for DashScope API calls. + /// + /// The requested api url. + /// The status code of response. Would be 0 if no response is received. + /// The error detail returned by server. + /// The error message. + public DashScopeException(string? apiUrl, int status, DashScopeError? error, string message) + : base(message) + { + ApiUrl = apiUrl; + Error = error; + Status = status; + } + /// /// The requested api url. /// - public string? ApiUrl { get; } = apiUrl; + public string? ApiUrl { get; } /// /// The error detail returned by server. /// - public DashScopeError? Error { get; } = error; + public DashScopeError? Error { get; } /// /// The status code of response. Would be 0 if no response is received. /// - public int Status { get; } = status; + public int Status { get; } } diff --git a/src/Cnblogs.DashScope.Core/DashScopeTaskOutput.cs b/src/Cnblogs.DashScope.Core/DashScopeTaskOutput.cs index 8ca43f9..7a8bee7 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeTaskOutput.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeTaskOutput.cs @@ -11,7 +11,7 @@ public abstract record DashScopeTaskOutput /// /// The unique id of this task. /// - public required string TaskId { get; set; } + public string TaskId { get; set; } = string.Empty; /// /// The status of this task. diff --git a/src/Cnblogs.DashScope.Core/DashScopeTaskStatus.cs b/src/Cnblogs.DashScope.Core/DashScopeTaskStatus.cs index 83a3509..3b87579 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeTaskStatus.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeTaskStatus.cs @@ -5,7 +5,7 @@ namespace Cnblogs.DashScope.Core; /// /// Represents status of DashScope task. /// -[JsonConverter(typeof(JsonStringEnumConverter))] +[JsonConverter(typeof(JsonStringEnumConverter))] public enum DashScopeTaskStatus { /// diff --git a/src/Cnblogs.DashScope.Core/IBatchGetEmbeddingsParameters.cs b/src/Cnblogs.DashScope.Core/IBatchGetEmbeddingsParameters.cs index d2640e0..04a28d3 100644 --- a/src/Cnblogs.DashScope.Core/IBatchGetEmbeddingsParameters.cs +++ b/src/Cnblogs.DashScope.Core/IBatchGetEmbeddingsParameters.cs @@ -3,4 +3,6 @@ /// /// Optional parameter of batch get embeddings request. /// -public interface IBatchGetEmbeddingsParameters : ITextEmbeddingParameters; +public interface IBatchGetEmbeddingsParameters : ITextEmbeddingParameters +{ +} diff --git a/src/Cnblogs.DashScope.Core/ImageGenerationInput.cs b/src/Cnblogs.DashScope.Core/ImageGenerationInput.cs index d21dca1..4ea9876 100644 --- a/src/Cnblogs.DashScope.Core/ImageGenerationInput.cs +++ b/src/Cnblogs.DashScope.Core/ImageGenerationInput.cs @@ -8,10 +8,10 @@ public class ImageGenerationInput /// /// The image url to generation new image from. /// - public required string ImageUrl { get; set; } + public string ImageUrl { get; set; } = string.Empty; /// /// The style the new image should use, checkout docs for sample image of different indexes: https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-wanxiang-style-repaint /// - public required int StyleIndex { get; set; } + public int StyleIndex { get; set; } } diff --git a/src/Cnblogs.DashScope.Core/ImageSynthesisInput.cs b/src/Cnblogs.DashScope.Core/ImageSynthesisInput.cs index 9c78118..21c0dcc 100644 --- a/src/Cnblogs.DashScope.Core/ImageSynthesisInput.cs +++ b/src/Cnblogs.DashScope.Core/ImageSynthesisInput.cs @@ -8,7 +8,7 @@ public class ImageSynthesisInput /// /// The prompt to generate image from. This will be chopped at max length of 500 characters. /// - public required string Prompt { get; set; } + public string Prompt { get; set; } = string.Empty; /// /// The negative prompt to generate image from. This will be chopped at max length of 500 characters. diff --git a/src/Cnblogs.DashScope.Core/Internals/DashScopeDateTimeConvertor.cs b/src/Cnblogs.DashScope.Core/Internals/DashScopeDateTimeConvertor.cs index c4c9987..45fc52f 100644 --- a/src/Cnblogs.DashScope.Core/Internals/DashScopeDateTimeConvertor.cs +++ b/src/Cnblogs.DashScope.Core/Internals/DashScopeDateTimeConvertor.cs @@ -6,11 +6,7 @@ namespace Cnblogs.DashScope.Core.Internals; internal class DashScopeDateTimeConvertor : JsonConverter { - private static readonly string[] DateTimeFormats = - [ - "yyyy-MM-dd HH:mm:ss.fff", - "yyyy-MM-dd HH:mm:ss.FFF" - ]; + private static readonly string[] DateTimeFormats = { "yyyy-MM-dd HH:mm:ss.fff", "yyyy-MM-dd HH:mm:ss.FFF" }; /// public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) diff --git a/src/Cnblogs.DashScope.Core/Internals/JsonSeparatorNamingPolicy.cs b/src/Cnblogs.DashScope.Core/Internals/JsonSeparatorNamingPolicy.cs new file mode 100644 index 0000000..761ae20 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/Internals/JsonSeparatorNamingPolicy.cs @@ -0,0 +1,128 @@ +using System.Buffers; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Text.Json; + +namespace Cnblogs.DashScope.Core.Internals; + +// back-porting from dotnet/runtime +internal abstract class JsonSeparatorNamingPolicy : JsonNamingPolicy +{ + private readonly bool _lowercase; + private readonly char _separator; + + internal JsonSeparatorNamingPolicy(bool lowercase, char separator) + { + _lowercase = lowercase; + _separator = separator; + } + + public sealed override string ConvertName(string? name) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + return ConvertNameCore(_separator, _lowercase, name.AsSpan()); + } + + private static string ConvertNameCore(char separator, bool lowercase, ReadOnlySpan chars) + { + var rentedBuffer = (char[]?)null; + var minimumLength = (int)(1.2 * chars.Length); + var destination = minimumLength > 128 /*0x80*/ + ? (Span)(rentedBuffer = ArrayPool.Shared.Rent(minimumLength)) + : stackalloc char[128 /*0x80*/]; + var separatorState = SeparatorState.NotStarted; + var charsWritten = 0; + for (var index = 0; index < chars.Length; ++index) + { + var c = chars[index]; + var unicodeCategory = char.GetUnicodeCategory(c); + switch (unicodeCategory) + { + case UnicodeCategory.UppercaseLetter: + switch (separatorState) + { + case SeparatorState.UppercaseLetter: + if (index + 1 < chars.Length && char.IsLower(chars[index + 1])) + { + WriteChar(separator, ref destination); + } + + break; + case SeparatorState.LowercaseLetterOrDigit: + case SeparatorState.SpaceSeparator: + WriteChar(separator, ref destination); + break; + } + + if (lowercase) + c = char.ToLowerInvariant(c); + WriteChar(c, ref destination); + separatorState = SeparatorState.UppercaseLetter; + break; + case UnicodeCategory.LowercaseLetter: + case UnicodeCategory.DecimalDigitNumber: + if (separatorState == SeparatorState.SpaceSeparator) + WriteChar(separator, ref destination); + if (!lowercase && unicodeCategory == UnicodeCategory.LowercaseLetter) + c = char.ToUpperInvariant(c); + WriteChar(c, ref destination); + separatorState = SeparatorState.LowercaseLetterOrDigit; + break; + case UnicodeCategory.SpaceSeparator: + if (separatorState != SeparatorState.NotStarted) + { + separatorState = SeparatorState.SpaceSeparator; + } + + break; + default: + WriteChar(c, ref destination); + separatorState = SeparatorState.NotStarted; + break; + } + } + + var str = destination.Slice(0, charsWritten).ToString(); + if (rentedBuffer != null) + { + destination.Slice(0, charsWritten).Clear(); + ArrayPool.Shared.Return(rentedBuffer); + } + + return str; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + void WriteChar(char value, ref Span destination) + { + if (charsWritten == destination.Length) + ExpandBuffer(ref destination); + destination[charsWritten++] = value; + } + + void ExpandBuffer(ref Span destination) + { + var destination1 = ArrayPool.Shared.Rent(checked(destination.Length * 2)); + destination.CopyTo((Span)destination1); + if (rentedBuffer != null) + { + destination.Slice(0, charsWritten).Clear(); + ArrayPool.Shared.Return(rentedBuffer); + } + + rentedBuffer = destination1; + destination = (Span)rentedBuffer; + } + } + + private enum SeparatorState + { + NotStarted, + UppercaseLetter, + LowercaseLetterOrDigit, + SpaceSeparator, + } +} diff --git a/src/Cnblogs.DashScope.Core/Internals/JsonSnakeCaseLowerNamingPolicy.cs b/src/Cnblogs.DashScope.Core/Internals/JsonSnakeCaseLowerNamingPolicy.cs new file mode 100644 index 0000000..23d1f48 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/Internals/JsonSnakeCaseLowerNamingPolicy.cs @@ -0,0 +1,11 @@ +namespace Cnblogs.DashScope.Core.Internals; + +internal class JsonSnakeCaseLowerNamingPolicy : JsonSeparatorNamingPolicy +{ + public static readonly JsonSnakeCaseLowerNamingPolicy SnakeCaseLower = new(); + + private JsonSnakeCaseLowerNamingPolicy() + : base(true, '_') + { + } +} diff --git a/src/Cnblogs.DashScope.Core/Internals/TextGenerationStopConvertor.cs b/src/Cnblogs.DashScope.Core/Internals/TextGenerationStopConvertor.cs index 1efd6b5..5f704a8 100644 --- a/src/Cnblogs.DashScope.Core/Internals/TextGenerationStopConvertor.cs +++ b/src/Cnblogs.DashScope.Core/Internals/TextGenerationStopConvertor.cs @@ -77,21 +77,21 @@ private static TextGenerationStop ReadArray(ref Utf8JsonReader reader) case JsonTokenType.EndArray: return type switch { - DeserializationArrayType.Strings => stringList ?? [], - DeserializationArrayType.Token => intList?.ToArray() ?? [], - DeserializationArrayType.Tokens => tokenList ?? [], + DeserializationArrayType.Strings => stringList ?? new List(), + DeserializationArrayType.Token => intList?.ToArray() ?? Array.Empty(), + DeserializationArrayType.Tokens => tokenList ?? new List(), _ => throw new JsonException("Impossible deserialization type") }; case JsonTokenType.StartArray when type is DeserializationArrayType.Tokens: - tokenList ??= []; + tokenList ??= new List(); tokenList.Add(ReadTokenId(ref reader)); break; case JsonTokenType.Number when type is DeserializationArrayType.Token: - intList ??= []; + intList ??= new List(); intList.Add(reader.GetInt32()); break; case JsonTokenType.String when type is DeserializationArrayType.Strings: - stringList ??= []; + stringList ??= new List(); stringList.Add(reader.GetString()!); break; default: diff --git a/src/Cnblogs.DashScope.Core/ModelRequest.cs b/src/Cnblogs.DashScope.Core/ModelRequest.cs index 69ad50c..93fbfff 100644 --- a/src/Cnblogs.DashScope.Core/ModelRequest.cs +++ b/src/Cnblogs.DashScope.Core/ModelRequest.cs @@ -10,12 +10,12 @@ public class ModelRequest /// /// The model to use. /// - public required string Model { get; init; } + public string Model { get; init; } = string.Empty; /// /// Input of this request. /// - public required TInput Input { get; init; } + public TInput Input { get; init; } = null!; } /// diff --git a/src/Cnblogs.DashScope.Core/MultimodalInput.cs b/src/Cnblogs.DashScope.Core/MultimodalInput.cs index 775b4d5..251e0ac 100644 --- a/src/Cnblogs.DashScope.Core/MultimodalInput.cs +++ b/src/Cnblogs.DashScope.Core/MultimodalInput.cs @@ -8,5 +8,5 @@ public class MultimodalInput /// /// The messages of context, model will generate from last user message. /// - public required IEnumerable Messages { get; set; } + public IEnumerable Messages { get; set; } = Array.Empty(); } diff --git a/src/Cnblogs.DashScope.Core/MultimodalMessageContent.cs b/src/Cnblogs.DashScope.Core/MultimodalMessageContent.cs index 98fff19..aee7879 100644 --- a/src/Cnblogs.DashScope.Core/MultimodalMessageContent.cs +++ b/src/Cnblogs.DashScope.Core/MultimodalMessageContent.cs @@ -1,6 +1,4 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Cnblogs.DashScope.Core; +namespace Cnblogs.DashScope.Core; /// /// Represents one content of a . @@ -12,10 +10,8 @@ namespace Cnblogs.DashScope.Core; /// For qwen-vl-ocr only. Minimal pixels for ocr task. /// For qwen-vl-ocr only. Maximum pixels for ocr task. public record MultimodalMessageContent( - [StringSyntax(StringSyntaxAttribute.Uri)] string? Image = null, string? Text = null, - [StringSyntax(StringSyntaxAttribute.Uri)] string? Audio = null, IEnumerable? Video = null, int? MinPixels = null, diff --git a/src/Cnblogs.DashScope.Core/QWenTokenizer.cs b/src/Cnblogs.DashScope.Core/QWenTokenizer.cs index 3deec09..f114a14 100644 --- a/src/Cnblogs.DashScope.Core/QWenTokenizer.cs +++ b/src/Cnblogs.DashScope.Core/QWenTokenizer.cs @@ -1,48 +1,35 @@ -using System.Text.RegularExpressions; -using Cnblogs.DashScope.Core.Internals; -using Microsoft.ML.Tokenizers; +using Cnblogs.DashScope.Core.Internals; +using Microsoft.DeepDev; namespace Cnblogs.DashScope.Core; /// -/// Local implementation for QWen tokenizer +/// Tokenizer using QWen /// -public partial class QWenTokenizer +public class QWenTokenizer { private static readonly Dictionary SpecialTokens = - new List - { - "<|endoftext|>", - "<|im_start|>", - "<|im_end|>" - } + new[] { "<|endoftext|>", "<|im_start|>", "<|im_end|>" } .Concat(Enumerable.Range(0, 205).Select(x => $"<|extra_{x}|>")) .Select((x, i) => new KeyValuePair(x, 151643 + i)) - .ToDictionary(); - - [GeneratedRegex( - @"(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+", - RegexOptions.Compiled, - "zh-CN")] - private static partial Regex Pattern(); + .ToDictionary(x => x.Key, x => x.Value); /// - /// Created tokenizer + /// Static tokenizer /// - public static Tokenizer Tokenizer { get; } = TiktokenTokenizer.Create( + public static readonly ITokenizer Tokenizer = TokenizerBuilder.CreateTokenizer( DashScopeEmbeddedResource.ReadBpeFile(), - new RegexPreTokenizer(Pattern(), SpecialTokens), - null, - SpecialTokens); + SpecialTokens, + @"(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+"); /// - /// Encode text to tokens. + /// Encode text. /// - /// The text to encode. + /// The text to be encoded. /// - public static IReadOnlyList Encode(string text) + public static List Encode(string text) { - return Tokenizer.EncodeToIds(text); + return Tokenizer.Encode(text, false); } /// @@ -56,25 +43,42 @@ public static string Decode(int[] tokens) } /// - /// Get token count for text. + /// Count tokens. + /// + /// Input text. + /// + public int CountTokens(string text) + { + return Tokenizer.Encode(text).Count; + } + + /// + /// Split text to string tokens. + /// + /// Input text. + /// + public IReadOnlyList GetTokens(string text) + { + return Tokenizer.Encode(text).Select(x => Tokenizer.Decode(new[] { x })).ToList(); + } + + /// + /// Count tokens. /// - /// The text to tokenize. + /// The text to be tokenized. /// - public static int CountTokens(string text) + public static int CountTokensStatic(string text) { - return Tokenizer.CountTokens(text); + return Tokenizer.Encode(text).Count; } /// - /// Find the index of the maximum encoding capacity without surpassing the token limit. + /// Get tokens /// - /// The input text. - /// The maximum number of tokens to encode. - /// If the tokenizer's normalization is enabled or is , this will be set to in its normalized form; otherwise, this value will be set to . - /// The token count can be generated which should be smaller than the maximum token count. + /// The text to tokenizers. /// - public static int GetIndexByTokenCount(string text, int maxTokenCount, out string? normalizedText, out int tokenCount) + public static IReadOnlyList GetTokensStatic(string text) { - return Tokenizer.GetIndexByTokenCount(text, maxTokenCount, out normalizedText, out tokenCount); + return Tokenizer.Encode(text).Select(x => Tokenizer.Decode(new[] { x })).ToList(); } } diff --git a/src/Cnblogs.DashScope.Core/TextChatMessage.cs b/src/Cnblogs.DashScope.Core/TextChatMessage.cs index 7191191..f61a033 100644 --- a/src/Cnblogs.DashScope.Core/TextChatMessage.cs +++ b/src/Cnblogs.DashScope.Core/TextChatMessage.cs @@ -6,20 +6,7 @@ namespace Cnblogs.DashScope.Core; /// /// Represents a chat message between the user and the model. /// -/// The role of this message. -/// The content of this message. -/// Used when role is tool, represents the function name of this message generated by. -/// Notify model that next message should use this message as prefix. -/// Reasoning content for reasoning model. -/// Calls to the function. -[method: JsonConstructor] -public record TextChatMessage( - string Role, - string Content, - string? Name = null, - bool? Partial = null, - string? ReasoningContent = null, - List? ToolCalls = null) : IMessage +public record TextChatMessage : IMessage { /// /// Create chat message from an uploaded DashScope file. @@ -39,6 +26,50 @@ public TextChatMessage(IEnumerable fileIds) { } + /// + /// Represents a chat message between the user and the model. + /// + /// The role of this message. + /// The content of this message. + /// Used when role is tool, represents the function name of this message generated by. + /// Notify model that next message should use this message as prefix. + /// Reasoning content for reasoning model. + /// Calls to the function. + [JsonConstructor] + public TextChatMessage( + string role, + string content, + string? name = null, + bool? partial = null, + string? reasoningContent = null, + List? toolCalls = null) + { + this.Role = role; + this.Content = content; + this.Name = name; + this.Partial = partial; + this.ReasoningContent = reasoningContent; + this.ToolCalls = toolCalls; + } + + /// The role of this message. + public string Role { get; init; } + + /// The content of this message. + public string Content { get; init; } + + /// Used when role is tool, represents the function name of this message generated by. + public string? Name { get; init; } + + /// Notify model that next message should use this message as prefix. + public bool? Partial { get; init; } + + /// Reasoning content for reasoning model. + public string? ReasoningContent { get; init; } + + /// Calls to the function. + public List? ToolCalls { get; init; } + /// /// Creates a file message. /// diff --git a/src/Cnblogs.DashScope.Core/TextEmbeddingInput.cs b/src/Cnblogs.DashScope.Core/TextEmbeddingInput.cs index 41295eb..fb884a2 100644 --- a/src/Cnblogs.DashScope.Core/TextEmbeddingInput.cs +++ b/src/Cnblogs.DashScope.Core/TextEmbeddingInput.cs @@ -8,5 +8,5 @@ public class TextEmbeddingInput /// /// The texts to be computed. /// - public required IEnumerable Texts { get; set; } + public IEnumerable Texts { get; set; } = Array.Empty(); } diff --git a/src/Cnblogs.DashScope.Core/TextGenerationChoice.cs b/src/Cnblogs.DashScope.Core/TextGenerationChoice.cs index 6f5d7ab..51eb4ac 100644 --- a/src/Cnblogs.DashScope.Core/TextGenerationChoice.cs +++ b/src/Cnblogs.DashScope.Core/TextGenerationChoice.cs @@ -13,5 +13,5 @@ public class TextGenerationChoice /// /// The generated message. /// - public required TextChatMessage Message { get; set; } + public TextChatMessage Message { get; set; } = new(Array.Empty()); } diff --git a/src/Cnblogs.DashScope.Sdk/Cnblogs.DashScope.Sdk.csproj b/src/Cnblogs.DashScope.Sdk/Cnblogs.DashScope.Sdk.csproj index 3480ef8..68ba835 100644 --- a/src/Cnblogs.DashScope.Sdk/Cnblogs.DashScope.Sdk.csproj +++ b/src/Cnblogs.DashScope.Sdk/Cnblogs.DashScope.Sdk.csproj @@ -4,9 +4,6 @@ true Cnblogs;Dashscope;AI;Sdk;Embedding; - - - diff --git a/src/Cnblogs.DashScope.Sdk/FunctionDefinition.cs b/src/Cnblogs.DashScope.Sdk/FunctionDefinition.cs index 1344496..042f5c5 100644 --- a/src/Cnblogs.DashScope.Sdk/FunctionDefinition.cs +++ b/src/Cnblogs.DashScope.Sdk/FunctionDefinition.cs @@ -1,5 +1,4 @@ using Cnblogs.DashScope.Core; -using Json.Schema; namespace Cnblogs.DashScope.Sdk; @@ -13,8 +12,8 @@ public record FunctionDefinition : IFunctionDefinition /// /// The name of the function. /// Descriptions about this function for model to reference on. - /// Parameter maps of this function. - public FunctionDefinition(string name, string description, JsonSchema? parameters) + /// Parameter maps of this function, can be dictionary or JsonSchema. + public FunctionDefinition(string name, string description, object? parameters) { Name = name; Description = description; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ChatClientTests.cs b/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs similarity index 92% rename from test/Cnblogs.DashScope.Sdk.UnitTests/ChatClientTests.cs rename to test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs index c1f5096..84f54c9 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ChatClientTests.cs +++ b/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs @@ -1,12 +1,12 @@ using System.Text; using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using Microsoft.Extensions.AI; using NSubstitute; using NSubstitute.Extensions; -namespace Cnblogs.DashScope.Sdk.UnitTests; +namespace Cnblogs.DashScope.AI.UnitTests; public class ChatClientTests { @@ -28,7 +28,7 @@ public async Task ChatClient_TextCompletion_SuccessAsync() // Act var response = await client.GetResponseAsync( content, - new ChatOptions() + new ChatOptions { FrequencyPenalty = parameter?.RepetitionPenalty, PresencePenalty = parameter?.PresencePenalty, @@ -69,7 +69,7 @@ public async Task ChatClient_TextCompletionStream_SuccessAsync() // Act var response = client.GetStreamingResponseAsync( content, - new ChatOptions() + new ChatOptions { FrequencyPenalty = parameter?.RepetitionPenalty, PresencePenalty = parameter?.PresencePenalty, @@ -79,7 +79,7 @@ public async Task ChatClient_TextCompletionStream_SuccessAsync() Temperature = parameter?.Temperature, TopK = parameter?.TopK, TopP = parameter?.TopP, - StopSequences = ["你好"], + StopSequences = new List { "你好" }, ToolMode = ChatToolMode.Auto }); var text = new StringBuilder(); @@ -113,7 +113,10 @@ public async Task ChatClient_ImageRecognition_SuccessAsync() { new( ChatRole.User, - [new DataContent(contents[0].Image!, "image/png"), new TextContent(contents[1].Text)]) + new List + { + new DataContent(contents[0].Image!, "image/png"), new TextContent(contents[1].Text) + }), }; var parameter = testCase.RequestModel.Parameters; @@ -157,14 +160,17 @@ public async Task ChatClient_ImageRecognitionStream_SuccessAsync() { new( ChatRole.User, - [new DataContent(contents[0].Image!, "image/png"), new TextContent(contents[1].Text)]) + new List + { + new DataContent(contents[0].Image!, "image/png"), new TextContent(contents[1].Text) + }) }; var parameter = testCase.RequestModel.Parameters; // Act var response = client.GetStreamingResponseAsync( messages, - new ChatOptions() + new ChatOptions { FrequencyPenalty = parameter?.RepetitionPenalty, PresencePenalty = parameter?.PresencePenalty, diff --git a/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj b/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj new file mode 100644 index 0000000..4c729f0 --- /dev/null +++ b/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj @@ -0,0 +1,32 @@ + + + + net8.0 + enable + enable + false + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/EmbeddingClientTests.cs b/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs similarity index 91% rename from test/Cnblogs.DashScope.Sdk.UnitTests/EmbeddingClientTests.cs rename to test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs index 96e21b4..f8bad1b 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/EmbeddingClientTests.cs +++ b/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs @@ -1,11 +1,11 @@ using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using Microsoft.Extensions.AI; using NSubstitute; using NSubstitute.Extensions; -namespace Cnblogs.DashScope.Sdk.UnitTests; +namespace Cnblogs.DashScope.AI.UnitTests; public class EmbeddingClientTests { @@ -27,7 +27,7 @@ public async Task EmbeddingClient_Text_SuccessAsync() // Act var response = await client.GenerateAsync( content, - new EmbeddingGenerationOptions() + new EmbeddingGenerationOptions { ModelId = testCase.RequestModel.Model, Dimensions = parameter?.Dimension }); diff --git a/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Cnblogs.DashScope.Sdk.SnapshotGenerator.csproj b/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Cnblogs.DashScope.Sdk.SnapshotGenerator.csproj index 8c791ae..c23a53c 100644 --- a/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Cnblogs.DashScope.Sdk.SnapshotGenerator.csproj +++ b/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Cnblogs.DashScope.Sdk.SnapshotGenerator.csproj @@ -1,6 +1,7 @@  + net8.0 Exe false diff --git a/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Program.cs b/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Program.cs index 3f99f6b..83ba9e2 100644 --- a/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Program.cs +++ b/test/Cnblogs.DashScope.Sdk.SnapshotGenerator/Program.cs @@ -11,7 +11,7 @@ apiKey = Console.ReadLine(); } -var handler = new SocketsHttpHandler() { AutomaticDecompression = DecompressionMethods.All, }; +var handler = new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.All, }; var client = new HttpClient(handler) { BaseAddress = new Uri("https://dashscope.aliyuncs.com/api/v1/") }; client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}"); diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs index a8021a0..d6de7a6 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs index 6754aa2..91c44c4 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/BaiChuanApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/BaiChuanApiTests.cs index 1184b1a..0d99cac 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/BaiChuanApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/BaiChuanApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; using Cnblogs.DashScope.Sdk.BaiChuan; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj b/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj index 3f82c79..94a3a5e 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj @@ -1,39 +1,39 @@ - - false - true - + + net6.0 + false + true + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + - - - Always - - + + + Always + + - - - - + + + + diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/DeepSeekTextGenerationApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/DeepSeekTextGenerationApiTests.cs index 5bc1956..461b037 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/DeepSeekTextGenerationApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/DeepSeekTextGenerationApiTests.cs @@ -13,7 +13,9 @@ public async Task TextCompletion_UseEnum_SuccessAsync() var client = Substitute.For(); // Act - await client.GetDeepSeekChatCompletionAsync(DeepSeekLlm.DeepSeekR1, [TextChatMessage.User("你好")]); + await client.GetDeepSeekChatCompletionAsync( + DeepSeekLlm.DeepSeekR1, + new List { TextChatMessage.User("你好") }.AsReadOnly()); // Assert await client.Received().GetTextCompletionAsync( @@ -29,7 +31,9 @@ public async Task TextCompletion_UseCustomModel_SuccessAsync() var client = Substitute.For(); // Act - await client.GetDeepSeekChatCompletionAsync(customModel, [TextChatMessage.User("你好")]); + await client.GetDeepSeekChatCompletionAsync( + customModel, + new List { TextChatMessage.User("你好") }.AsReadOnly()); // Assert await client.Received().GetTextCompletionAsync( @@ -44,7 +48,9 @@ public void StreamCompletion_UseEnum_SuccessAsync() var client = Substitute.For(); // Act - _ = client.GetDeepSeekChatCompletionStreamAsync(DeepSeekLlm.DeepSeekV3, [TextChatMessage.User("你好")]); + _ = client.GetDeepSeekChatCompletionStreamAsync( + DeepSeekLlm.DeepSeekV3, + new List { TextChatMessage.User("你好") }.AsReadOnly()); // Assert _ = client.Received().GetTextCompletionStreamAsync( @@ -62,7 +68,9 @@ public void StreamCompletion_CustomModel_SuccessAsync() var client = Substitute.For(); // Act - _ = client.GetDeepSeekChatCompletionStreamAsync(customModel, [TextChatMessage.User("你好")]); + _ = client.GetDeepSeekChatCompletionStreamAsync( + customModel, + new List { TextChatMessage.User("你好") }.AsReadOnly()); // Assert _ = client.Received().GetTextCompletionStreamAsync( diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs index e660852..ba17907 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs @@ -1,5 +1,5 @@ using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; using NSubstitute.ExceptionExtensions; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs index 05faa58..9b92f25 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs index d0d30b7..752e922 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs index 909c6bf..47013e0 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Llama2TextGenerationApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Llama2TextGenerationApiTests.cs index 29c1a8c..c4d5679 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Llama2TextGenerationApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Llama2TextGenerationApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; using Cnblogs.DashScope.Sdk.Llama2; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs index 8889981..0170d0d 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs @@ -1,6 +1,6 @@ using System.Text; using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenMultimodalApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenMultimodalApiTests.cs index e3b5424..c2c15ce 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenMultimodalApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenMultimodalApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; using Cnblogs.DashScope.Sdk.QWenMultimodal; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; @@ -8,13 +8,15 @@ namespace Cnblogs.DashScope.Sdk.UnitTests; public class QWenMultimodalApiTests { private static readonly List Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent("https://cdn.example.com/image.jpg"), - MultimodalMessageContent.TextContent("说明一下这张图片的内容") - ]) - ]; + new() + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent("https://cdn.example.com/image.jpg"), + MultimodalMessageContent.TextContent("说明一下这张图片的内容") + }.AsReadOnly()) + }; [Fact] public async Task Multimodal_UseEnum_SuccessAsync() diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTextGenerationApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTextGenerationApiTests.cs index ad9d5fb..ddd6640 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTextGenerationApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTextGenerationApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; using Cnblogs.DashScope.Sdk.QWen; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs index 8f91a35..69f0192 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs @@ -9,475 +9,42 @@ public class QWenTokenizerTests "很不错的一款产品,送人的额,非常喜欢,很不错,好评哦,以后还会多多支持的\n已经吃了,感觉不错。第二次购买,这个价格很实惠,卖家还赠送了美容器和尺子,很愉悦的一次购物。\n衣服的质量杠杠的,很漂亮,不枉我等了这么久啊,喜欢,以后还来这里买,我一次买了四件不到200块钱,真好\n用了一段时间了,感觉比传统的风扇好用,广度大,档数多,静音效果也不错,关键是还很漂亮!\n这个热量低,比意面还低,关键是口感还好,挺好吃,多煮一会一级棒,我的减脂早餐就靠它了\n整体评价:好 使用效果:好 包装与外观:好 三好商品\n电视机很好,我给老爸买的,老人很喜欢,图像清晰,音质很好,老人喜欢我满意。\n宝贝很轻巧,打的时候网弹力很足,儿子非常喜欢,五分好评,还送了羽毛球噢!\n终于装上,风很大,热的还可以,排风声音不小,安装的师傅说不能直吹,安装的时候非常满意,最后还帮忙把棚顶给擦干净了,非常感谢。\n颜色很美。就是别人的盒子都是平整的,唯独我的盒子有很严重的压痕。本来想直接用这个盒子装胶带的..现在这个样子强迫症看着实在很糟心。压成这样要么包装有问题,要么本来产品就有问题。而卖家一直在甩锅快递。由于包裹是被家里人拆开的,所以我也不知道是什么样子的,不好跟卖家掰扯。但我看别的人都是纸盒装的,想来我这个也是纸盒装的。那么排除包装的原因的话,很可能就是寄过来的就是个瑕疵品。比起同样今天到货的另一家,有个小瑕疵立马给我补寄了一个,这家的处理方式真的..换货..或者直接道歉说疏忽我都接受的。甩锅真的不能忍。本来还给好几个人推了这家店...就挺失望的 以后应该不会来了。这坚定的甩锅态度我也不点退换了..请不要给我打电话改评,谢谢。"; private static readonly int[] Tokens = - [ - 109517, - 110659, - 82700, - 3837, - 36605, - 103947, - 61191, - 3837, - 115171, - 3837, - 109517, - 3837, - 102959, - 104170, - 3837, - 103934, - 104342, - 103235, - 100143, - 9370, - 198, - 99461, - 105705, - 3837, - 100681, - 100832, - 1773, - 106309, - 103946, - 3837, - 99487, - 97480, - 99165, - 109896, - 3837, - 108602, - 97706, - 109349, - 34187, - 105157, - 31548, - 33108, - 101489, - 44729, - 3837, - 99165, - 111985, - 99774, - 32571, - 102297, - 8997, - 102214, - 108042, - 103178, - 103178, - 9370, - 3837, - 117817, - 3837, - 16530, - 119117, - 35946, - 49567, - 34187, - 113260, - 103924, - 3837, - 99729, - 3837, - 103934, - 97706, - 115217, - 99565, - 3837, - 35946, - 99796, - 105275, - 63703, - 14224, - 99828, - 17, - 15, - 15, - 106734, - 3837, - 88051, - 52801, - 198, - 11622, - 99593, - 101430, - 34187, - 3837, - 100681, - 56006, - 105062, - 117814, - 52801, - 11622, - 3837, - 80942, - 26381, - 26288, - 3837, - 100104, - 8863, - 42140, - 3837, - 99541, - 78685, - 101062, - 116006, - 3837, - 111623, - 97706, - 117817, - 6313, - 198, - 99487, - 108461, - 99285, - 3837, - 56006, - 36589, - 27091, - 97706, - 99285, - 3837, - 111623, - 107816, - 108432, - 3837, - 101174, - 106678, - 3837, - 42140, - 104783, - 102947, - 105072, - 102321, - 3837, - 97611, - 99536, - 100553, - 102589, - 80158, - 99904, - 99652, - 34187, - 198, - 101932, - 103964, - 5122, - 52801, - 85658, - 101062, - 5122, - 52801, - 94305, - 227, - 98641, - 57218, - 105502, - 5122, - 52801, - 220, - 44991, - 52801, - 45943, - 198, - 115281, - 101243, - 3837, - 35946, - 89012, - 114198, - 108850, - 3837, - 102032, - 108295, - 3837, - 107553, - 104542, - 3837, - 78685, - 99178, - 101243, - 3837, - 102032, - 99729, - 35946, - 100545, - 8997, - 105882, - 99165, - 99578, - 100084, - 3837, - 75437, - 103920, - 31139, - 100080, - 47534, - 99165, - 99336, - 3837, - 102067, - 115171, - 3837, - 75108, - 17177, - 102959, - 3837, - 97706, - 36605, - 34187, - 116140, - 118401, - 6313, - 198, - 104020, - 98641, - 17447, - 3837, - 99208, - 101235, - 3837, - 99259, - 9370, - 104468, - 3837, - 59956, - 99208, - 102274, - 112592, - 3837, - 103999, - 9370, - 105476, - 36587, - 53153, - 73145, - 102203, - 3837, - 103999, - 103920, - 99491, - 100545, - 3837, - 100161, - 97706, - 106128, - 99360, - 103031, - 99743, - 89012, - 101432, - 102466, - 34187, - 3837, - 99491, - 104305, - 8997, - 102284, - 99165, - 57566, - 1773, - 99486, - 107693, - 110792, - 100132, - 112857, - 9370, - 3837, - 100473, - 99510, - 97611, - 110792, - 18830, - 99165, - 105806, - 99451, - 101629, - 1773, - 102347, - 99172, - 101041, - 11622, - 99487, - 110792, - 98641, - 100773, - 99278, - 9370, - 496, - 99601, - 99487, - 102481, - 111057, - 99769, - 101952, - 100538, - 99165, - 103336, - 63109, - 1773, - 99451, - 12857, - 99654, - 106016, - 104184, - 110686, - 3837, - 106016, - 102347, - 82700, - 104435, - 86119, - 1773, - 68536, - 108602, - 105078, - 107001, - 101240, - 104655, - 1773, - 101887, - 108232, - 20412, - 99250, - 102078, - 17340, - 101348, - 29767, - 9370, - 3837, - 107020, - 107066, - 102021, - 102481, - 9370, - 3837, - 101132, - 99557, - 108602, - 119059, - 105948, - 1773, - 105984, - 50930, - 62922, - 100623, - 100132, - 100050, - 102307, - 98641, - 9370, - 3837, - 99172, - 36407, - 35946, - 99487, - 100000, - 100050, - 102307, - 98641, - 9370, - 1773, - 100624, - 102945, - 104184, - 104249, - 100363, - 3837, - 107093, - 99486, - 101400, - 101180, - 105729, - 18947, - 117219, - 24442, - 1773, - 107957, - 101165, - 100644, - 26939, - 81668, - 9370, - 100266, - 45629, - 3837, - 104627, - 30709, - 117219, - 108628, - 104169, - 99622, - 101400, - 104059, - 3837, - 101610, - 9370, - 54542, - 75768, - 100672, - 496, - 71134, - 81668, - 496, - 100631, - 101041, - 107961, - 36587, - 100900, - 100310, - 107108, - 100669, - 9370, - 1773, - 107001, - 101240, - 100672, - 53153, - 100292, - 1773, - 102347, - 97706, - 89012, - 52801, - 112285, - 83751, - 34187, - 101610, - 71416, - 1112, - 80158, - 101174, - 106586, - 9370, - 220, - 103934, - 99730, - 99670, - 101161, - 1773, - 43288, - 102405, - 9370, - 107001, - 101240, - 102316, - 35946, - 99744, - 27442, - 55806, - 110735, - 496, - 14880, - 100148, - 104169, - 106202, - 22418, - 63379, - 3837, - 102570, - 1773 - ]; + new[] + { + 109517, 110659, 82700, 3837, 36605, 103947, 61191, 3837, 115171, 3837, 109517, 3837, 102959, 104170, + 3837, 103934, 104342, 103235, 100143, 9370, 198, 99461, 105705, 3837, 100681, 100832, 1773, 106309, + 103946, 3837, 99487, 97480, 99165, 109896, 3837, 108602, 97706, 109349, 34187, 105157, 31548, 33108, + 101489, 44729, 3837, 99165, 111985, 99774, 32571, 102297, 8997, 102214, 108042, 103178, 103178, 9370, + 3837, 117817, 3837, 16530, 119117, 35946, 49567, 34187, 113260, 103924, 3837, 99729, 3837, 103934, + 97706, 115217, 99565, 3837, 35946, 99796, 105275, 63703, 14224, 99828, 17, 15, 15, 106734, 3837, 88051, + 52801, 198, 11622, 99593, 101430, 34187, 3837, 100681, 56006, 105062, 117814, 52801, 11622, 3837, 80942, + 26381, 26288, 3837, 100104, 8863, 42140, 3837, 99541, 78685, 101062, 116006, 3837, 111623, 97706, + 117817, 6313, 198, 99487, 108461, 99285, 3837, 56006, 36589, 27091, 97706, 99285, 3837, 111623, 107816, + 108432, 3837, 101174, 106678, 3837, 42140, 104783, 102947, 105072, 102321, 3837, 97611, 99536, 100553, + 102589, 80158, 99904, 99652, 34187, 198, 101932, 103964, 5122, 52801, 85658, 101062, 5122, 52801, 94305, + 227, 98641, 57218, 105502, 5122, 52801, 220, 44991, 52801, 45943, 198, 115281, 101243, 3837, 35946, + 89012, 114198, 108850, 3837, 102032, 108295, 3837, 107553, 104542, 3837, 78685, 99178, 101243, 3837, + 102032, 99729, 35946, 100545, 8997, 105882, 99165, 99578, 100084, 3837, 75437, 103920, 31139, 100080, + 47534, 99165, 99336, 3837, 102067, 115171, 3837, 75108, 17177, 102959, 3837, 97706, 36605, 34187, + 116140, 118401, 6313, 198, 104020, 98641, 17447, 3837, 99208, 101235, 3837, 99259, 9370, 104468, 3837, + 59956, 99208, 102274, 112592, 3837, 103999, 9370, 105476, 36587, 53153, 73145, 102203, 3837, 103999, + 103920, 99491, 100545, 3837, 100161, 97706, 106128, 99360, 103031, 99743, 89012, 101432, 102466, 34187, + 3837, 99491, 104305, 8997, 102284, 99165, 57566, 1773, 99486, 107693, 110792, 100132, 112857, 9370, + 3837, 100473, 99510, 97611, 110792, 18830, 99165, 105806, 99451, 101629, 1773, 102347, 99172, 101041, + 11622, 99487, 110792, 98641, 100773, 99278, 9370, 496, 99601, 99487, 102481, 111057, 99769, 101952, + 100538, 99165, 103336, 63109, 1773, 99451, 12857, 99654, 106016, 104184, 110686, 3837, 106016, 102347, + 82700, 104435, 86119, 1773, 68536, 108602, 105078, 107001, 101240, 104655, 1773, 101887, 108232, 20412, + 99250, 102078, 17340, 101348, 29767, 9370, 3837, 107020, 107066, 102021, 102481, 9370, 3837, 101132, + 99557, 108602, 119059, 105948, 1773, 105984, 50930, 62922, 100623, 100132, 100050, 102307, 98641, 9370, + 3837, 99172, 36407, 35946, 99487, 100000, 100050, 102307, 98641, 9370, 1773, 100624, 102945, 104184, + 104249, 100363, 3837, 107093, 99486, 101400, 101180, 105729, 18947, 117219, 24442, 1773, 107957, 101165, + 100644, 26939, 81668, 9370, 100266, 45629, 3837, 104627, 30709, 117219, 108628, 104169, 99622, 101400, + 104059, 3837, 101610, 9370, 54542, 75768, 100672, 496, 71134, 81668, 496, 100631, 101041, 107961, 36587, + 100900, 100310, 107108, 100669, 9370, 1773, 107001, 101240, 100672, 53153, 100292, 1773, 102347, 97706, + 89012, 52801, 112285, 83751, 34187, 101610, 71416, 1112, 80158, 101174, 106586, 9370, 220, 103934, + 99730, 99670, 101161, 1773, 43288, 102405, 9370, 107001, 101240, 102316, 35946, 99744, 27442, 55806, + 110735, 496, 14880, 100148, 104169, 106202, 22418, 63379, 3837, 102570, 1773 + }; [Fact] public void QWenTokenizer_Encode_SuccessAsync() @@ -503,20 +70,9 @@ public void QWenTokenizer_Decode_SuccessAsync() public void QWenTokenizer_EncodeToStrings_SuccessAsync() { // Act - var tokens = QWenTokenizer.Tokenizer.EncodeToTokens(Text, out _); + var tokens = QWenTokenizer.Tokenizer.Encode(Text); // Assert - tokens.Select(t => t.Id).Should().BeEquivalentTo(Tokens); - } - - [Fact] - public void QWenTokenizer_CountIndex_SuccessAsync() - { - // Act - var maxIndex = QWenTokenizer.GetIndexByTokenCount(Text, 100, out _, out var tokenCount); - - // Assert - maxIndex.Should().Be(155); - tokenCount.Should().BeLessThanOrEqualTo(100); + tokens.Should().BeEquivalentTo(Tokens); } } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.response.body.txt deleted file mode 100644 index 75aba2c..0000000 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.response.body.txt +++ /dev/null @@ -1 +0,0 @@ -{"request_id":"8b22164d-c784-9a31-bda3-3c26259d4213","output":{"task_id":"b2e98d78-c79b-431c-b2d7-c7bcd54465da","task_status":"SUCCEEDED","submit_time":"2024-03-04 10:08:57.333","scheduled_time":"2024-03-04 10:08:57.363","end_time":"2024-03-04 10:09:07.727","text_results":{"urls":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=kmZGXc2s8P4uI%2BVrADITyrPz82U%3D"},{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=cb1Qg%2FkIuZyI7XQqWHjP712N0ak%3D"}],"params":[{"sample_idx":0,"layers":[{"color":"#521b08","top":0,"left":0,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#521b0800"},{"offset":1,"color":"#521b08ff"}],"gradient_units":"pixels","coords":{"y1":257,"x1":0,"y2":0,"x2":0}},"width":1024,"type":"text_mask","idx":0,"opacity":0.8,"radius":0,"height":257},{"font_weight":"Regular","font_size":67,"type":"text","content":"分享好时光","font_under_line":false,"line_height":1,"font_italic":false,"top":25,"sub_type":"Title","font_color":"#e6baa7","left":319,"text_stroke":"1px #fffffff0","width":385,"text_shadow":"1px 0px #80808080","font_family":"站酷文艺体","idx":1,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":77},{"color":"#e6baa7","top":118,"left":395,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#e6baa7ff"},{"offset":1,"color":"#e6baa7ff"}],"gradient_units":"pixels","coords":{"y1":0,"x1":0,"y2":50,"x2":0}},"width":233,"type":"text_mask","idx":2,"opacity":1,"radius":37,"box_shadow":"2px 1px #80808080","height":50},{"font_weight":"Medium","font_size":27,"type":"text","content":"只为不一样的你","font_under_line":false,"line_height":1,"font_italic":false,"top":118,"sub_type":"SubTitle","font_color":"#223629","left":395,"width":233,"text_shadow":0,"font_family":"阿里巴巴普惠体","idx":3,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":50}]},{"sample_idx":1,"layers":[{"color":"#efeae4","top":0,"left":0,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#efeae400"},{"offset":1,"color":"#efeae4ff"}],"gradient_units":"pixels","coords":{"y1":257,"x1":0,"y2":0,"x2":0}},"width":1024,"type":"text_mask","idx":0,"opacity":0.8,"radius":0,"height":257},{"font_weight":"Regular","font_size":67,"type":"text","content":"分享好时光","font_under_line":false,"line_height":1,"font_italic":false,"top":25,"sub_type":"Title","font_color":"#421f12","left":319,"text_stroke":"1px #fffffff0","width":385,"text_shadow":"0px 2px #80808080","font_family":"钉钉进步体","idx":1,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":77},{"color":"#421f12","top":118,"left":395,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#421f12ff"},{"offset":1,"color":"#421f12ff"}],"gradient_units":"pixels","coords":{"y1":0,"x1":0,"y2":50,"x2":0}},"width":233,"type":"text_mask","idx":2,"opacity":1,"radius":37,"box_shadow":"0px 0px #80808080","height":50},{"font_weight":"Regular","font_size":27,"type":"text","content":"只为不一样的你","font_under_line":false,"line_height":1,"font_italic":false,"top":118,"sub_type":"SubTitle","font_color":"#f1eeec","left":395,"width":233,"text_shadow":0,"font_family":"阿里巴巴普惠体","idx":3,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":50}]}]},"results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_0_02dc0bba-8b1d-4648-8b95-eb2b92fe715d.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OYstgSxWOl%2FOxYTLa2Mx3bi2RWw%3D"},{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_1_e1af86ec-152a-4ebe-b2a0-b40a592043b2.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=p0UXTUdXfp0tFlt0K5tDsA%2Fxl1M%3D"}],"task_metrics":{"TOTAL":2,"SUCCEEDED":2,"FAILED":0}},"usage":{"image_count":2}} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt deleted file mode 100644 index 43c0bb2..0000000 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt +++ /dev/null @@ -1 +0,0 @@ -{"request_id":"6662e925-4846-9afe-a3af-0d131805d378","output":{"task_id":"9e2b6ef6-285d-4efa-8651-4dbda7d571fa","task_status":"SUCCEEDED","submit_time":"2024-03-01 17:38:24.817","scheduled_time":"2024-03-01 17:38:24.831","end_time":"2024-03-01 17:38:55.565","results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/1d/d4/20240301/8d820c8d/4c48fa53-2907-499b-b9ac-76477fe8d299-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=bEfLmd%2BarXgZyhxcVYOWs%2BovJb8%3D"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=fdPScmRkIXyH3TSaSaWwvVjxREQ%3D"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/0f/20240301/3ab595ad/ecfe06b3-b91c-4950-a932-49ea1619a1f9-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=gNuVAt8iy4X8Nl2l3K4Gu4f0ydw%3D"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/3d/20240301/3ab595ad/3fca748e-d491-458a-bb72-73649af33209-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=Mx5TueC9I9yfDno9rjzi48opHtM%3D"}],"task_metrics":{"TOTAL":4,"SUCCEEDED":4,"FAILED":0}},"usage":{"image_count":4}} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs index 149d2db..745e9c5 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs @@ -1,5 +1,5 @@ using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingApiTests.cs index bbe1abb..5ad66d3 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; using Cnblogs.DashScope.Sdk.TextEmbedding; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs index a662ade..0b380ce 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs index de32581..9a9406e 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs @@ -1,6 +1,6 @@ using System.Text; using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs index 26c4af3..e269682 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs @@ -50,20 +50,26 @@ public record TestObj(TextGenerationStop? Stop); public static TheoryData Data => new() { - { new TextGenerationStop("hello"), """{"stop":"hello"}""" }, - { new TextGenerationStop(["hello", "world"]), """{"stop":["hello","world"]}""" }, - { new TextGenerationStop([12, 334]), """{"stop":[12,334]}""" }, - { new TextGenerationStop([[12, 334]]), """{"stop":[[12,334]]}""" }, - { null, """{"stop":null}""" } + { new TextGenerationStop("hello"), @"{""stop"":""hello""}" }, + { + new TextGenerationStop(new List { "hello", "world" }.AsReadOnly()), + "{\"stop\":[\"hello\",\"world\"]}" + }, + { new TextGenerationStop(new[] { 12, 334 }), "{\"stop\":[12,334]}" }, + { + new TextGenerationStop(new List { new[] { 12, 334 } }.AsReadOnly()), + "{\"stop\":[[12,334]]}" + }, + { null, "{\"stop\":null}" } }; public static TheoryData InvalidJson => new() { - """{"stop":{}}""", - """{"stop":[1234,"hello"]}""", - """{"stop":["hello"}}""", - """{"stop":[[34243,"hello"]]}""", - """{"stop":[[34243,123]}}""" + "{\"stop\":{}}", + "{\"stop\":[1234,\"hello\"]}", + "{\"stop\":[\"hello\"}}", + "{\"stop\":[[34243,\"hello\"]]}", + "{\"stop\":[[34243,123]}}" }; } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs index 08e4cae..6c3a49b 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using FluentAssertions; using NSubstitute; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs index 077a4b0..c9a23c7 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs @@ -50,19 +50,19 @@ public record TestObj(ToolChoice? Choice); public static TheoryData Data => new() { - { ToolChoice.AutoChoice, """{"choice":"auto"}""" }, - { ToolChoice.NoneChoice, """{"choice":"none"}""" }, - { ToolChoice.FunctionChoice("weather"), """{"choice":{"type":"function","function":{"name":"weather"}}}""" }, - { null, """{"choice":null}""" } + { ToolChoice.AutoChoice, "{\"choice\":\"auto\"}" }, + { ToolChoice.NoneChoice, "{\"choice\":\"none\"}" }, + { ToolChoice.FunctionChoice("weather"), "{\"choice\":{\"type\":\"function\",\"function\":{\"name\":\"weather\"}}}" }, + { null, "{\"choice\":null}" } }; public static TheoryData InvalidJson => new() { - """{"choice":{}}""", - """{"choice":"other"}""", - """{"choice":{"type":"other"}}""", - """{"choice":{"type":"other", "function":{"name": "weather"}}}""", - """{"choice":{"type":"function", "function": "other"}}""" + "{\"choice\":{}}", + "{\"choice\":\"other\"}", + "{\"choice\":{\"type\":\"other\"}}", + "{\"choice\":{\"type\":\"other\", \"function\":{\"name\": \"weather\"}}}", + "{\"choice\":{\"type\":\"function\", \"function\": \"other\"}}" }; } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/GetCurrentWeatherParameters.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/GetCurrentWeatherParameters.cs deleted file mode 100644 index 3d606f3..0000000 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/GetCurrentWeatherParameters.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Text.Json.Serialization; -using Json.More; -using Json.Schema.Generation; - -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; - -public record GetCurrentWeatherParameters( - [property: Required] - [property: Description("要获取天气的省市名称,例如浙江省杭州市")] - string Location, - [property: JsonConverter(typeof(EnumStringConverter))] - [property: Description("温度单位")] - TemperatureUnit Unit = TemperatureUnit.Celsius); - -public enum TemperatureUnit -{ - Celsius, - Fahrenheit -} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs deleted file mode 100644 index 20f17f5..0000000 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs +++ /dev/null @@ -1,517 +0,0 @@ -using Cnblogs.DashScope.Core; - -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; - -public static partial class Snapshots -{ - public static class MultimodalGeneration - { - public static readonly RequestSnapshot, - ModelResponse> VlNoSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - Temperature = 1.1f, - VlHighResolutionImages = true, - RepetitionPenalty = 1.3f, - PresencePenalty = 1.2f, - MaxTokens = 120, - Stop = "你好" - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("海滩。") - ])) - ]), - RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", - Usage = new MultimodalTokenUsage - { - OutputTokens = 3, - InputTokens = 3613, - ImageTokens = 3577 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlChatClientNoSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - Temperature = 1.1f, - RepetitionPenalty = 1.3f, - PresencePenalty = 1.2f, - MaxTokens = 120, - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("海滩。") - ])) - ]), - RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", - Usage = new MultimodalTokenUsage - { - OutputTokens = 3, - InputTokens = 3613, - ImageTokens = 3577 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - IncrementalOutput = true, - Seed = 1234, - TopK = 100, - TopP = 0.81f - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") - ])) - ]), - RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", - Usage = new MultimodalTokenUsage - { - OutputTokens = 85, - InputTokens = 1283, - ImageTokens = 1247 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlChatClientSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - IncrementalOutput = true, - Seed = 1234, - TopK = 100, - TopP = 0.81f, - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") - ])) - ]), - RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", - Usage = new MultimodalTokenUsage - { - OutputTokens = 85, - InputTokens = 1283, - ImageTokens = 1247 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - OcrNoSse = new( - "multimodal-generation-vl-ocr", - new ModelRequest - { - Model = "qwen-vl-ocr", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", - 3136, - 1003520), - MultimodalMessageContent.TextContent("Read all the text in the image.") - ]), - ] - }, - Parameters = new MultimodalParameters - { - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - MaxTokens = 2000, - TopP = 0.01f - } - }, - new ModelResponse - { - RequestId = "195c98cd-4ee5-998b-b662-132b7aebc048", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 1248, - OutputTokens = 225, - ImageTokens = 1219 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - OcrSse = new( - "multimodal-generation-vl-ocr", - new ModelRequest - { - Model = "qwen-vl-ocr", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", - 3136, - 1003520), - MultimodalMessageContent.TextContent("Read all the text in the image.") - ]), - ] - }, - Parameters = new MultimodalParameters - { - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - MaxTokens = 2000, - TopP = 0.01f, - IncrementalOutput = true - } - }, - new ModelResponse - { - RequestId = "fb33a990-3826-9386-8b0a-8317dfc38c1c", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 1248, - OutputTokens = 225, - ImageTokens = 1219 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - AudioNoSse = new( - "multimodal-generation-audio", - new ModelRequest - { - Model = "qwen-audio-turbo", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.AudioContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), - MultimodalMessageContent.TextContent("这段音频在说什么,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f - } - }, - new ModelResponse - { - RequestId = "6b6738bd-dd9d-9e78-958b-02574acbda44", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段音频在说中文,内容是\"没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网\"。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 786, - OutputTokens = 38, - AudioTokens = 752 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - AudioSse = new( - "multimodal-generation-audio", - new ModelRequest - { - Model = "qwen-audio-turbo", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.AudioContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), - MultimodalMessageContent.TextContent("这段音频的第一句话说了什么?") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - IncrementalOutput = true - } - }, - new ModelResponse - { - RequestId = "bb6ab962-af57-99f1-9af8-eb7016ebc18e", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("第一句话说了没有我互联网。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 783, - OutputTokens = 7, - AudioTokens = 752 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - VideoNoSse = new( - "multimodal-generation-vl-video", - new ModelRequest() - { - Model = "qwen-vl-max", - Input = new MultimodalInput() - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.VideoContent( - [ - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" - ]), - MultimodalMessageContent.TextContent("描述这个视频的具体过程") - ]), - ] - }, - Parameters = new MultimodalParameters() - { - Seed = 1234, - TopP = 0.01f, - Temperature = 0.1f, - RepetitionPenalty = 1.05f - } - }, - new ModelResponse() - { - RequestId = "d538f8cc-8048-9ca8-9e8a-d2a49985b479", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:球场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **守门员扑救**:守门员看到对方射门后,立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") - ])) - ]), - Usage = new MultimodalTokenUsage() - { - VideoTokens = 1440, - InputTokens = 1466, - OutputTokens = 180 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - VideoSse = new( - "multimodal-generation-vl-video", - new ModelRequest() - { - Model = "qwen-vl-max", - Input = new MultimodalInput() - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.VideoContent( - [ - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" - ]), - MultimodalMessageContent.TextContent("描述这个视频的具体过程") - ]), - ] - }, - Parameters = new MultimodalParameters() - { - Seed = 1234, - TopP = 0.01f, - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - IncrementalOutput = true - } - }, - new ModelResponse() - { - RequestId = "851745a1-22ba-90e2-ace2-c04e7445ec6f", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **扑救尝试**:守门员看到射门后立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") - ])) - ]), - Usage = new MultimodalTokenUsage() - { - VideoTokens = 1440, - InputTokens = 1466, - OutputTokens = 176 - } - }); - } -} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/WanxApiTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/WanxApiTests.cs index 5a2c830..ff05d7c 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/WanxApiTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/WanxApiTests.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; -using Cnblogs.DashScope.Sdk.UnitTests.Utils; using Cnblogs.DashScope.Sdk.Wanx; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; using NSubstitute.Extensions; diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/WorkspaceIdTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/WorkspaceIdTests.cs index c6b3a98..0c1b445 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/WorkspaceIdTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/WorkspaceIdTests.cs @@ -1,4 +1,4 @@ -using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using Cnblogs.DashScope.Tests.Shared.Utils; using NSubstitute; namespace Cnblogs.DashScope.Sdk.UnitTests; diff --git a/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj b/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj new file mode 100644 index 0000000..6c9b008 --- /dev/null +++ b/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + false + + + + + + + + + + + + + + + + Always + + + + diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-message-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/application-workflow-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/auth-error-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/auth-error-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/background-generation-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/background-generation-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/batch-text-embedding-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/batch-text-embedding-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/cancel-completed-task-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/cancel-completed-task-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-partial-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-partial-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/conversation-generation-message-with-files-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/conversation-generation-message-with-files-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/delete-file-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/delete-file-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-file-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-file-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.response.body.txt new file mode 100644 index 0000000..98e695b --- /dev/null +++ b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.response.body.txt @@ -0,0 +1 @@ +{"request_id":"8b22164d-c784-9a31-bda3-3c26259d4213","output":{"task_id":"b2e98d78-c79b-431c-b2d7-c7bcd54465da","task_status":"SUCCEEDED","submit_time":"2024-03-04 10:08:57.333","scheduled_time":"2024-03-04 10:08:57.363","end_time":"2024-03-04 10:09:07.727","text_results":{"urls":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png"},{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png"}],"params":[{"sample_idx":0,"layers":[{"color":"#521b08","top":0,"left":0,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#521b0800"},{"offset":1,"color":"#521b08ff"}],"gradient_units":"pixels","coords":{"y1":257,"x1":0,"y2":0,"x2":0}},"width":1024,"type":"text_mask","idx":0,"opacity":0.8,"radius":0,"height":257},{"font_weight":"Regular","font_size":67,"type":"text","content":"分享好时光","font_under_line":false,"line_height":1,"font_italic":false,"top":25,"sub_type":"Title","font_color":"#e6baa7","left":319,"text_stroke":"1px #fffffff0","width":385,"text_shadow":"1px 0px #80808080","font_family":"站酷文艺体","idx":1,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":77},{"color":"#e6baa7","top":118,"left":395,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#e6baa7ff"},{"offset":1,"color":"#e6baa7ff"}],"gradient_units":"pixels","coords":{"y1":0,"x1":0,"y2":50,"x2":0}},"width":233,"type":"text_mask","idx":2,"opacity":1,"radius":37,"box_shadow":"2px 1px #80808080","height":50},{"font_weight":"Medium","font_size":27,"type":"text","content":"只为不一样的你","font_under_line":false,"line_height":1,"font_italic":false,"top":118,"sub_type":"SubTitle","font_color":"#223629","left":395,"width":233,"text_shadow":0,"font_family":"阿里巴巴普惠体","idx":3,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":50}]},{"sample_idx":1,"layers":[{"color":"#efeae4","top":0,"left":0,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#efeae400"},{"offset":1,"color":"#efeae4ff"}],"gradient_units":"pixels","coords":{"y1":257,"x1":0,"y2":0,"x2":0}},"width":1024,"type":"text_mask","idx":0,"opacity":0.8,"radius":0,"height":257},{"font_weight":"Regular","font_size":67,"type":"text","content":"分享好时光","font_under_line":false,"line_height":1,"font_italic":false,"top":25,"sub_type":"Title","font_color":"#421f12","left":319,"text_stroke":"1px #fffffff0","width":385,"text_shadow":"0px 2px #80808080","font_family":"钉钉进步体","idx":1,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":77},{"color":"#421f12","top":118,"left":395,"gradient":{"type":"linear","color_stops":[{"offset":0,"color":"#421f12ff"},{"offset":1,"color":"#421f12ff"}],"gradient_units":"pixels","coords":{"y1":0,"x1":0,"y2":50,"x2":0}},"width":233,"type":"text_mask","idx":2,"opacity":1,"radius":37,"box_shadow":"0px 0px #80808080","height":50},{"font_weight":"Regular","font_size":27,"type":"text","content":"只为不一样的你","font_under_line":false,"line_height":1,"font_italic":false,"top":118,"sub_type":"SubTitle","font_color":"#f1eeec","left":395,"width":233,"text_shadow":0,"font_family":"阿里巴巴普惠体","idx":3,"alignment":"center","opacity":1,"font_line_through":false,"direction":"horizontal","height":50}]}]},"results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_0_02dc0bba-8b1d-4648-8b95-eb2b92fe715d.png"},{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_1_e1af86ec-152a-4ebe-b2a0-b40a592043b2.png"}],"task_metrics":{"TOTAL":2,"SUCCEEDED":2,"FAILED":0}},"usage":{"image_count":2}} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-background-generation-success-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-background-generation-success-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-batch-text-embedding-success-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-batch-text-embedding-success-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.response.body.txt similarity index 77% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.response.body.txt index 1cbff88..55681d4 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.response.body.txt +++ b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.response.body.txt @@ -1 +1 @@ -{"request_id":"f927c766-5079-90f8-9354-6a87d2167897","output":{"task_id":"c4f94e00-5899-431b-9579-eb1ebe686379","task_status":"SUCCEEDED","submit_time":"2024-03-02 22:22:13.026","scheduled_time":"2024-03-02 22:22:13.051","end_time":"2024-03-02 22:22:21","error_message":"Success","start_time":"2024-03-02 22:22:13","style_index":3,"error_code":0,"results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/viapi-video/2024-03-02/ac5d435a-9ea9-4287-8666-e1be7bbba943/20240302222213528791_style3_jxdf6o4zwy.jpg?Expires=1709475741&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=LM26fy1Pk8rCfPzihzpUqa3Vst8%3D"}]},"usage":{"image_count":1}} +{"request_id":"f927c766-5079-90f8-9354-6a87d2167897","output":{"task_id":"c4f94e00-5899-431b-9579-eb1ebe686379","task_status":"SUCCEEDED","submit_time":"2024-03-02 22:22:13.026","scheduled_time":"2024-03-02 22:22:13.051","end_time":"2024-03-02 22:22:21","error_message":"Success","start_time":"2024-03-02 22:22:13","style_index":3,"error_code":0,"results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/viapi-video/2024-03-02/ac5d435a-9ea9-4287-8666-e1be7bbba943/20240302222213528791_style3_jxdf6o4zwy.jpg"}]},"usage":{"image_count":1}} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-generation-success-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-generation-success-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt new file mode 100644 index 0000000..f9ffba2 --- /dev/null +++ b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.response.body.txt @@ -0,0 +1 @@ +{"request_id":"6662e925-4846-9afe-a3af-0d131805d378","output":{"task_id":"9e2b6ef6-285d-4efa-8651-4dbda7d571fa","task_status":"SUCCEEDED","submit_time":"2024-03-01 17:38:24.817","scheduled_time":"2024-03-01 17:38:24.831","end_time":"2024-03-01 17:38:55.565","results":[{"url":"https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/1d/d4/20240301/8d820c8d/4c48fa53-2907-499b-b9ac-76477fe8d299-1.png"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png"},{"url":"https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/3d/20240301/3ab595ad/3fca748e-d491-458a-bb72-73649af33209-1.png"}],"task_metrics":{"TOTAL":4,"SUCCEEDED":4,"FAILED":0}},"usage":{"image_count":4}} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-image-synthesis-success-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-image-synthesis-success-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-running-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-running-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/get-task-unknown-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/get-task-unknown-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-generation-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-generation-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/image-synthesis-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/image-synthesis-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-files-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-files-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/list-task-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/list-task-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-audio-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-audio-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-ocr-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-ocr-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/multimodal-generation-vl-video-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/multimodal-generation-vl-video-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/parameter-error-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/parameter-error-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-json-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-json-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-reasoning-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.request.body.json similarity index 85% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.request.body.json index 67f0342..7e41d14 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.request.body.json +++ b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.request.body.json @@ -32,13 +32,6 @@ "location": { "type": "string", "description": "要获取天气的省市名称,例如浙江省杭州市" - }, - "unit": { - "description": "温度单位", - "enum": [ - "Celsius", - "Fahrenheit" - ] } }, "required": [ diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-message-with-tools-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-with-tools-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/single-generation-text-sse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-text-sse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/test1.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/test1.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/test1.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/test1.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/test2.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/test2.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/test2.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/test2.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/text-embedding-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/text-embedding-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.request.body.json b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.request.body.json similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.request.body.json rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.request.body.json diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/tokenization-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/tokenization-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-error-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-error-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.request.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.request.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.request.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.request.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.response.body.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.response.body.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.response.body.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.response.body.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.response.header.txt b/test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.response.header.txt similarity index 100% rename from test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/upload-file-nosse.response.header.txt rename to test/Cnblogs.DashScope.Tests.Shared/RawHttpData/upload-file-nosse.response.header.txt diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Cases.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Cases.cs similarity index 69% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Cases.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Cases.cs index 79daec6..88cef2f 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Cases.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Cases.cs @@ -1,8 +1,8 @@ using Cnblogs.DashScope.Core; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; -internal class Cases +public class Cases { public const string CustomModelName = "custom-model"; public const string Prompt = "hello"; @@ -11,5 +11,5 @@ internal class Cases public const string ImageUrl = "https://www.cnblogs.com/image.png"; public static readonly List TextMessages = - [TextChatMessage.System("you are a helpful assistant"), TextChatMessage.User("hello")]; + new() { TextChatMessage.System("you are a helpful assistant"), TextChatMessage.User("hello") }; } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Checkers.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Checkers.cs similarity index 94% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Checkers.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Checkers.cs index c7b6e36..0e66fbd 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Checkers.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Checkers.cs @@ -1,6 +1,6 @@ using System.Text.Json.Nodes; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static class Checkers { diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/EquivalentUtils.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs similarity index 69% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/EquivalentUtils.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs index 70f6e54..c643ab3 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/EquivalentUtils.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs @@ -1,10 +1,10 @@ using FluentAssertions; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static class EquivalentUtils { - internal static bool IsEquivalent(this T left, T right) + public static bool IsEquivalent(this T left, T right) { try { diff --git a/test/Cnblogs.DashScope.Tests.Shared/Utils/GetCurrentWeatherParameters.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/GetCurrentWeatherParameters.cs new file mode 100644 index 0000000..91f7524 --- /dev/null +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/GetCurrentWeatherParameters.cs @@ -0,0 +1,10 @@ +using Json.Schema.Generation; + +namespace Cnblogs.DashScope.Tests.Shared.Utils; + +public class GetCurrentWeatherParameters +{ + [Required] + [Description("要获取天气的省市名称,例如浙江省杭州市")] + public string Location { get; init; } = string.Empty; +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/MockHttpMessageHandler.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/MockHttpMessageHandler.cs similarity index 93% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/MockHttpMessageHandler.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/MockHttpMessageHandler.cs index 1aa1b78..bf8de9d 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/MockHttpMessageHandler.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/MockHttpMessageHandler.cs @@ -1,4 +1,4 @@ -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public class MockHttpMessageHandler : HttpMessageHandler { diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/RequestSnapshot.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/RequestSnapshot.cs similarity index 96% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/RequestSnapshot.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/RequestSnapshot.cs index 17596ff..4c01bc1 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/RequestSnapshot.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/RequestSnapshot.cs @@ -1,7 +1,7 @@ using System.Net; using System.Text; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public record RequestSnapshot(string Name, TResponse ResponseModel) { diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Application.cs similarity index 91% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Application.cs index 59cfe01..fc467e9 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Application.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static partial class Snapshots { @@ -9,19 +9,19 @@ public static class Application public static readonly RequestSnapshot SinglePromptNoSse = new( "application-single-generation-text", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, - Parameters = new ApplicationParameters() + Input = new ApplicationInput { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, Seed = 1234, Temperature = 0.85f, - RagOptions = new ApplicationRagOptions() + RagOptions = new ApplicationRagOptions { - PipelineIds = ["thie5bysoj"], - FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + PipelineIds = new List { "thie5bysoj" }.AsReadOnly(), + FileIds = new List { "file_d129d632800c45aa9e7421b30561f447_10207234" }.AsReadOnly() } } }, @@ -31,8 +31,9 @@ public static class Application "xUnit Test Patterns 提供了一套全面的指南,用于改进测试自动化和重构测试代码。以下是根据提供的文档内容总结的关键点:\n\n1. 测试自动化的目标包括帮助提高产品质量、帮助我们理解被测系统(SUT)、减少(并且不引入)风险、易于运行、编写和维护[4]。\n2. 在管理共享fixture方面,文档讨论了访问共享fixture以及触发共享fixture构造的方法[2]。\n3. 关于结果验证,文档提供了自我检查测试的方法,验证状态或行为,使用内置断言进行状态验证,以及验证直接输出和替代路径[2]。\n4. 当涉及到数据库时,文档提到了与数据库相关的测试问题、没有数据库的测试、数据库测试、存储过程测试、数据访问层测试,并强调确保开发者独立性[3]。\n5. 文档还涵盖了测试方法组织策略、测试命名约定、测试套件组织、运行测试组或单个测试、测试代码重用、测试文件组织等内容[5]。\n\n这些模式和实践旨在解决测试中的常见问题,如高测试维护成本、不可测试代码最小化、防止生产代码中的错误测试等[1]。通过应用这些模式,开发者可以创建更高效、更易于维护的自动化测试。", "stop", "b7250cba47db463ca851dfb4088e71d8", - [ - new ApplicationOutputThought( + new List + { + new( null, "agentRag", "知识检索", @@ -42,7 +43,7 @@ public static class Application "[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]", null, "{}"), - new ApplicationOutputThought( + new( null, "api", "长期记忆检索", @@ -52,68 +53,76 @@ public static class Application "[]", null, "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"总结xUnit Test Patterns中的内容\"}") - ], - [ - new ApplicationDocReference( + }, + new List + { + new( "1", "Visual Summary of the Pattern Language", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:Visual Summary of the Pattern Language\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\n", - [ + new List + { "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648", "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302" - ], + }, null), - new ApplicationDocReference( + new( "2", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n", - [], + new List(), null), - new ApplicationDocReference( + new( "3", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n", - [], + new List(), null), - new ApplicationDocReference( + new( "4", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n", - [], + new List(), null), - new ApplicationDocReference( + new( "5", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n", - [], + new List(), null) - ]), - new ApplicationUsage([new ApplicationModelUsage("qwen-plus", 2591, 290)]))); + }), + new ApplicationUsage( + new List { new("qwen-plus", 2591, 290) }))); public static readonly RequestSnapshot SinglePromptSse = new( "application-single-generation-text", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, - Parameters = new ApplicationParameters() + Input = new ApplicationInput { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, Seed = 1234, Temperature = 0.85f, IncrementalOutput = true, - RagOptions = new ApplicationRagOptions() { PipelineIds = ["thie5bysoj"], Tags = ["xUnit"] } + RagOptions = new ApplicationRagOptions + { + PipelineIds = + new List { "thie5bysoj" }.AsReadOnly(), Tags = + new List { "xUnit" }.AsReadOnly() + } } }, new ApplicationResponse( @@ -123,58 +132,60 @@ public static class Application "stop", "069db8223d514dab91185954dc5108de", null, - [ - new ApplicationDocReference( + new List + { + new( "2", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n", - [], + new List(), null), - new ApplicationDocReference( + new( "3", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n", - [], + new List(), null), - new ApplicationDocReference( + new( "4", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n", - [], + new List(), null), - new ApplicationDocReference( + new( "5", "xUnit Test Patterns", "file_d129d632800c45aa9e7421b30561f447_10207234", "xUnit Test Patterns", "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n", - [], + new List(), null), - ]), - new ApplicationUsage([new ApplicationModelUsage("qwen-max-latest", 2304, 244)]))); + }), + new ApplicationUsage( + new List { new("qwen-max-latest", 2304, 244) }))); public static readonly RequestSnapshot SinglePromptWithThoughtsNoSse = new( "application-single-generation-text-with-thought", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, - Parameters = new ApplicationParameters() + Input = new ApplicationInput { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, Seed = 1234, Temperature = 0.85f, - RagOptions = new ApplicationRagOptions() + RagOptions = new ApplicationRagOptions { - PipelineIds = ["thie5bysoj"], - FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + PipelineIds = new List { "thie5bysoj" }.AsReadOnly(), + FileIds = new List { "file_d129d632800c45aa9e7421b30561f447_10207234" }.AsReadOnly() }, HasThoughts = true } @@ -185,8 +196,9 @@ public static class Application "《xUnit Test Patterns》是一本系统介绍单元测试模式与最佳实践的指南,主要帮助开发者设计可维护、高效且可靠的自动化测试。以下是其核心内容的总结:\n\n---\n\n### **核心主题与内容**\n1. **测试模式与反模式**\n - **关键模式**:如共享夹具管理(Shared Fixtures)、自定义断言(Custom Assertions)、预期对象(Expected Objects)等,用于解决测试代码重复、依赖管理等问题。\n - **反模式与问题**:如不可测试代码(Untestable Code)、测试逻辑混入生产代码(Test Logic in Production)、高维护成本(High Test Maintenance Cost)等,分析其成因与规避策略。\n\n2. **测试夹具管理**\n - **共享夹具**:如何构造、触发和访问共享测试环境(如数据库连接),避免测试间的副作用。\n - **数据库测试**:讨论是否依赖数据库进行测试、如何测试数据访问层、存储过程,以及确保开发者独立性的策略(如使用测试替身)。\n\n3. **测试验证策略**\n - **状态验证**:通过断言检查系统状态(如使用内置断言、Delta断言)。\n - **行为验证**:验证系统是否按预期调用方法(如模拟对象、过程式验证)。\n - **减少代码重复**:通过自定义断言、预期对象和验证方法统一结果检查逻辑。\n\n4. **测试自动化哲学与目标**\n - **目标**:提升代码质量、降低风险、易于编写和维护测试。\n - **经济性**:平衡测试投入与收益,优先覆盖关键路径(Happy Path)和替代路径(Alternative Paths)。\n\n5. **测试代码组织**\n - **结构化策略**:按类(Testcase Class per Class)、功能(Testcase Class per Feature)或夹具(Testcase Class per Fixture)组织测试用例。\n - **命名与套件管理**:使用清晰命名约定、分组测试套件(Test Suites)和依赖管理。\n\n6. **测试维护与演进**\n - **最小化维护成本**:通过模式(如测试工具方法、继承复用)适应系统变化。\n - **自检测试(Built-in Self-Test)**:确保测试本身的可信性。\n\n---\n\n### **书籍结构特点**\n- **问题驱动**:每章围绕具体问题(如“如何处理共享夹具?”)展开,提供模式、替代方案和权衡。\n- **视觉化总结**:通过图表展示模式间的关系,帮助读者理解复杂概念。\n- **实践导向**:结合代码示例与真实场景,指导如何应用模式解决测试中的常见痛点。\n\n---\n\n### **适用场景**\n- 开发中遇到测试代码重复、脆弱测试(Fragile Tests)或高维护成本时。\n- 需要设计复杂测试场景(如数据库交互、异步行为)时。\n- 团队希望建立统一的测试实践与规范时。\n\n通过遵循书中模式,开发者能构建更健壮、可维护的测试体系,最终提升软件质量和开发效率。", "stop", "9d81b84e95f844c29ee825ad8bb647bb", - [ - new ApplicationOutputThought( + new List + { + new( null, "agentRag", "知识检索", @@ -196,7 +208,7 @@ public static class Application "[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=4CddPVeeyxgrXe5axUspV6zXnS8%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=hRkFcnwAiV7LSHw69WvJJ6fXEV0%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]", null, "{}"), - new ApplicationOutputThought( + new( "好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。", "reasoning", "思考过程", @@ -206,20 +218,21 @@ public static class Application null, "好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。", null) - ], + }, null), - new ApplicationUsage([new ApplicationModelUsage("deepseek-r1", 1129, 1126)]))); + new ApplicationUsage( + new List { new("deepseek-r1", 1129, 1126) }))); public static readonly RequestSnapshot SinglePromptWithMemoryNoSse = new( "application-single-generation-text-with-memory", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() + Input = new ApplicationInput { Prompt = "我爱吃面食", MemoryId = "ffd8be2352d84c6b9350e91c865b512e" }, - Parameters = new ApplicationParameters() + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, @@ -234,9 +247,10 @@ public static class Application "那您一定会对面条、馒头或者饺子这些美食很感兴趣呢!如果您有特定的面食问题或者需要推荐相关的菜品,可以告诉我,我很乐意为您提供帮助[1]。", "stop", "cd395cb8d4604db786a14555fdcffa1a", - [ - new ApplicationOutputThought(null, "agentRag", "知识检索", "rag", "{}", null, "[]", null, "{}"), - new ApplicationOutputThought( + new List + { + new(null, "agentRag", "知识检索", "rag", "{}", null, "[]", null, "{}"), + new( null, "api", "长期记忆检索", @@ -246,21 +260,22 @@ public static class Application "[\"[2025-3-16 20:47:40 周日] 用户喜欢吃面食。\"]", null, "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"我爱吃面食\"}") - ], + }, null), - new ApplicationUsage([new ApplicationModelUsage("qwen-plus", 1201, 43)]))); + new ApplicationUsage( + new List { new("qwen-plus", 1201, 43) }))); public static readonly RequestSnapshot, ApplicationResponse> WorkflowNoSse = new( "application-workflow", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() + Input = new ApplicationInput { BizParams = new TestApplicationBizParam("code"), Prompt = "请你跟我这样说" }, - Parameters = new ApplicationParameters() + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, @@ -277,13 +292,13 @@ public static readonly RequestSnapshot() + new ApplicationRequest { - Input = new ApplicationInput() + Input = new ApplicationInput { BizParams = new TestApplicationBizParam("code"), Prompt = "请你跟我这样说" }, - Parameters = new ApplicationParameters() + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, @@ -300,22 +315,22 @@ public static readonly RequestSnapshot ConversationSessionIdNoSse = new( "application-conversation-generation-session-id", - new ApplicationRequest() + new ApplicationRequest { Input = - new ApplicationInput() + new ApplicationInput { Prompt = "总结一下第一本书的内容", SessionId = "9995da2046a04b448dc5a562563f4835" }, - Parameters = new ApplicationParameters() + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, Seed = 1234, Temperature = 0.85f, - RagOptions = new ApplicationRagOptions() + RagOptions = new ApplicationRagOptions { - PipelineIds = ["ll6yfcnxjg"], + PipelineIds = new List { "ll6yfcnxjg" }.AsReadOnly(), MetadataFilter = new Dictionary { { "docType", "电子书" } } }, HasThoughts = true @@ -327,8 +342,9 @@ public static readonly RequestSnapshot + { + new( null, "agentRag", "知识检索", @@ -338,7 +354,7 @@ public static readonly RequestSnapshot { new("deepseek-r1", 1283, 1081) }))); public static readonly RequestSnapshot ConversationMessageNoSse = new( "application-conversation-generation-message", - new ApplicationRequest() + new ApplicationRequest { - Input = new ApplicationInput() + Input = new ApplicationInput { Messages = - [ - ApplicationMessage.System("You are a helpful assistant."), - ApplicationMessage.User("你是谁?"), - ApplicationMessage.Assistant("我是阿里云开发的大规模语言模型,我叫通义千问。"), - ApplicationMessage.User("哪些人的主食偏好是米饭?"), - ], + new List + { + ApplicationMessage.System("You are a helpful assistant."), + ApplicationMessage.User("你是谁?"), + ApplicationMessage.Assistant("我是阿里云开发的大规模语言模型,我叫通义千问。"), + ApplicationMessage.User("哪些人的主食偏好是米饭?"), + }.AsReadOnly(), }, - Parameters = new ApplicationParameters() + Parameters = new ApplicationParameters { TopK = 100, TopP = 0.8f, Seed = 1234, Temperature = 0.85f, - RagOptions = new ApplicationRagOptions() + RagOptions = new ApplicationRagOptions { - PipelineIds = ["e6md69132k"], + PipelineIds = new List { "e6md69132k" }.AsReadOnly(), StructuredFilter = new Dictionary { { "年龄", 14 } } }, HasThoughts = true @@ -387,8 +405,9 @@ public static readonly RequestSnapshot + { + new( null, "agentRag", "知识检索", @@ -398,7 +417,7 @@ public static readonly RequestSnapshot { new("qwen-plus", 344, 311) }))); } } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Error.cs similarity index 84% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Error.cs index eb4ea63..f199963 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Error.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static partial class Snapshots { @@ -23,7 +23,7 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = false } @@ -42,7 +42,11 @@ public static readonly new ModelRequest { Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, + Input = new TextGenerationInput + { + Prompt = "请问 1+1 是多少?", Messages = + new List().AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "text", @@ -52,7 +56,7 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = false } @@ -71,7 +75,11 @@ public static readonly new ModelRequest { Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, + Input = new TextGenerationInput + { + Prompt = "请问 1+1 是多少?", Messages = + new List().AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "text", @@ -81,7 +89,7 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = true } diff --git a/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.MultimodalGeneration.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.MultimodalGeneration.cs new file mode 100644 index 0000000..f413959 --- /dev/null +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.MultimodalGeneration.cs @@ -0,0 +1,567 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Tests.Shared.Utils; + +public static partial class Snapshots +{ + public static class MultimodalGeneration + { + public static readonly RequestSnapshot, + ModelResponse> VlNoSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.System( + new List + { + MultimodalMessageContent.TextContent("You are a helpful assistant.") + }.AsReadOnly()), + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + Temperature = 1.1f, + VlHighResolutionImages = true, + RepetitionPenalty = 1.3f, + PresencePenalty = 1.2f, + MaxTokens = 120, + Stop = "你好" + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List { MultimodalMessageContent.TextContent("海滩。") } + .AsReadOnly())) + }), + RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", + Usage = new MultimodalTokenUsage + { + OutputTokens = 3, + InputTokens = 3613, + ImageTokens = 3577 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlChatClientNoSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + Temperature = 1.1f, + RepetitionPenalty = 1.3f, + PresencePenalty = 1.2f, + MaxTokens = 120, + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List { MultimodalMessageContent.TextContent("海滩。") } + .AsReadOnly())) + }), + RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", + Usage = new MultimodalTokenUsage + { + OutputTokens = 3, + InputTokens = 3613, + ImageTokens = 3577 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.System( + new List + { + MultimodalMessageContent.TextContent("You are a helpful assistant.") + }.AsReadOnly()), + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + IncrementalOutput = true, + Seed = 1234, + TopK = 100, + TopP = 0.81f + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") + }.AsReadOnly())) + }), + RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", + Usage = new MultimodalTokenUsage + { + OutputTokens = 85, + InputTokens = 1283, + ImageTokens = 1247 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlChatClientSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + IncrementalOutput = true, + Seed = 1234, + TopK = 100, + TopP = 0.81f, + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") + }.AsReadOnly())) + }), + RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", + Usage = new MultimodalTokenUsage + { + OutputTokens = 85, + InputTokens = 1283, + ImageTokens = 1247 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + OcrNoSse = new( + "multimodal-generation-vl-ocr", + new ModelRequest + { + Model = "qwen-vl-ocr", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", + 3136, + 1003520), + MultimodalMessageContent.TextContent("Read all the text in the image.") + }.AsReadOnly()), + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + MaxTokens = 2000, + TopP = 0.01f + } + }, + new ModelResponse + { + RequestId = "195c98cd-4ee5-998b-b662-132b7aebc048", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + InputTokens = 1248, + OutputTokens = 225, + ImageTokens = 1219 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + OcrSse = new( + "multimodal-generation-vl-ocr", + new ModelRequest + { + Model = "qwen-vl-ocr", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.ImageContent( + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", + 3136, + 1003520), + MultimodalMessageContent.TextContent("Read all the text in the image.") + }.AsReadOnly()), + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + MaxTokens = 2000, + TopP = 0.01f, + IncrementalOutput = true + } + }, + new ModelResponse + { + RequestId = "fb33a990-3826-9386-8b0a-8317dfc38c1c", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + InputTokens = 1248, + OutputTokens = 225, + ImageTokens = 1219 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + AudioNoSse = new( + "multimodal-generation-audio", + new ModelRequest + { + Model = "qwen-audio-turbo", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.System( + new List + { + MultimodalMessageContent.TextContent("You are a helpful assistant.") + }.AsReadOnly()), + MultimodalMessage.User( + new List + { + MultimodalMessageContent.AudioContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), + MultimodalMessageContent.TextContent("这段音频在说什么,请用简短的语言回答") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f + } + }, + new ModelResponse + { + RequestId = "6b6738bd-dd9d-9e78-958b-02574acbda44", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "这段音频在说中文,内容是\"没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网\"。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + InputTokens = 786, + OutputTokens = 38, + AudioTokens = 752 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + AudioSse = new( + "multimodal-generation-audio", + new ModelRequest + { + Model = "qwen-audio-turbo", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.System( + new List + { + MultimodalMessageContent.TextContent("You are a helpful assistant.") + }.AsReadOnly()), + MultimodalMessage.User( + new List + { + MultimodalMessageContent.AudioContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), + MultimodalMessageContent.TextContent("这段音频的第一句话说了什么?") + }.AsReadOnly()) + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + IncrementalOutput = true + } + }, + new ModelResponse + { + RequestId = "bb6ab962-af57-99f1-9af8-eb7016ebc18e", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent("第一句话说了没有我互联网。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + InputTokens = 783, + OutputTokens = 7, + AudioTokens = 752 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + VideoNoSse = new( + "multimodal-generation-vl-video", + new ModelRequest + { + Model = "qwen-vl-max", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.VideoContent( + new List + { + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" + }.AsReadOnly()), + MultimodalMessageContent.TextContent("描述这个视频的具体过程") + }.AsReadOnly()), + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopP = 0.01f, + Temperature = 0.1f, + RepetitionPenalty = 1.05f + } + }, + new ModelResponse + { + RequestId = "d538f8cc-8048-9ca8-9e8a-d2a49985b479", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:球场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **守门员扑救**:守门员看到对方射门后,立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + VideoTokens = 1440, + InputTokens = 1466, + OutputTokens = 180 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + VideoSse = new( + "multimodal-generation-vl-video", + new ModelRequest + { + Model = "qwen-vl-max", + Input = new MultimodalInput + { + Messages = + new List + { + MultimodalMessage.User( + new List + { + MultimodalMessageContent.VideoContent( + new List + { + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" + }.AsReadOnly()), + MultimodalMessageContent.TextContent("描述这个视频的具体过程") + }.AsReadOnly()), + }.AsReadOnly() + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopP = 0.01f, + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + IncrementalOutput = true + } + }, + new ModelResponse + { + RequestId = "851745a1-22ba-90e2-ace2-c04e7445ec6f", + Output = new MultimodalOutput( + new List + { + new( + "stop", + MultimodalMessage.Assistant( + new List + { + MultimodalMessageContent.TextContent( + "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **扑救尝试**:守门员看到射门后立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") + }.AsReadOnly())) + }), + Usage = new MultimodalTokenUsage + { + VideoTokens = 1440, + InputTokens = 1466, + OutputTokens = 176 + } + }); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Tasks.cs similarity index 78% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Tasks.cs index 90b68ff..01eb965 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.Tasks.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static partial class Snapshots { @@ -58,16 +58,17 @@ public static readonly RequestSnapshot + { + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/1d/d4/20240301/8d820c8d/4c48fa53-2907-499b-b9ac-76477fe8d299-1.png"), + new( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png"), + new( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png"), + new( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/3d/20240301/3ab595ad/3fca748e-d491-458a-bb72-73649af33209-1.png") + }, TaskMetrics = new DashScopeTaskMetrics(4, 4, 0) }, new ImageSynthesisUsage(4))); @@ -89,10 +90,11 @@ public static readonly RequestSnapshot + { + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/viapi-video/2024-03-02/ac5d435a-9ea9-4287-8666-e1be7bbba943/20240302222213528791_style3_jxdf6o4zwy.jpg") + } }, new ImageGenerationUsage(1))); @@ -109,26 +111,30 @@ public static readonly RequestSnapshot + { + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_0_02dc0bba-8b1d-4648-8b95-eb2b92fe715d.png"), + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_1_e1af86ec-152a-4ebe-b2a0-b40a592043b2.png") + }, TaskMetrics = new DashScopeTaskMetrics(2, 2, 0), TextResults = new BackgroundGenerationTextResult( - [ - new BackgroundGenerationTextResultUrl( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=kmZGXc2s8P4uI%2BVrADITyrPz82U%3D"), - new BackgroundGenerationTextResultUrl( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=cb1Qg%2FkIuZyI7XQqWHjP712N0ak%3D") - ], - [ - new BackgroundGenerationTextResultParams( + new List + { + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png"), + new( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png") + }, + new List + { + new( 0, - [ - new BackgroundGenerationTextResultLayer( + new List + { + new( 0, "text_mask", 0, @@ -141,14 +147,15 @@ public static readonly RequestSnapshot + { + new( "#521b0800", 0), - new BackgroundGenerationTextResultGradientColorStop( + new( "#521b08ff", 1) - ]) + }) { Coords = new Dictionary { @@ -158,7 +165,7 @@ public static readonly RequestSnapshot + { + new( "#e6baa7ff", 0), - new BackgroundGenerationTextResultGradientColorStop( + new( "#e6baa7ff", 1) - ]) + }) { Coords = new Dictionary { @@ -211,7 +219,7 @@ public static readonly RequestSnapshot + { + new( 0, "text_mask", 0, @@ -247,14 +256,15 @@ public static readonly RequestSnapshot + { + new( "#efeae400", 0), - new BackgroundGenerationTextResultGradientColorStop( + new( "#efeae4ff", 1) - ]) + }) { Coords = new Dictionary { @@ -266,7 +276,7 @@ public static readonly RequestSnapshot + { + new( "#421f12ff", 0), - new BackgroundGenerationTextResultGradientColorStop( + new( "#421f12ff", 1) - ]) + }) { Coords = new Dictionary { @@ -319,7 +330,7 @@ public static readonly RequestSnapshot { - Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, + Input = new TextEmbeddingInput { Texts = new List { "代码改变世界" }.AsReadOnly() }, Model = "text-embedding-v2", Parameters = new TextEmbeddingParameters { TextType = "query" } }, new ModelResponse { - Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), + Output = new TextEmbeddingOutput(new List { new(0, new float[0]) }), RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", Usage = new TextEmbeddingTokenUsage(3) }); @@ -27,13 +27,13 @@ public static class TextEmbedding "text-embedding", new ModelRequest { - Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, + Input = new TextEmbeddingInput { Texts = new List { "代码改变世界" }.AsReadOnly() }, Model = "text-embedding-v3", Parameters = new TextEmbeddingParameters { Dimension = 1024 } }, new ModelResponse { - Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), + Output = new TextEmbeddingOutput(new List { new(0, new float[0]) }), RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", Usage = new TextEmbeddingTokenUsage(3) }); diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.TextGeneration.cs similarity index 57% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.TextGeneration.cs index eca1ed8..c53e968 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.TextGeneration.cs @@ -1,8 +1,9 @@ using Cnblogs.DashScope.Core; +using Cnblogs.DashScope.Sdk; using Json.Schema; using Json.Schema.Generation; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static partial class Snapshots { @@ -27,17 +28,15 @@ public static class TextFormat TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = false } }, new ModelResponse { - Output = new TextGenerationOutput - { - FinishReason = "stop", Text = "1+1等于2。这是最基本的数学加法运算之一。" - }, + Output = + new TextGenerationOutput { FinishReason = "stop", Text = "1+1等于2。这是最基本的数学加法运算之一。" }, RequestId = "7e3d5586-cb70-98ce-97bf-8a2ac0091c3f", Usage = new TextGenerationTokenUsage { @@ -65,7 +64,7 @@ public static class TextFormat TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = true } @@ -93,7 +92,11 @@ public static class MessageFormat { Model = "qwen-max", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "message", @@ -103,7 +106,7 @@ public static class MessageFormat TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = false } @@ -113,14 +116,15 @@ public static class MessageFormat Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + } } - ] }, RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", Usage = new TextGenerationTokenUsage @@ -139,26 +143,29 @@ public static class MessageFormat { Model = "deepseek-r1", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - IncrementalOutput = false - } + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, + Parameters = new TextGenerationParameters { IncrementalOutput = false } }, new ModelResponse { Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1 + 1 等于 **2**。这是基础的算术加法,当我们将一个单位与另一个单位相加时,总和为两个单位。", - reasoningContent: "嗯,用户问1加1等于多少。这个问题看起来很简单,但可能有一些需要注意的地方。首先,我得确认用户是不是真的在问基本的数学问题,还是有其他的意图,比如测试我的反应或者开玩笑。\n\n1加1在基础算术里确实是2,但有时候可能会有不同的解释,比如在二进制中1+1等于10,或者在逻辑学中有时候表示为1,如果是布尔代数的话。不过通常情况下,用户可能只需要最直接的答案,也就是2。\n\n不过也有可能用户想考察我是否能够处理更复杂的情况,或者是否有隐藏的意思。比如,在某些情况下,1加1可能被用来比喻合作的效果,比如“1+1大于2”,但这可能超出了当前问题的范围。\n\n我需要考虑用户的背景。如果用户是小学生,那么直接回答2是正确的,并且可能需要鼓励的话。如果是成年人,可能还是同样的答案,但不需要额外的解释。如果用户来自数学或计算机领域,可能需要确认是否需要其他进制的答案,但通常默认是十进制。\n\n另外,检查是否有拼写错误或非阿拉伯数字的情况,比如罗马数字的I+I,但问题里明确写的是1+1,所以应该是阿拉伯数字。\n\n总结下来,最安全也是最正确的答案就是2。不过为了确保,可以简短地确认用户的意图,但按照常规问题处理,直接回答即可。") + new() + { + FinishReason = "stop", + Message = + TextChatMessage.Assistant( + "1 + 1 等于 **2**。这是基础的算术加法,当我们将一个单位与另一个单位相加时,总和为两个单位。", + reasoningContent: "嗯,用户问1加1等于多少。这个问题看起来很简单,但可能有一些需要注意的地方。首先,我得确认用户是不是真的在问基本的数学问题,还是有其他的意图,比如测试我的反应或者开玩笑。\n\n1加1在基础算术里确实是2,但有时候可能会有不同的解释,比如在二进制中1+1等于10,或者在逻辑学中有时候表示为1,如果是布尔代数的话。不过通常情况下,用户可能只需要最直接的答案,也就是2。\n\n不过也有可能用户想考察我是否能够处理更复杂的情况,或者是否有隐藏的意思。比如,在某些情况下,1加1可能被用来比喻合作的效果,比如“1+1大于2”,但这可能超出了当前问题的范围。\n\n我需要考虑用户的背景。如果用户是小学生,那么直接回答2是正确的,并且可能需要鼓励的话。如果是成年人,可能还是同样的答案,但不需要额外的解释。如果用户来自数学或计算机领域,可能需要确认是否需要其他进制的答案,但通常默认是十进制。\n\n另外,检查是否有拼写错误或非阿拉伯数字的情况,比如罗马数字的I+I,但问题里明确写的是1+1,所以应该是阿拉伯数字。\n\n总结下来,最安全也是最正确的答案就是2。不过为了确保,可以简短地确认用户的意图,但按照常规问题处理,直接回答即可。") + } } - ] }, RequestId = "7039d8ff-89e0-9191-b4d3-0d258a7d70e1", Usage = new TextGenerationTokenUsage @@ -177,7 +184,11 @@ public static class MessageFormat { Model = "qwen-max", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "message", @@ -195,14 +206,15 @@ public static class MessageFormat Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + } } - ] }, RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", Usage = new TextGenerationTokenUsage @@ -221,7 +233,12 @@ public static class MessageFormat { Model = "qwen-max", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?用 JSON 格式输出。")] }, + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?用 JSON 格式输出。") } + .AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "message", @@ -231,7 +248,7 @@ public static class MessageFormat TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = false, ResponseFormat = DashScopeResponseFormat.Json @@ -242,13 +259,14 @@ public static class MessageFormat Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant("{\n \"result\": 2\n}") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant("{\n \"result\": 2\n}") + } } - ] }, RequestId = "6af9571b-1033-98f9-a287-c06f2e9d6f7f", Usage = new TextGenerationTokenUsage @@ -267,7 +285,11 @@ public static class MessageFormat { Model = "qwen-max", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "message", @@ -277,7 +299,7 @@ public static class MessageFormat TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = true } @@ -287,14 +309,15 @@ public static class MessageFormat Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + } } - ] }, RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", Usage = new TextGenerationTokenUsage @@ -304,6 +327,7 @@ public static class MessageFormat InputTokens = 8 } }); + public static readonly RequestSnapshot, ModelResponse> SingleMessageReasoningIncremental = new( @@ -312,26 +336,28 @@ public static class MessageFormat { Model = "deepseek-r1", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - IncrementalOutput = true - } + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, + Parameters = new TextGenerationParameters { IncrementalOutput = true } }, new ModelResponse { Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 在基础算术中的答案是 **2**。\n\n不过,根据不同的数学或逻辑系统,结果可能不同:\n- **二进制**:1+1 = 10(读作“一零”)。\n- **布尔代数**:1+1 = 1(逻辑“或”运算)。\n- **抽象场景**:如“1滴水 + 1滴水 = 1大滴水”(非数学意义的合并)。\n\n日常问题中默认使用十进制算术,因此答案是 **2** \ud83d\ude0a。", - reasoningContent: "嗯,用户问1加1等于多少。这个问题看起来很简单,但其实可能有很多种情况需要考虑。首先,我得确定用户是不是在问数学上的基本加法。通常来说,1加1等于2,这是数学里的基本事实,根据皮亚诺公理或者基本的算术规则。不过,有时候问题可能有隐藏的含义,特别是在不同的语境下,答案可能会不同。比如在二进制中,1+1等于10,或者在布尔代数中,1+1可能等于1,如果是逻辑或运算的话。不过大部分情况下,尤其是在日常交流中,人们提到1+1的时候都是指十进制加法,结果自然是2。不过也有可能用户是在测试我的反应,或者想看看我会不会考虑其他可能性。比如在特定的谜语或笑话中,答案可能不是2,比如“1滴水加1滴水还是1滴水”,或者类似的文字游戏。但根据常规问题,我应该先给出正确的数学答案,再补充可能的其他情况,这样既准确又全面。所以可能先回答2,然后解释其他可能性。不过用户的问题看起来直接,可能不需要太复杂的解释,但为了保险起见,还是确认一下是否有其他意图比较好。或者用户可能只是单纯想知道答案,所以直接回答2即可。需要平衡简洁和全面性。可能先给出直接答案,然后简单说明其他情况的存在,这样既满足需求,又避免信息过载。总之,核心答案应该是2,但根据情况适当扩展。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 在基础算术中的答案是 **2**。\n\n不过,根据不同的数学或逻辑系统,结果可能不同:\n- **二进制**:1+1 = 10(读作“一零”)。\n- **布尔代数**:1+1 = 1(逻辑“或”运算)。\n- **抽象场景**:如“1滴水 + 1滴水 = 1大滴水”(非数学意义的合并)。\n\n日常问题中默认使用十进制算术,因此答案是 **2** \ud83d\ude0a。", + reasoningContent: "嗯,用户问1加1等于多少。这个问题看起来很简单,但其实可能有很多种情况需要考虑。首先,我得确定用户是不是在问数学上的基本加法。通常来说,1加1等于2,这是数学里的基本事实,根据皮亚诺公理或者基本的算术规则。不过,有时候问题可能有隐藏的含义,特别是在不同的语境下,答案可能会不同。比如在二进制中,1+1等于10,或者在布尔代数中,1+1可能等于1,如果是逻辑或运算的话。不过大部分情况下,尤其是在日常交流中,人们提到1+1的时候都是指十进制加法,结果自然是2。不过也有可能用户是在测试我的反应,或者想看看我会不会考虑其他可能性。比如在特定的谜语或笑话中,答案可能不是2,比如“1滴水加1滴水还是1滴水”,或者类似的文字游戏。但根据常规问题,我应该先给出正确的数学答案,再补充可能的其他情况,这样既准确又全面。所以可能先回答2,然后解释其他可能性。不过用户的问题看起来直接,可能不需要太复杂的解释,但为了保险起见,还是确认一下是否有其他意图比较好。或者用户可能只是单纯想知道答案,所以直接回答2即可。需要平衡简洁和全面性。可能先给出直接答案,然后简单说明其他情况的存在,这样既满足需求,又避免信息过载。总之,核心答案应该是2,但根据情况适当扩展。") + } } - ] }, RequestId = "e4ad5d0f-8019-9716-adc6-eae1411d3c9a", Usage = new TextGenerationTokenUsage @@ -350,7 +376,11 @@ public static class MessageFormat { Model = "qwen-max", Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("请问 1+1 是多少?") }.AsReadOnly() + }, Parameters = new TextGenerationParameters { ResultFormat = "message", @@ -370,14 +400,15 @@ public static class MessageFormat Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + } } - ] }, RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", Usage = new TextGenerationTokenUsage @@ -396,8 +427,12 @@ public static readonly new ModelRequest { Model = "qwen-max", - Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, - Parameters = new TextGenerationParameters() + Input = new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("杭州现在的天气如何?") }.AsReadOnly() + }, + Parameters = new TextGenerationParameters { ResultFormat = "message", Seed = 1234, @@ -411,19 +446,21 @@ public static readonly EnableSearch = false, IncrementalOutput = false, Tools = - [ - new ToolDefinition( - "function", - new FunctionDefinition( - "get_current_weather", - "获取现在的天气", - new JsonSchemaBuilder().FromType( - new SchemaGeneratorConfiguration - { - PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase - }) - .Build())) - ], + new List + { + new( + "function", + new FunctionDefinition( + "get_current_weather", + "获取现在的天气", + new JsonSchemaBuilder().FromType( + new SchemaGeneratorConfiguration + { + PropertyNameResolver = + PropertyNameResolvers.LowerSnakeCase + }) + .Build())) + }.AsReadOnly(), ToolChoice = ToolChoice.FunctionChoice("get_current_weather") } }, @@ -432,24 +469,26 @@ public static readonly Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - string.Empty, - toolCalls: - [ - new ToolCall( - "call_cec4c19d27624537b583af", - ToolTypes.Function, - 0, - new FunctionCall( - "get_current_weather", - """{"location": "浙江省杭州市"}""")) - ]) + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + string.Empty, + toolCalls: + new List + { + new( + "call_cec4c19d27624537b583af", + ToolTypes.Function, + 0, + new FunctionCall( + "get_current_weather", + "{\"location\": \"浙江省杭州市\"}")) + }) + } } - ] }, RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", Usage = new TextGenerationTokenUsage @@ -468,8 +507,12 @@ public static readonly new ModelRequest { Model = "qwen-max", - Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, - Parameters = new TextGenerationParameters() + Input = new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("杭州现在的天气如何?") }.AsReadOnly() + }, + Parameters = new TextGenerationParameters { ResultFormat = "message", Seed = 1234, @@ -480,19 +523,21 @@ public static readonly PresencePenalty = 1.2f, Temperature = 0.85f, Tools = - [ - new ToolDefinition( - "function", - new FunctionDefinition( - "get_current_weather", - "获取现在的天气", - new JsonSchemaBuilder().FromType( - new SchemaGeneratorConfiguration - { - PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase - }) - .Build())) - ], + new List + { + new( + "function", + new FunctionDefinition( + "get_current_weather", + "获取现在的天气", + new JsonSchemaBuilder().FromType( + new SchemaGeneratorConfiguration + { + PropertyNameResolver = + PropertyNameResolvers.LowerSnakeCase + }) + .Build())) + }.AsReadOnly(), ToolChoice = ToolChoice.FunctionChoice("get_current_weather") } }, @@ -501,24 +546,26 @@ public static readonly Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - string.Empty, - toolCalls: - [ - new ToolCall( - "call_cec4c19d27624537b583af", - ToolTypes.Function, - 0, - new FunctionCall( - "get_current_weather", - """{"location": "浙江省杭州市"}""")) - ]) + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + string.Empty, + toolCalls: + new List + { + new( + "call_cec4c19d27624537b583af", + ToolTypes.Function, + 0, + new FunctionCall( + "get_current_weather", + "{\"location\": \"浙江省杭州市\"}")) + }) + } } - ] }, RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", Usage = new TextGenerationTokenUsage @@ -533,18 +580,19 @@ public static readonly ModelResponse> ConversationPartialMessageNoSse = new( "conversation-generation-message-partial", - new ModelRequest() + new ModelRequest { Model = "qwen-max", - Input = new TextGenerationInput() + Input = new TextGenerationInput { Messages = - [ - TextChatMessage.User("请对“春天来了,大地”这句话进行续写,来表达春天的美好和作者的喜悦之情"), - TextChatMessage.Assistant("春天来了,大地", true) - ] + new List + { + TextChatMessage.User("请对“春天来了,大地”这句话进行续写,来表达春天的美好和作者的喜悦之情"), + TextChatMessage.Assistant("春天来了,大地", true) + }.AsReadOnly() }, - Parameters = new TextGenerationParameters() + Parameters = new TextGenerationParameters { ResultFormat = ResultFormats.Message, Seed = 1234, @@ -552,27 +600,28 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false } }, - new ModelResponse() + new ModelResponse { RequestId = "4c45d7fd-3158-9ff4-96a0-6e92c710df2c", - Output = new TextGenerationOutput() + Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice() + new List { - FinishReason = "stop", - Message = - TextChatMessage.Assistant( - "仿佛从漫长的冬眠中苏醒过来,万物复苏。嫩绿的小草悄悄地探出了头,争先恐后地想要沐浴在温暖的阳光下;五彩斑斓的花朵也不甘示弱,竞相绽放着自己最美丽的姿态,将田野、山林装扮得分外妖娆。微风轻轻吹过,带来了泥土的气息与花香混合的独特香味,让人心旷神怡。小鸟们开始忙碌起来,在枝头欢快地歌唱,似乎也在庆祝这个充满希望的新季节的到来。这一切美好景象不仅让人感受到了大自然的魅力所在,更激发了人们对生活无限热爱和向往的心情。") + new() + { + FinishReason = "stop", + Message = + TextChatMessage.Assistant( + "仿佛从漫长的冬眠中苏醒过来,万物复苏。嫩绿的小草悄悄地探出了头,争先恐后地想要沐浴在温暖的阳光下;五彩斑斓的花朵也不甘示弱,竞相绽放着自己最美丽的姿态,将田野、山林装扮得分外妖娆。微风轻轻吹过,带来了泥土的气息与花香混合的独特香味,让人心旷神怡。小鸟们开始忙碌起来,在枝头欢快地歌唱,似乎也在庆祝这个充满希望的新季节的到来。这一切美好景象不仅让人感受到了大自然的魅力所在,更激发了人们对生活无限热爱和向往的心情。") + } } - ] }, - Usage = new TextGenerationTokenUsage() + Usage = new TextGenerationTokenUsage { TotalTokens = 165, OutputTokens = 131, @@ -591,11 +640,12 @@ public static readonly new TextGenerationInput { Messages = - [ - TextChatMessage.User("现在请你记住一个数字,42"), - TextChatMessage.Assistant("好的,我已经记住了这个数字。"), - TextChatMessage.User("请问我刚才提到的数字是多少?") - ] + new List + { + TextChatMessage.User("现在请你记住一个数字,42"), + TextChatMessage.Assistant("好的,我已经记住了这个数字。"), + TextChatMessage.User("请问我刚才提到的数字是多少?") + }.AsReadOnly() }, Parameters = new TextGenerationParameters { @@ -606,7 +656,7 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = true } @@ -616,12 +666,14 @@ public static readonly Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", Message = TextChatMessage.Assistant("您刚才提到的数字是42。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant("您刚才提到的数字是42。") + } } - ] }, RequestId = "9188e907-56c2-9849-97f6-23f130f7fed7", Usage = new TextGenerationTokenUsage @@ -643,11 +695,16 @@ public static readonly new TextGenerationInput { Messages = - [ - TextChatMessage.File( - ["file-fe-WTTG89tIUTd4ByqP3K48R3bn", "file-fe-l92iyRvJm9vHCCfonLckf1o2"]), - TextChatMessage.User("这两个文件是相同的吗?") - ] + new List + { + TextChatMessage.File( + new List + { + "file-fe-WTTG89tIUTd4ByqP3K48R3bn", + "file-fe-l92iyRvJm9vHCCfonLckf1o2" + }.AsReadOnly()), + TextChatMessage.User("这两个文件是相同的吗?") + }.AsReadOnly() }, Parameters = new TextGenerationParameters { @@ -658,7 +715,7 @@ public static readonly TopK = 100, RepetitionPenalty = 1.1f, Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, + Stop = new[] { new[] { 37763, 367 } }, EnableSearch = false, IncrementalOutput = true } @@ -668,14 +725,15 @@ public static readonly Output = new TextGenerationOutput { Choices = - [ - new TextGenerationChoice + new List { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "你上传的两个文件并不相同。第一个文件`test1.txt`包含两行文本,每行都是“测试”。而第二个文件`test2.txt`只有一行文本,“测试2”。尽管它们都含有“测试”这个词,但具体内容和结构不同。") + new() + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "你上传的两个文件并不相同。第一个文件`test1.txt`包含两行文本,每行都是“测试”。而第二个文件`test2.txt`只有一行文本,“测试2”。尽管它们都含有“测试”这个词,但具体内容和结构不同。") + } } - ] }, RequestId = "7865ae43-8379-9c79-bef6-95050868bc52", Usage = new TextGenerationTokenUsage diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.cs similarity index 87% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.cs index ab61622..fcd442d 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Snapshots.cs @@ -1,6 +1,6 @@ using Cnblogs.DashScope.Core; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static partial class Snapshots { @@ -12,13 +12,29 @@ public static readonly "tokenization", new ModelRequest { - Input = new TextGenerationInput { Messages = [TextChatMessage.User("代码改变世界")] }, + Input = new TextGenerationInput + { + Messages = + new List { TextChatMessage.User("代码改变世界") }.AsReadOnly() + }, Model = "qwen-max", Parameters = new TextGenerationParameters { Seed = 1234 } }, new ModelResponse { - Output = new TokenizationOutput([46100, 101933, 99489], ["代码", "改变", "世界"]), + Output = new TokenizationOutput( + new List + { + 46100, + 101933, + 99489 + }, + new List + { + "代码", + "改变", + "世界" + }), Usage = new TokenizationUsage(3), RequestId = "6615ba01-081d-9147-93ff-7bd26f3adf93" }); @@ -119,7 +135,7 @@ public static readonly public static class File { - public static readonly FileInfo TestFile = new FileInfo("RawHttpData/test1.txt"); + public static readonly FileInfo TestFile = new("RawHttpData/test1.txt"); public static readonly RequestSnapshot UploadFileNoSse = new( "upload-file", @@ -134,22 +150,23 @@ public static class File new DashScopeFileList( "list", false, - [ - new DashScopeFile( + new List + { + new( "file-fe-qBKjZKfTx64R9oYmwyovNHBH", "file", 6, 1720582024, "test1.txt", "file-extract"), - new DashScopeFile( + new( "file-fe-WTTG89tIUTd4ByqP3K48R3bn", "file", 6, 1720535665, "test1.txt", "file-extract") - ])); + })); public static readonly RequestSnapshot DeleteFileNoSse = new( "delete-file", diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Sut.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/Sut.cs similarity index 94% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Sut.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/Sut.cs index b6f1755..cb42ce2 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Sut.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/Sut.cs @@ -2,7 +2,7 @@ using NSubstitute; using NSubstitute.Extensions; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public static class Sut { diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/TestApplicationBizParam.cs similarity index 75% rename from test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs rename to test/Cnblogs.DashScope.Tests.Shared/Utils/TestApplicationBizParam.cs index a1274f4..66c6a27 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs +++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/TestApplicationBizParam.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; +namespace Cnblogs.DashScope.Tests.Shared.Utils; public record TestApplicationBizParam( [property: JsonPropertyName("sourceCode")]