@ai-sdk/alibaba 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +136 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
- package/src/alibaba-chat-language-model.ts +1 -1
- package/src/alibaba-error.ts +17 -0
- package/src/alibaba-provider.ts +4 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @ai-sdk/alibaba
|
|
2
2
|
|
|
3
|
+
## 1.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a727da4: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
8
|
+
- Updated dependencies [a727da4]
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.43
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.25
|
|
11
|
+
- @ai-sdk/provider@3.0.10
|
|
12
|
+
|
|
13
|
+
## 1.0.18
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- a7f3c72: trigger release for all packages after provenance setup
|
|
18
|
+
- Updated dependencies [a7f3c72]
|
|
19
|
+
- Updated dependencies [408a2ad]
|
|
20
|
+
- @ai-sdk/openai-compatible@2.0.42
|
|
21
|
+
- @ai-sdk/provider@3.0.9
|
|
22
|
+
- @ai-sdk/provider-utils@4.0.24
|
|
23
|
+
|
|
3
24
|
## 1.0.17
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
2
|
import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
|
|
6
6
|
declare const alibabaLanguageModelOptions: z.ZodObject<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
2
|
import { ProviderV3, LanguageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AlibabaChatModelId = 'qwen3-max' | 'qwen3-max-preview' | 'qwen-plus' | 'qwen-plus-latest' | 'qwen-flash' | 'qwen-turbo' | 'qwen-turbo-latest' | 'qwen3-235b-a22b' | 'qwen3-32b' | 'qwen3-30b-a3b' | 'qwen3-14b' | 'qwen3-next-80b-a3b-thinking' | 'qwen3-235b-a22b-thinking-2507' | 'qwen3-30b-a3b-thinking-2507' | 'qwq-plus' | 'qwq-plus-latest' | 'qwq-32b' | 'qwen-coder' | 'qwen3-coder-plus' | 'qwen3-coder-flash' | (string & {});
|
|
6
6
|
declare const alibabaLanguageModelOptions: z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -28,14 +28,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/alibaba-provider.ts
|
|
30
30
|
var import_provider4 = require("@ai-sdk/provider");
|
|
31
|
-
var
|
|
32
|
-
var import_v44 = require("zod/v4");
|
|
31
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
33
32
|
|
|
34
33
|
// src/alibaba-chat-language-model.ts
|
|
35
34
|
var import_internal2 = require("@ai-sdk/openai-compatible/internal");
|
|
36
35
|
var import_provider2 = require("@ai-sdk/provider");
|
|
37
|
-
var
|
|
38
|
-
var
|
|
36
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
37
|
+
var import_v43 = require("zod/v4");
|
|
39
38
|
|
|
40
39
|
// src/alibaba-chat-options.ts
|
|
41
40
|
var import_v4 = require("zod/v4");
|
|
@@ -59,6 +58,21 @@ var alibabaLanguageModelOptions = import_v4.z.object({
|
|
|
59
58
|
parallelToolCalls: import_v4.z.boolean().optional()
|
|
60
59
|
});
|
|
61
60
|
|
|
61
|
+
// src/alibaba-error.ts
|
|
62
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
63
|
+
var import_v42 = require("zod/v4");
|
|
64
|
+
var alibabaErrorDataSchema = import_v42.z.object({
|
|
65
|
+
error: import_v42.z.object({
|
|
66
|
+
message: import_v42.z.string(),
|
|
67
|
+
code: import_v42.z.string().nullish(),
|
|
68
|
+
type: import_v42.z.string().nullish()
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
var alibabaFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
72
|
+
errorSchema: alibabaErrorDataSchema,
|
|
73
|
+
errorToMessage: (data) => data.error.message
|
|
74
|
+
});
|
|
75
|
+
|
|
62
76
|
// src/convert-alibaba-usage.ts
|
|
63
77
|
var import_internal = require("@ai-sdk/openai-compatible/internal");
|
|
64
78
|
function convertAlibabaUsage(usage) {
|
|
@@ -78,12 +92,12 @@ function convertAlibabaUsage(usage) {
|
|
|
78
92
|
|
|
79
93
|
// src/convert-to-alibaba-chat-messages.ts
|
|
80
94
|
var import_provider = require("@ai-sdk/provider");
|
|
81
|
-
var
|
|
95
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
82
96
|
function formatImageUrl({
|
|
83
97
|
data,
|
|
84
98
|
mediaType
|
|
85
99
|
}) {
|
|
86
|
-
return data instanceof URL ? data.toString() : `data:${mediaType};base64,${(0,
|
|
100
|
+
return data instanceof URL ? data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(data)}`;
|
|
87
101
|
}
|
|
88
102
|
function convertToAlibabaChatMessages({
|
|
89
103
|
prompt,
|
|
@@ -298,7 +312,7 @@ var AlibabaLanguageModel = class {
|
|
|
298
312
|
var _a;
|
|
299
313
|
const warnings = [];
|
|
300
314
|
const cacheControlValidator = new CacheControlValidator();
|
|
301
|
-
const alibabaOptions = await (0,
|
|
315
|
+
const alibabaOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
302
316
|
provider: "alibaba",
|
|
303
317
|
providerOptions,
|
|
304
318
|
schema: alibabaLanguageModelOptions
|
|
@@ -355,12 +369,12 @@ var AlibabaLanguageModel = class {
|
|
|
355
369
|
responseHeaders,
|
|
356
370
|
value: response,
|
|
357
371
|
rawValue: rawResponse
|
|
358
|
-
} = await (0,
|
|
372
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
359
373
|
url: `${this.config.baseURL}/chat/completions`,
|
|
360
|
-
headers: (0,
|
|
374
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
361
375
|
body: args,
|
|
362
376
|
failedResponseHandler: alibabaFailedResponseHandler,
|
|
363
|
-
successfulResponseHandler: (0,
|
|
377
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
364
378
|
alibabaChatResponseSchema
|
|
365
379
|
),
|
|
366
380
|
abortSignal: options.abortSignal,
|
|
@@ -412,12 +426,12 @@ var AlibabaLanguageModel = class {
|
|
|
412
426
|
stream: true,
|
|
413
427
|
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
414
428
|
};
|
|
415
|
-
const { responseHeaders, value: response } = await (0,
|
|
429
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
|
|
416
430
|
url: `${this.config.baseURL}/chat/completions`,
|
|
417
|
-
headers: (0,
|
|
431
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
418
432
|
body,
|
|
419
433
|
failedResponseHandler: alibabaFailedResponseHandler,
|
|
420
|
-
successfulResponseHandler: (0,
|
|
434
|
+
successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
|
|
421
435
|
alibabaChatChunkSchema
|
|
422
436
|
),
|
|
423
437
|
abortSignal: options.abortSignal,
|
|
@@ -469,7 +483,7 @@ var AlibabaLanguageModel = class {
|
|
|
469
483
|
controller.enqueue({ type: "text-end", id: "0" });
|
|
470
484
|
activeText = false;
|
|
471
485
|
}
|
|
472
|
-
activeReasoningId = (0,
|
|
486
|
+
activeReasoningId = (0, import_provider_utils3.generateId)();
|
|
473
487
|
controller.enqueue({
|
|
474
488
|
type: "reasoning-start",
|
|
475
489
|
id: activeReasoningId
|
|
@@ -548,7 +562,7 @@ var AlibabaLanguageModel = class {
|
|
|
548
562
|
delta: toolCall2.function.arguments
|
|
549
563
|
});
|
|
550
564
|
}
|
|
551
|
-
if ((0,
|
|
565
|
+
if ((0, import_provider_utils3.isParsableJson)(toolCall2.function.arguments)) {
|
|
552
566
|
controller.enqueue({
|
|
553
567
|
type: "tool-input-end",
|
|
554
568
|
id: toolCall2.id
|
|
@@ -575,7 +589,7 @@ var AlibabaLanguageModel = class {
|
|
|
575
589
|
delta: toolCallDelta.function.arguments
|
|
576
590
|
});
|
|
577
591
|
}
|
|
578
|
-
if ((0,
|
|
592
|
+
if ((0, import_provider_utils3.isParsableJson)(toolCall.function.arguments)) {
|
|
579
593
|
controller.enqueue({
|
|
580
594
|
type: "tool-input-end",
|
|
581
595
|
id: toolCall.id
|
|
@@ -620,72 +634,72 @@ var AlibabaLanguageModel = class {
|
|
|
620
634
|
};
|
|
621
635
|
}
|
|
622
636
|
};
|
|
623
|
-
var alibabaUsageSchema =
|
|
624
|
-
prompt_tokens:
|
|
625
|
-
completion_tokens:
|
|
626
|
-
total_tokens:
|
|
627
|
-
prompt_tokens_details:
|
|
628
|
-
cached_tokens:
|
|
629
|
-
cache_creation_input_tokens:
|
|
637
|
+
var alibabaUsageSchema = import_v43.z.object({
|
|
638
|
+
prompt_tokens: import_v43.z.number(),
|
|
639
|
+
completion_tokens: import_v43.z.number(),
|
|
640
|
+
total_tokens: import_v43.z.number(),
|
|
641
|
+
prompt_tokens_details: import_v43.z.object({
|
|
642
|
+
cached_tokens: import_v43.z.number().nullish(),
|
|
643
|
+
cache_creation_input_tokens: import_v43.z.number().nullish()
|
|
630
644
|
}).nullish(),
|
|
631
|
-
completion_tokens_details:
|
|
632
|
-
reasoning_tokens:
|
|
645
|
+
completion_tokens_details: import_v43.z.object({
|
|
646
|
+
reasoning_tokens: import_v43.z.number().nullish()
|
|
633
647
|
}).nullish()
|
|
634
648
|
});
|
|
635
|
-
var alibabaChatResponseSchema =
|
|
636
|
-
id:
|
|
637
|
-
created:
|
|
638
|
-
model:
|
|
639
|
-
choices:
|
|
640
|
-
|
|
641
|
-
message:
|
|
642
|
-
role:
|
|
643
|
-
content:
|
|
644
|
-
reasoning_content:
|
|
649
|
+
var alibabaChatResponseSchema = import_v43.z.object({
|
|
650
|
+
id: import_v43.z.string().nullish(),
|
|
651
|
+
created: import_v43.z.number().nullish(),
|
|
652
|
+
model: import_v43.z.string().nullish(),
|
|
653
|
+
choices: import_v43.z.array(
|
|
654
|
+
import_v43.z.object({
|
|
655
|
+
message: import_v43.z.object({
|
|
656
|
+
role: import_v43.z.literal("assistant").nullish(),
|
|
657
|
+
content: import_v43.z.string().nullish(),
|
|
658
|
+
reasoning_content: import_v43.z.string().nullish(),
|
|
645
659
|
// Alibaba thinking mode
|
|
646
|
-
tool_calls:
|
|
647
|
-
|
|
648
|
-
id:
|
|
649
|
-
type:
|
|
650
|
-
function:
|
|
651
|
-
name:
|
|
652
|
-
arguments:
|
|
660
|
+
tool_calls: import_v43.z.array(
|
|
661
|
+
import_v43.z.object({
|
|
662
|
+
id: import_v43.z.string(),
|
|
663
|
+
type: import_v43.z.literal("function"),
|
|
664
|
+
function: import_v43.z.object({
|
|
665
|
+
name: import_v43.z.string(),
|
|
666
|
+
arguments: import_v43.z.string()
|
|
653
667
|
})
|
|
654
668
|
})
|
|
655
669
|
).nullish()
|
|
656
670
|
}),
|
|
657
|
-
finish_reason:
|
|
658
|
-
index:
|
|
671
|
+
finish_reason: import_v43.z.string().nullish(),
|
|
672
|
+
index: import_v43.z.number()
|
|
659
673
|
})
|
|
660
674
|
),
|
|
661
675
|
usage: alibabaUsageSchema.nullish()
|
|
662
676
|
});
|
|
663
|
-
var alibabaChatChunkSchema =
|
|
664
|
-
id:
|
|
665
|
-
created:
|
|
666
|
-
model:
|
|
667
|
-
choices:
|
|
668
|
-
|
|
669
|
-
delta:
|
|
670
|
-
role:
|
|
671
|
-
content:
|
|
672
|
-
reasoning_content:
|
|
677
|
+
var alibabaChatChunkSchema = import_v43.z.object({
|
|
678
|
+
id: import_v43.z.string().nullish(),
|
|
679
|
+
created: import_v43.z.number().nullish(),
|
|
680
|
+
model: import_v43.z.string().nullish(),
|
|
681
|
+
choices: import_v43.z.array(
|
|
682
|
+
import_v43.z.object({
|
|
683
|
+
delta: import_v43.z.object({
|
|
684
|
+
role: import_v43.z.enum(["assistant"]).nullish(),
|
|
685
|
+
content: import_v43.z.string().nullish(),
|
|
686
|
+
reasoning_content: import_v43.z.string().nullish(),
|
|
673
687
|
// Alibaba thinking mode delta
|
|
674
|
-
tool_calls:
|
|
675
|
-
|
|
676
|
-
index:
|
|
688
|
+
tool_calls: import_v43.z.array(
|
|
689
|
+
import_v43.z.object({
|
|
690
|
+
index: import_v43.z.number().nullish(),
|
|
677
691
|
// Index for accumulating tool calls
|
|
678
|
-
id:
|
|
679
|
-
type:
|
|
680
|
-
function:
|
|
681
|
-
name:
|
|
682
|
-
arguments:
|
|
692
|
+
id: import_v43.z.string().nullish(),
|
|
693
|
+
type: import_v43.z.literal("function").nullish(),
|
|
694
|
+
function: import_v43.z.object({
|
|
695
|
+
name: import_v43.z.string().nullish(),
|
|
696
|
+
arguments: import_v43.z.string().nullish()
|
|
683
697
|
}).nullish()
|
|
684
698
|
})
|
|
685
699
|
).nullish()
|
|
686
700
|
}),
|
|
687
|
-
finish_reason:
|
|
688
|
-
index:
|
|
701
|
+
finish_reason: import_v43.z.string().nullish(),
|
|
702
|
+
index: import_v43.z.number()
|
|
689
703
|
})
|
|
690
704
|
),
|
|
691
705
|
usage: alibabaUsageSchema.nullish()
|
|
@@ -694,59 +708,59 @@ var alibabaChatChunkSchema = import_v42.z.object({
|
|
|
694
708
|
|
|
695
709
|
// src/alibaba-video-model.ts
|
|
696
710
|
var import_provider3 = require("@ai-sdk/provider");
|
|
697
|
-
var
|
|
698
|
-
var
|
|
699
|
-
var alibabaVideoModelOptionsSchema = (0,
|
|
700
|
-
() => (0,
|
|
701
|
-
|
|
702
|
-
negativePrompt:
|
|
703
|
-
audioUrl:
|
|
704
|
-
promptExtend:
|
|
705
|
-
shotType:
|
|
706
|
-
watermark:
|
|
707
|
-
audio:
|
|
708
|
-
referenceUrls:
|
|
709
|
-
pollIntervalMs:
|
|
710
|
-
pollTimeoutMs:
|
|
711
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
712
|
+
var import_v44 = require("zod/v4");
|
|
713
|
+
var alibabaVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
|
|
714
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
715
|
+
import_v44.z.object({
|
|
716
|
+
negativePrompt: import_v44.z.string().nullish(),
|
|
717
|
+
audioUrl: import_v44.z.string().nullish(),
|
|
718
|
+
promptExtend: import_v44.z.boolean().nullish(),
|
|
719
|
+
shotType: import_v44.z.enum(["single", "multi"]).nullish(),
|
|
720
|
+
watermark: import_v44.z.boolean().nullish(),
|
|
721
|
+
audio: import_v44.z.boolean().nullish(),
|
|
722
|
+
referenceUrls: import_v44.z.array(import_v44.z.string()).nullish(),
|
|
723
|
+
pollIntervalMs: import_v44.z.number().positive().nullish(),
|
|
724
|
+
pollTimeoutMs: import_v44.z.number().positive().nullish()
|
|
711
725
|
}).passthrough()
|
|
712
726
|
)
|
|
713
727
|
);
|
|
714
|
-
var alibabaVideoErrorSchema =
|
|
715
|
-
code:
|
|
716
|
-
message:
|
|
717
|
-
request_id:
|
|
728
|
+
var alibabaVideoErrorSchema = import_v44.z.object({
|
|
729
|
+
code: import_v44.z.string().nullish(),
|
|
730
|
+
message: import_v44.z.string(),
|
|
731
|
+
request_id: import_v44.z.string().nullish()
|
|
718
732
|
});
|
|
719
|
-
var alibabaVideoFailedResponseHandler = (0,
|
|
733
|
+
var alibabaVideoFailedResponseHandler = (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
720
734
|
errorSchema: alibabaVideoErrorSchema,
|
|
721
735
|
errorToMessage: (data) => data.message
|
|
722
736
|
});
|
|
723
|
-
var alibabaVideoCreateTaskSchema =
|
|
724
|
-
output:
|
|
725
|
-
task_status:
|
|
726
|
-
task_id:
|
|
737
|
+
var alibabaVideoCreateTaskSchema = import_v44.z.object({
|
|
738
|
+
output: import_v44.z.object({
|
|
739
|
+
task_status: import_v44.z.string(),
|
|
740
|
+
task_id: import_v44.z.string()
|
|
727
741
|
}).nullish(),
|
|
728
|
-
request_id:
|
|
742
|
+
request_id: import_v44.z.string().nullish()
|
|
729
743
|
});
|
|
730
|
-
var alibabaVideoTaskStatusSchema =
|
|
731
|
-
output:
|
|
732
|
-
task_id:
|
|
733
|
-
task_status:
|
|
734
|
-
video_url:
|
|
735
|
-
submit_time:
|
|
736
|
-
scheduled_time:
|
|
737
|
-
end_time:
|
|
738
|
-
orig_prompt:
|
|
739
|
-
actual_prompt:
|
|
740
|
-
code:
|
|
741
|
-
message:
|
|
744
|
+
var alibabaVideoTaskStatusSchema = import_v44.z.object({
|
|
745
|
+
output: import_v44.z.object({
|
|
746
|
+
task_id: import_v44.z.string(),
|
|
747
|
+
task_status: import_v44.z.string(),
|
|
748
|
+
video_url: import_v44.z.string().nullish(),
|
|
749
|
+
submit_time: import_v44.z.string().nullish(),
|
|
750
|
+
scheduled_time: import_v44.z.string().nullish(),
|
|
751
|
+
end_time: import_v44.z.string().nullish(),
|
|
752
|
+
orig_prompt: import_v44.z.string().nullish(),
|
|
753
|
+
actual_prompt: import_v44.z.string().nullish(),
|
|
754
|
+
code: import_v44.z.string().nullish(),
|
|
755
|
+
message: import_v44.z.string().nullish()
|
|
742
756
|
}).nullish(),
|
|
743
|
-
usage:
|
|
744
|
-
duration:
|
|
745
|
-
output_video_duration:
|
|
746
|
-
SR:
|
|
747
|
-
size:
|
|
757
|
+
usage: import_v44.z.object({
|
|
758
|
+
duration: import_v44.z.number().nullish(),
|
|
759
|
+
output_video_duration: import_v44.z.number().nullish(),
|
|
760
|
+
SR: import_v44.z.number().nullish(),
|
|
761
|
+
size: import_v44.z.string().nullish()
|
|
748
762
|
}).nullish(),
|
|
749
|
-
request_id:
|
|
763
|
+
request_id: import_v44.z.string().nullish()
|
|
750
764
|
});
|
|
751
765
|
function detectMode(modelId) {
|
|
752
766
|
if (modelId.includes("-i2v")) return "i2v";
|
|
@@ -768,7 +782,7 @@ var AlibabaVideoModel = class {
|
|
|
768
782
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
769
783
|
const warnings = [];
|
|
770
784
|
const mode = detectMode(this.modelId);
|
|
771
|
-
const alibabaOptions = await (0,
|
|
785
|
+
const alibabaOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
772
786
|
provider: "alibaba",
|
|
773
787
|
providerOptions: options.providerOptions,
|
|
774
788
|
schema: alibabaVideoModelOptionsSchema
|
|
@@ -787,7 +801,7 @@ var AlibabaVideoModel = class {
|
|
|
787
801
|
if (options.image.type === "url") {
|
|
788
802
|
input.img_url = options.image.url;
|
|
789
803
|
} else {
|
|
790
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data : (0,
|
|
804
|
+
const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
|
|
791
805
|
input.img_url = base64Data;
|
|
792
806
|
}
|
|
793
807
|
}
|
|
@@ -856,10 +870,10 @@ var AlibabaVideoModel = class {
|
|
|
856
870
|
details: "Alibaba video models only support generating 1 video per call."
|
|
857
871
|
});
|
|
858
872
|
}
|
|
859
|
-
const { value: createResponse } = await (0,
|
|
873
|
+
const { value: createResponse } = await (0, import_provider_utils4.postJsonToApi)({
|
|
860
874
|
url: `${this.config.baseURL}/api/v1/services/aigc/video-generation/video-synthesis`,
|
|
861
|
-
headers: (0,
|
|
862
|
-
await (0,
|
|
875
|
+
headers: (0, import_provider_utils4.combineHeaders)(
|
|
876
|
+
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
863
877
|
options.headers,
|
|
864
878
|
{
|
|
865
879
|
"X-DashScope-Async": "enable"
|
|
@@ -870,7 +884,7 @@ var AlibabaVideoModel = class {
|
|
|
870
884
|
input,
|
|
871
885
|
parameters
|
|
872
886
|
},
|
|
873
|
-
successfulResponseHandler: (0,
|
|
887
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
874
888
|
alibabaVideoCreateTaskSchema
|
|
875
889
|
),
|
|
876
890
|
failedResponseHandler: alibabaVideoFailedResponseHandler,
|
|
@@ -890,20 +904,20 @@ var AlibabaVideoModel = class {
|
|
|
890
904
|
let finalResponse;
|
|
891
905
|
let responseHeaders;
|
|
892
906
|
while (true) {
|
|
893
|
-
await (0,
|
|
907
|
+
await (0, import_provider_utils4.delay)(pollIntervalMs, { abortSignal: options.abortSignal });
|
|
894
908
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
895
909
|
throw new import_provider3.AISDKError({
|
|
896
910
|
name: "ALIBABA_VIDEO_GENERATION_TIMEOUT",
|
|
897
911
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
898
912
|
});
|
|
899
913
|
}
|
|
900
|
-
const { value: statusResponse, responseHeaders: pollHeaders } = await (0,
|
|
914
|
+
const { value: statusResponse, responseHeaders: pollHeaders } = await (0, import_provider_utils4.getFromApi)({
|
|
901
915
|
url: `${this.config.baseURL}/api/v1/tasks/${taskId}`,
|
|
902
|
-
headers: (0,
|
|
903
|
-
await (0,
|
|
916
|
+
headers: (0, import_provider_utils4.combineHeaders)(
|
|
917
|
+
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
904
918
|
options.headers
|
|
905
919
|
),
|
|
906
|
-
successfulResponseHandler: (0,
|
|
920
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
907
921
|
alibabaVideoTaskStatusSchema
|
|
908
922
|
),
|
|
909
923
|
failedResponseHandler: alibabaVideoFailedResponseHandler,
|
|
@@ -964,27 +978,16 @@ var AlibabaVideoModel = class {
|
|
|
964
978
|
};
|
|
965
979
|
|
|
966
980
|
// src/version.ts
|
|
967
|
-
var VERSION = "1.0.
|
|
981
|
+
var VERSION = "1.0.19";
|
|
968
982
|
|
|
969
983
|
// src/alibaba-provider.ts
|
|
970
|
-
var alibabaErrorDataSchema = import_v44.z.object({
|
|
971
|
-
error: import_v44.z.object({
|
|
972
|
-
message: import_v44.z.string(),
|
|
973
|
-
code: import_v44.z.string().nullish(),
|
|
974
|
-
type: import_v44.z.string().nullish()
|
|
975
|
-
})
|
|
976
|
-
});
|
|
977
|
-
var alibabaFailedResponseHandler = (0, import_provider_utils4.createJsonErrorResponseHandler)({
|
|
978
|
-
errorSchema: alibabaErrorDataSchema,
|
|
979
|
-
errorToMessage: (data) => data.error.message
|
|
980
|
-
});
|
|
981
984
|
function createAlibaba(options = {}) {
|
|
982
985
|
var _a, _b;
|
|
983
|
-
const baseURL = (_a = (0,
|
|
984
|
-
const videoBaseURL = (_b = (0,
|
|
985
|
-
const getHeaders = () => (0,
|
|
986
|
+
const baseURL = (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
|
|
987
|
+
const videoBaseURL = (_b = (0, import_provider_utils5.withoutTrailingSlash)(options.videoBaseURL)) != null ? _b : "https://dashscope-intl.aliyuncs.com";
|
|
988
|
+
const getHeaders = () => (0, import_provider_utils5.withUserAgentSuffix)(
|
|
986
989
|
{
|
|
987
|
-
Authorization: `Bearer ${(0,
|
|
990
|
+
Authorization: `Bearer ${(0, import_provider_utils5.loadApiKey)({
|
|
988
991
|
apiKey: options.apiKey,
|
|
989
992
|
environmentVariableName: "ALIBABA_API_KEY",
|
|
990
993
|
description: "Alibaba Cloud (DashScope)"
|