@@ -43,7 +43,7 @@ public DashScopeChatClient(IDashScopeClient dashScopeClient, string modelId)
43
43
44
44
/// <inheritdoc />
45
45
public async Task < ChatResponse > GetResponseAsync (
46
- IList < ChatMessage > chatMessages ,
46
+ IEnumerable < ChatMessage > chatMessages ,
47
47
ChatOptions ? options = null ,
48
48
CancellationToken cancellationToken = default )
49
49
{
@@ -130,7 +130,7 @@ public async Task<ChatResponse> GetResponseAsync(
130
130
131
131
/// <inheritdoc />
132
132
public async IAsyncEnumerable < ChatResponseUpdate > GetStreamingResponseAsync (
133
- IList < ChatMessage > chatMessages ,
133
+ IEnumerable < ChatMessage > chatMessages ,
134
134
ChatOptions ? options = null ,
135
135
[ EnumeratorCancellation ] CancellationToken cancellationToken = default )
136
136
{
@@ -202,10 +202,10 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
202
202
yield return new ChatResponseUpdate ( )
203
203
{
204
204
ResponseId = completion . ResponseId ,
205
- Role = completion . Message . Role ,
205
+ Role = completion . Messages [ 0 ] . Role ,
206
206
AdditionalProperties = completion . AdditionalProperties ,
207
- Contents = completion . Message . Contents ,
208
- RawRepresentation = completion . Message . RawRepresentation ,
207
+ Contents = completion . Messages [ 0 ] . Contents ,
208
+ RawRepresentation = completion . Messages [ 0 ] . RawRepresentation ,
209
209
CreatedAt = completion . CreatedAt ,
210
210
FinishReason = completion . FinishReason ,
211
211
ModelId = completion . ModelId ,
@@ -392,11 +392,11 @@ private List<MultimodalMessageContent> ToMultimodalMessageContents(IList<AIConte
392
392
var content = aiContent switch
393
393
{
394
394
TextContent text => MultimodalMessageContent . TextContent ( text . Text ) ,
395
- DataContent { Data . Length : > 0 } data when data . MediaTypeStartsWith ( "image" ) =>
395
+ DataContent { Data . Length : > 0 } data when data . HasTopLevelMediaType ( "image" ) =>
396
396
MultimodalMessageContent . ImageContent (
397
- data . Data . Value . Span ,
397
+ data . Data . Span ,
398
398
data . MediaType ?? throw new InvalidOperationException ( "image media type should not be null" ) ) ,
399
- DataContent { Uri : { } uri } data when data . MediaTypeStartsWith ( "image" ) =>
399
+ DataContent { Uri : { } uri } data when data . HasTopLevelMediaType ( "image" ) =>
400
400
MultimodalMessageContent . ImageContent ( uri ) ,
401
401
_ => null
402
402
} ;
@@ -422,7 +422,7 @@ private IEnumerable<TextChatMessage> ToTextChatMessages(
422
422
{
423
423
yield return new TextChatMessage (
424
424
from . Role . Value ,
425
- from . Text ?? string . Empty ,
425
+ from . Text ,
426
426
from . AuthorName ) ;
427
427
}
428
428
else if ( from . Role == ChatRole . Tool )
@@ -464,7 +464,7 @@ private IEnumerable<TextChatMessage> ToTextChatMessages(
464
464
// <400> InternalError.Algo.InvalidParameter: Empty tool_calls is not supported in message
465
465
yield return new TextChatMessage (
466
466
from . Role . Value ,
467
- from . Text ?? string . Empty ,
467
+ from . Text ,
468
468
from . AuthorName ,
469
469
null ,
470
470
functionCall . Count > 0 ? functionCall : null ) ;
0 commit comments