Skip to content

Commit 1b7dd4c

Browse files
committed
feat: support reasoning switch for qwen3 models
1 parent 9f2f8a1 commit 1b7dd4c

11 files changed

+162
-1611
lines changed

src/Cnblogs.DashScope.Core/ITextGenerationParameters.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public interface ITextGenerationParameters
4040
/// </summary>
4141
public bool? EnableSearch { get; }
4242

43+
/// <summary>
44+
/// Thinking option. Valid for supported models.(e.g. qwen3)
45+
/// </summary>
46+
public bool? EnableThinking { get; }
47+
4348
/// <summary>
4449
/// Available tools for model to call.
4550
/// </summary>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Cnblogs.DashScope.Core;
2+
3+
/// <summary>
4+
/// Output details for text generation api.
5+
/// </summary>
6+
/// <param name="ReasoningTokens">Token count of reasoning content.</param>
7+
public record TextGenerationOutputTokenDetails(int ReasoningTokens);

src/Cnblogs.DashScope.Core/TextGenerationParameters.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class TextGenerationParameters : ITextGenerationParameters
3838
/// <inheritdoc />
3939
public bool? EnableSearch { get; set; }
4040

41+
/// <inheritdoc />
42+
public bool? EnableThinking { get; set; }
43+
4144
/// <inheritdoc />
4245
public IEnumerable<ToolDefinition>? Tools { get; set; }
4346

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Cnblogs.DashScope.Core;
2+
3+
/// <summary>
4+
/// Token usage details.
5+
/// </summary>
6+
/// <param name="CachedTokens">Token count of cached input.</param>
7+
public record TextGenerationPromptTokenDetails(int CachedTokens);

src/Cnblogs.DashScope.Core/TextGenerationTokenDetails.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/Cnblogs.DashScope.Core/TextGenerationTokenUsage.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ public class TextGenerationTokenUsage
1414
/// <summary>
1515
/// Input token details.
1616
/// </summary>
17-
public TextGenerationTokenDetails? PromptTokensDetails { get; set; }
17+
public TextGenerationPromptTokenDetails? PromptTokensDetails { get; set; }
18+
19+
/// <summary>
20+
/// Output token details.
21+
/// </summary>
22+
public TextGenerationOutputTokenDetails? OutputTokensDetails { get; set; }
1823

1924
/// <summary>
2025
/// The number of output token.

test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-nosse.request.body.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
]
1010
},
1111
"parameters": {
12-
"incremental_output": false
12+
"incremental_output": false,
13+
"result_format": "message"
1314
}
1415
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"model": "deepseek-r1",
2+
"model": "qwen-plus-latest",
33
"input": {
44
"messages": [
55
{
@@ -9,6 +9,8 @@
99
]
1010
},
1111
"parameters": {
12-
"incremental_output": true
12+
"incremental_output": true,
13+
"result_format": "message",
14+
"enable_thinking": true
1315
}
1416
}

test/Cnblogs.DashScope.Tests.Shared/RawHttpData/single-generation-message-reasoning-sse.response.body.txt

Lines changed: 98 additions & 1583 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
HTTP/1.1 200 OK
22
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
3-
x-request-id: e4ad5d0f-8019-9716-adc6-eae1411d3c9a
3+
x-request-id: d21851a2-675b-97a3-9132-2935c31d6ee3
44
content-type: text/event-stream;charset=UTF-8
55
x-dashscope-call-gateway: true
66
x-dashscope-timeout: 180
77
x-dashscope-finished: false
8-
req-cost-time: 500
9-
req-arrive-time: 1742405632039
10-
resp-start-time: 1742405632540
11-
x-envoy-upstream-service-time: 490
12-
date: Wed, 19 Mar 2025 17:33:52 GMT
8+
req-cost-time: 482
9+
req-arrive-time: 1749445556927
10+
resp-start-time: 1749445557410
11+
x-envoy-upstream-service-time: 474
12+
date: Mon, 09 Jun 2025 05:05:57 GMT
1313
server: istio-envoy
1414
transfer-encoding: chunked

0 commit comments

Comments
 (0)