@@ -17,7 +17,7 @@ public sealed class DashScopeChatClient : IChatClient
17
17
private readonly string _modelId ;
18
18
19
19
private static readonly JsonSchema EmptyObjectSchema =
20
- JsonSchema . FromText ( """{ "type": "object", "required":[],"properties":{}}"" " ) ;
20
+ JsonSchema . FromText ( "{ \ " type\" : \ " object\" , \ " required\ " :[],\ " properties\ " :{}}" ) ;
21
21
22
22
private static readonly TextGenerationParameters
23
23
DefaultTextGenerationParameter = new ( ) { ResultFormat = "message" } ;
@@ -55,15 +55,15 @@ public async Task<ChatResponse> GetResponseAsync(
55
55
if ( useVl )
56
56
{
57
57
var response = await _dashScopeClient . GetMultimodalGenerationAsync (
58
- new ModelRequest < MultimodalInput , IMultimodalParameters > ( )
58
+ new ModelRequest < MultimodalInput , IMultimodalParameters >
59
59
{
60
60
Input = new MultimodalInput { Messages = ToMultimodalMessages ( chatMessages ) } ,
61
61
Parameters = ToMultimodalParameters ( options ) ,
62
62
Model = modelId
63
63
} ,
64
64
cancellationToken ) ;
65
65
66
- var returnMessage = new ChatMessage ( )
66
+ var returnMessage = new ChatMessage
67
67
{
68
68
RawRepresentation = response , Role = ToChatRole ( response . Output . Choices [ 0 ] . Message . Role ) ,
69
69
} ;
@@ -80,7 +80,7 @@ public async Task<ChatResponse> GetResponseAsync(
80
80
81
81
if ( response . Usage != null )
82
82
{
83
- completion . Usage = new UsageDetails ( )
83
+ completion . Usage = new UsageDetails
84
84
{
85
85
InputTokenCount = response . Usage . InputTokens , OutputTokenCount = response . Usage . OutputTokens ,
86
86
} ;
@@ -92,7 +92,7 @@ public async Task<ChatResponse> GetResponseAsync(
92
92
{
93
93
var parameters = ToTextGenerationParameters ( options ) ?? DefaultTextGenerationParameter ;
94
94
var response = await _dashScopeClient . GetTextCompletionAsync (
95
- new ModelRequest < TextGenerationInput , ITextGenerationParameters > ( )
95
+ new ModelRequest < TextGenerationInput , ITextGenerationParameters >
96
96
{
97
97
Input = new TextGenerationInput
98
98
{
@@ -116,7 +116,7 @@ public async Task<ChatResponse> GetResponseAsync(
116
116
117
117
if ( response . Usage != null )
118
118
{
119
- completion . Usage = new UsageDetails ( )
119
+ completion . Usage = new UsageDetails
120
120
{
121
121
InputTokenCount = response . Usage . InputTokens ,
122
122
OutputTokenCount = response . Usage . OutputTokens ,
@@ -147,7 +147,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
147
147
var parameter = ToMultimodalParameters ( options ) ;
148
148
parameter . IncrementalOutput = true ;
149
149
var stream = _dashScopeClient . GetMultimodalGenerationStreamAsync (
150
- new ModelRequest < MultimodalInput , IMultimodalParameters > ( )
150
+ new ModelRequest < MultimodalInput , IMultimodalParameters >
151
151
{
152
152
Input = new MultimodalInput { Messages = ToMultimodalMessages ( chatMessages ) } ,
153
153
Parameters = parameter ,
@@ -164,7 +164,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
164
164
: ToFinishReason ( response . Output . Choices [ 0 ] . FinishReason ) ;
165
165
completionId ??= response . RequestId ;
166
166
167
- var update = new ChatResponseUpdate ( )
167
+ var update = new ChatResponseUpdate
168
168
{
169
169
ResponseId = completionId ,
170
170
CreatedAt = DateTimeOffset . Now ,
@@ -199,7 +199,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
199
199
{
200
200
// qwen does not support streaming with function call, fallback to non-streaming
201
201
var completion = await GetResponseAsync ( chatMessages , options , cancellationToken ) ;
202
- yield return new ChatResponseUpdate ( )
202
+ yield return new ChatResponseUpdate
203
203
{
204
204
ResponseId = completion . ResponseId ,
205
205
Role = completion . Messages [ 0 ] . Role ,
@@ -216,7 +216,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
216
216
var parameters = ToTextGenerationParameters ( options ) ?? DefaultTextGenerationParameter ;
217
217
parameters . IncrementalOutput = true ;
218
218
var stream = _dashScopeClient . GetTextCompletionStreamAsync (
219
- new ModelRequest < TextGenerationInput , ITextGenerationParameters > ( )
219
+ new ModelRequest < TextGenerationInput , ITextGenerationParameters >
220
220
{
221
221
Input = new TextGenerationInput
222
222
{
@@ -238,7 +238,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
238
238
: ToFinishReason ( response . Output . Choices [ 0 ] . FinishReason ) ;
239
239
completionId ??= response . RequestId ;
240
240
241
- var update = new ChatResponseUpdate ( )
241
+ var update = new ChatResponseUpdate
242
242
{
243
243
ResponseId = completionId ,
244
244
CreatedAt = DateTimeOffset . Now ,
@@ -257,7 +257,7 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
257
257
{
258
258
update . Contents . Add (
259
259
new UsageContent (
260
- new UsageDetails ( )
260
+ new UsageDetails
261
261
{
262
262
InputTokenCount = response . Usage . InputTokens ,
263
263
OutputTokenCount = response . Usage . OutputTokens ,
@@ -299,7 +299,7 @@ public void Dispose()
299
299
300
300
private static ChatMessage ToChatMessage ( TextChatMessage message )
301
301
{
302
- var returnMessage = new ChatMessage ( )
302
+ var returnMessage = new ChatMessage
303
303
{
304
304
RawRepresentation = message , Role = ToChatRole ( message . Role ) ,
305
305
} ;
@@ -485,7 +485,7 @@ private IEnumerable<TextChatMessage> ToTextChatMessages(
485
485
format = "json_object" ;
486
486
}
487
487
488
- return new TextGenerationParameters ( )
488
+ return new TextGenerationParameters
489
489
{
490
490
ResultFormat = format ,
491
491
Temperature = options . Temperature ,
0 commit comments