diff --git a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs index 8b0012f..f28456f 100644 --- a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs +++ b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs @@ -459,12 +459,15 @@ private IEnumerable ToTextChatMessages( tools?.FindIndex(f => f.Function?.Name == c.Name) ?? -1, new FunctionCall(c.Name, JsonSerializer.Serialize(c.Arguments, ToolCallJsonSerializerOptions)))) .ToList(); + + // function all array must be null when empty + // <400> InternalError.Algo.InvalidParameter: Empty tool_calls is not supported in message yield return new TextChatMessage( from.Role.Value, from.Text ?? string.Empty, from.AuthorName, null, - functionCall); + functionCall.Count > 0 ? functionCall : null); } }