@ai-sdk/alibaba 2.0.0-beta.6 → 2.0.0-beta.61
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 +501 -0
- package/README.md +22 -1
- package/dist/index.d.ts +34 -5
- package/dist/index.js +489 -318
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/src/{alibaba-chat-options.ts → alibaba-chat-language-model-options.ts} +4 -3
- package/src/alibaba-chat-language-model.ts +97 -133
- package/src/alibaba-config.ts +1 -1
- package/src/alibaba-embedding-model-options.ts +33 -0
- package/src/alibaba-embedding-model.ts +178 -0
- package/src/alibaba-error.ts +17 -0
- package/src/alibaba-provider.ts +41 -25
- package/src/alibaba-video-model-options.ts +46 -0
- package/src/alibaba-video-model.ts +9 -50
- package/src/convert-to-alibaba-chat-messages.ts +59 -58
- package/src/index.ts +11 -5
- package/src/version.ts +6 -3
- package/dist/index.d.mts +0 -119
- package/dist/index.mjs +0 -1054
- package/dist/index.mjs.map +0 -1
package/src/alibaba-provider.ts
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NoSuchModelError,
|
|
3
|
+
type EmbeddingModelV4,
|
|
2
4
|
type Experimental_VideoModelV4,
|
|
3
5
|
type LanguageModelV4,
|
|
4
|
-
NoSuchModelError,
|
|
5
6
|
type ProviderV4,
|
|
6
7
|
} from '@ai-sdk/provider';
|
|
7
8
|
import {
|
|
8
|
-
createJsonErrorResponseHandler,
|
|
9
|
-
type FetchFunction,
|
|
10
9
|
loadApiKey,
|
|
11
10
|
withoutTrailingSlash,
|
|
12
11
|
withUserAgentSuffix,
|
|
12
|
+
type FetchFunction,
|
|
13
13
|
} from '@ai-sdk/provider-utils';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
14
|
+
import { AlibabaChatLanguageModel } from './alibaba-chat-language-model';
|
|
15
|
+
import type { AlibabaChatModelId } from './alibaba-chat-language-model-options';
|
|
16
|
+
import { AlibabaEmbeddingModel } from './alibaba-embedding-model';
|
|
17
|
+
import type { AlibabaEmbeddingModelId } from './alibaba-embedding-model-options';
|
|
17
18
|
import { AlibabaVideoModel } from './alibaba-video-model';
|
|
18
19
|
import type { AlibabaVideoModelId } from './alibaba-video-settings';
|
|
19
20
|
import { VERSION } from './version';
|
|
20
21
|
|
|
21
|
-
export type AlibabaErrorData
|
|
22
|
-
|
|
23
|
-
const alibabaErrorDataSchema = z.object({
|
|
24
|
-
error: z.object({
|
|
25
|
-
message: z.string(),
|
|
26
|
-
code: z.string().nullish(),
|
|
27
|
-
type: z.string().nullish(),
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export const alibabaFailedResponseHandler = createJsonErrorResponseHandler({
|
|
32
|
-
errorSchema: alibabaErrorDataSchema,
|
|
33
|
-
errorToMessage: data => data.error.message,
|
|
34
|
-
});
|
|
22
|
+
export type { AlibabaErrorData } from './alibaba-error';
|
|
23
|
+
export { alibabaFailedResponseHandler } from './alibaba-error';
|
|
35
24
|
|
|
36
25
|
export interface AlibabaProvider extends ProviderV4 {
|
|
37
26
|
(modelId: AlibabaChatModelId): LanguageModelV4;
|
|
@@ -46,6 +35,16 @@ export interface AlibabaProvider extends ProviderV4 {
|
|
|
46
35
|
*/
|
|
47
36
|
chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
|
|
48
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Creates a model for text embeddings.
|
|
40
|
+
*/
|
|
41
|
+
embedding(modelId: AlibabaEmbeddingModelId): EmbeddingModelV4;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a model for text embeddings.
|
|
45
|
+
*/
|
|
46
|
+
embeddingModel(modelId: AlibabaEmbeddingModelId): EmbeddingModelV4;
|
|
47
|
+
|
|
49
48
|
/**
|
|
50
49
|
* Creates a model for video generation.
|
|
51
50
|
*/
|
|
@@ -71,6 +70,13 @@ export interface AlibabaProviderSettings {
|
|
|
71
70
|
*/
|
|
72
71
|
videoBaseURL?: string;
|
|
73
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Use a different URL prefix for embedding API calls.
|
|
75
|
+
* The embedding API uses the DashScope native endpoint (not the OpenAI-compatible endpoint).
|
|
76
|
+
* The default prefix is `https://dashscope-intl.aliyuncs.com/api/v1`.
|
|
77
|
+
*/
|
|
78
|
+
embeddingBaseURL?: string;
|
|
79
|
+
|
|
74
80
|
/**
|
|
75
81
|
* API key that is being sent using the `Authorization` header.
|
|
76
82
|
* It defaults to the `ALIBABA_API_KEY` environment variable.
|
|
@@ -111,6 +117,10 @@ export function createAlibaba(
|
|
|
111
117
|
withoutTrailingSlash(options.videoBaseURL) ??
|
|
112
118
|
'https://dashscope-intl.aliyuncs.com';
|
|
113
119
|
|
|
120
|
+
const embeddingBaseURL =
|
|
121
|
+
withoutTrailingSlash(options.embeddingBaseURL) ??
|
|
122
|
+
'https://dashscope-intl.aliyuncs.com/api/v1';
|
|
123
|
+
|
|
114
124
|
const getHeaders = () =>
|
|
115
125
|
withUserAgentSuffix(
|
|
116
126
|
{
|
|
@@ -125,7 +135,7 @@ export function createAlibaba(
|
|
|
125
135
|
);
|
|
126
136
|
|
|
127
137
|
const createLanguageModel = (modelId: AlibabaChatModelId) =>
|
|
128
|
-
new
|
|
138
|
+
new AlibabaChatLanguageModel(modelId, {
|
|
129
139
|
provider: 'alibaba.chat',
|
|
130
140
|
baseURL,
|
|
131
141
|
headers: getHeaders,
|
|
@@ -133,6 +143,14 @@ export function createAlibaba(
|
|
|
133
143
|
includeUsage: options.includeUsage ?? true,
|
|
134
144
|
});
|
|
135
145
|
|
|
146
|
+
const createEmbeddingModel = (modelId: AlibabaEmbeddingModelId) =>
|
|
147
|
+
new AlibabaEmbeddingModel(modelId, {
|
|
148
|
+
provider: 'alibaba.embedding',
|
|
149
|
+
baseURL: embeddingBaseURL,
|
|
150
|
+
headers: getHeaders,
|
|
151
|
+
fetch: options.fetch,
|
|
152
|
+
});
|
|
153
|
+
|
|
136
154
|
const createVideoModel = (modelId: AlibabaVideoModelId) =>
|
|
137
155
|
new AlibabaVideoModel(modelId, {
|
|
138
156
|
provider: 'alibaba.video',
|
|
@@ -154,6 +172,8 @@ export function createAlibaba(
|
|
|
154
172
|
provider.specificationVersion = 'v4' as const;
|
|
155
173
|
provider.languageModel = createLanguageModel;
|
|
156
174
|
provider.chatModel = createLanguageModel;
|
|
175
|
+
provider.embedding = createEmbeddingModel;
|
|
176
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
157
177
|
provider.video = createVideoModel;
|
|
158
178
|
provider.videoModel = createVideoModel;
|
|
159
179
|
|
|
@@ -161,10 +181,6 @@ export function createAlibaba(
|
|
|
161
181
|
throw new NoSuchModelError({ modelId, modelType: 'imageModel' });
|
|
162
182
|
};
|
|
163
183
|
|
|
164
|
-
provider.embeddingModel = (modelId: string) => {
|
|
165
|
-
throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });
|
|
166
|
-
};
|
|
167
|
-
|
|
168
184
|
return provider;
|
|
169
185
|
}
|
|
170
186
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
|
|
4
|
+
export type AlibabaVideoModelOptions = {
|
|
5
|
+
/** Negative prompt to specify what to avoid (max 500 chars). */
|
|
6
|
+
negativePrompt?: string | null;
|
|
7
|
+
/** URL to audio file for audio-video sync (WAV/MP3, 3-30s, max 15MB). */
|
|
8
|
+
audioUrl?: string | null;
|
|
9
|
+
/** Enable prompt extension/rewriting for better generation. Defaults to true. */
|
|
10
|
+
promptExtend?: boolean | null;
|
|
11
|
+
/** Shot type: 'single' for single-shot or 'multi' for multi-shot narrative. */
|
|
12
|
+
shotType?: 'single' | 'multi' | null;
|
|
13
|
+
/** Whether to add watermark to generated video. Defaults to false. */
|
|
14
|
+
watermark?: boolean | null;
|
|
15
|
+
/** Enable audio generation (for I2V/R2V models). */
|
|
16
|
+
audio?: boolean | null;
|
|
17
|
+
/**
|
|
18
|
+
* Reference URLs for reference-to-video mode.
|
|
19
|
+
* Array of URLs to images (0-5) and/or videos (0-3), max 5 total.
|
|
20
|
+
* Use character identifiers (character1, character2) in prompts to reference them.
|
|
21
|
+
*/
|
|
22
|
+
referenceUrls?: string[] | null;
|
|
23
|
+
/** Polling interval in milliseconds. Defaults to 5000 (5 seconds). */
|
|
24
|
+
pollIntervalMs?: number | null;
|
|
25
|
+
/** Maximum wait time in milliseconds for video generation. Defaults to 600000 (10 minutes). */
|
|
26
|
+
pollTimeoutMs?: number | null;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const alibabaVideoModelOptionsSchema = lazySchema(() =>
|
|
31
|
+
zodSchema(
|
|
32
|
+
z
|
|
33
|
+
.object({
|
|
34
|
+
negativePrompt: z.string().nullish(),
|
|
35
|
+
audioUrl: z.string().nullish(),
|
|
36
|
+
promptExtend: z.boolean().nullish(),
|
|
37
|
+
shotType: z.enum(['single', 'multi']).nullish(),
|
|
38
|
+
watermark: z.boolean().nullish(),
|
|
39
|
+
audio: z.boolean().nullish(),
|
|
40
|
+
referenceUrls: z.array(z.string()).nullish(),
|
|
41
|
+
pollIntervalMs: z.number().positive().nullish(),
|
|
42
|
+
pollTimeoutMs: z.number().positive().nullish(),
|
|
43
|
+
})
|
|
44
|
+
.passthrough(),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
@@ -9,62 +9,20 @@ import {
|
|
|
9
9
|
createJsonErrorResponseHandler,
|
|
10
10
|
createJsonResponseHandler,
|
|
11
11
|
delay,
|
|
12
|
-
type FetchFunction,
|
|
13
12
|
getFromApi,
|
|
14
|
-
lazySchema,
|
|
15
13
|
parseProviderOptions,
|
|
16
14
|
postJsonToApi,
|
|
17
|
-
type Resolvable,
|
|
18
15
|
resolve,
|
|
19
|
-
|
|
16
|
+
type FetchFunction,
|
|
17
|
+
type Resolvable,
|
|
20
18
|
} from '@ai-sdk/provider-utils';
|
|
21
19
|
import { z } from 'zod/v4';
|
|
20
|
+
import {
|
|
21
|
+
alibabaVideoModelOptionsSchema,
|
|
22
|
+
type AlibabaVideoModelOptions,
|
|
23
|
+
} from './alibaba-video-model-options';
|
|
22
24
|
import type { AlibabaVideoModelId } from './alibaba-video-settings';
|
|
23
25
|
|
|
24
|
-
export type AlibabaVideoModelOptions = {
|
|
25
|
-
/** Negative prompt to specify what to avoid (max 500 chars). */
|
|
26
|
-
negativePrompt?: string | null;
|
|
27
|
-
/** URL to audio file for audio-video sync (WAV/MP3, 3-30s, max 15MB). */
|
|
28
|
-
audioUrl?: string | null;
|
|
29
|
-
/** Enable prompt extension/rewriting for better generation. Defaults to true. */
|
|
30
|
-
promptExtend?: boolean | null;
|
|
31
|
-
/** Shot type: 'single' for single-shot or 'multi' for multi-shot narrative. */
|
|
32
|
-
shotType?: 'single' | 'multi' | null;
|
|
33
|
-
/** Whether to add watermark to generated video. Defaults to false. */
|
|
34
|
-
watermark?: boolean | null;
|
|
35
|
-
/** Enable audio generation (for I2V/R2V models). */
|
|
36
|
-
audio?: boolean | null;
|
|
37
|
-
/**
|
|
38
|
-
* Reference URLs for reference-to-video mode.
|
|
39
|
-
* Array of URLs to images (0-5) and/or videos (0-3), max 5 total.
|
|
40
|
-
* Use character identifiers (character1, character2) in prompts to reference them.
|
|
41
|
-
*/
|
|
42
|
-
referenceUrls?: string[] | null;
|
|
43
|
-
/** Polling interval in milliseconds. Defaults to 5000 (5 seconds). */
|
|
44
|
-
pollIntervalMs?: number | null;
|
|
45
|
-
/** Maximum wait time in milliseconds for video generation. Defaults to 600000 (10 minutes). */
|
|
46
|
-
pollTimeoutMs?: number | null;
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const alibabaVideoModelOptionsSchema = lazySchema(() =>
|
|
51
|
-
zodSchema(
|
|
52
|
-
z
|
|
53
|
-
.object({
|
|
54
|
-
negativePrompt: z.string().nullish(),
|
|
55
|
-
audioUrl: z.string().nullish(),
|
|
56
|
-
promptExtend: z.boolean().nullish(),
|
|
57
|
-
shotType: z.enum(['single', 'multi']).nullish(),
|
|
58
|
-
watermark: z.boolean().nullish(),
|
|
59
|
-
audio: z.boolean().nullish(),
|
|
60
|
-
referenceUrls: z.array(z.string()).nullish(),
|
|
61
|
-
pollIntervalMs: z.number().positive().nullish(),
|
|
62
|
-
pollTimeoutMs: z.number().positive().nullish(),
|
|
63
|
-
})
|
|
64
|
-
.passthrough(),
|
|
65
|
-
),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
26
|
interface AlibabaVideoModelConfig {
|
|
69
27
|
provider: string;
|
|
70
28
|
baseURL: string;
|
|
@@ -241,8 +199,9 @@ export class AlibabaVideoModel implements Experimental_VideoModelV4 {
|
|
|
241
199
|
if (alibabaOptions?.watermark != null) {
|
|
242
200
|
parameters.watermark = alibabaOptions.watermark;
|
|
243
201
|
}
|
|
244
|
-
|
|
245
|
-
|
|
202
|
+
const audio = options.generateAudio ?? alibabaOptions?.audio;
|
|
203
|
+
if (audio != null) {
|
|
204
|
+
parameters.audio = audio;
|
|
246
205
|
}
|
|
247
206
|
|
|
248
207
|
// Warn about unsupported standard options
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type LanguageModelV4DataContent,
|
|
3
|
-
type LanguageModelV4Prompt,
|
|
4
2
|
UnsupportedFunctionalityError,
|
|
3
|
+
type LanguageModelV4FilePart,
|
|
4
|
+
type LanguageModelV4Prompt,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
convertToBase64,
|
|
8
|
+
getTopLevelMediaType,
|
|
9
|
+
resolveFullMediaType,
|
|
10
|
+
} from '@ai-sdk/provider-utils';
|
|
7
11
|
import type { AlibabaChatPrompt } from './alibaba-chat-prompt';
|
|
8
12
|
import type { CacheControlValidator } from './get-cache-control';
|
|
9
13
|
|
|
10
|
-
function formatImageUrl({
|
|
11
|
-
data
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
function formatImageUrl({ part }: { part: LanguageModelV4FilePart }): string {
|
|
15
|
+
if (part.data.type === 'url') {
|
|
16
|
+
return part.data.url.toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (part.data.type === 'data') {
|
|
20
|
+
return `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
throw new UnsupportedFunctionalityError({
|
|
24
|
+
functionality: `file part data type ${part.data.type}`,
|
|
25
|
+
});
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export function convertToAlibabaChatMessages({
|
|
@@ -53,26 +59,13 @@ export function convertToAlibabaChatMessages({
|
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
case 'user': {
|
|
56
|
-
const isSinglePart = content.length === 1;
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
isSinglePart &&
|
|
60
|
-
content[0].type === 'text' &&
|
|
61
|
-
!messageCacheControl
|
|
62
|
-
) {
|
|
63
|
-
messages.push({
|
|
64
|
-
role: 'user',
|
|
65
|
-
content: content[0].text,
|
|
66
|
-
});
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
62
|
messages.push({
|
|
71
63
|
role: 'user',
|
|
72
|
-
content: content.map(part => {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
content: content.map((part, index) => {
|
|
65
|
+
const isLastPart = index === content.length - 1;
|
|
66
|
+
const partCacheControl =
|
|
67
|
+
cacheControlValidator?.getCacheControl(part.providerOptions) ??
|
|
68
|
+
(isLastPart ? messageCacheControl : undefined);
|
|
76
69
|
|
|
77
70
|
switch (part.type) {
|
|
78
71
|
case 'text': {
|
|
@@ -86,25 +79,35 @@ export function convertToAlibabaChatMessages({
|
|
|
86
79
|
}
|
|
87
80
|
|
|
88
81
|
case 'file': {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
82
|
+
switch (part.data.type) {
|
|
83
|
+
case 'reference': {
|
|
84
|
+
throw new UnsupportedFunctionalityError({
|
|
85
|
+
functionality: 'file parts with provider references',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
case 'text': {
|
|
89
|
+
throw new UnsupportedFunctionalityError({
|
|
90
|
+
functionality: 'text file parts',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
case 'url':
|
|
94
|
+
case 'data': {
|
|
95
|
+
if (getTopLevelMediaType(part.mediaType) === 'image') {
|
|
96
|
+
return {
|
|
97
|
+
type: 'image_url',
|
|
98
|
+
image_url: {
|
|
99
|
+
url: formatImageUrl({ part }),
|
|
100
|
+
},
|
|
101
|
+
...(partCacheControl
|
|
102
|
+
? { cache_control: partCacheControl }
|
|
103
|
+
: {}),
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
throw new UnsupportedFunctionalityError({
|
|
107
|
+
functionality: 'Only image file parts are supported',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -163,17 +166,15 @@ export function convertToAlibabaChatMessages({
|
|
|
163
166
|
r => r.type !== 'tool-approval-response',
|
|
164
167
|
);
|
|
165
168
|
|
|
166
|
-
const isSinglePart = toolResponses.length === 1;
|
|
167
|
-
|
|
168
169
|
for (let i = 0; i < toolResponses.length; i++) {
|
|
169
170
|
const toolResponse = toolResponses[i];
|
|
170
171
|
const output = toolResponse.output;
|
|
172
|
+
const isLastPart = i === toolResponses.length - 1;
|
|
171
173
|
|
|
172
|
-
const partCacheControl =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
);
|
|
174
|
+
const partCacheControl =
|
|
175
|
+
cacheControlValidator?.getCacheControl(
|
|
176
|
+
toolResponse.providerOptions,
|
|
177
|
+
) ?? (isLastPart ? messageCacheControl : undefined);
|
|
177
178
|
|
|
178
179
|
let contentValue: string;
|
|
179
180
|
switch (output.type) {
|
|
@@ -182,7 +183,7 @@ export function convertToAlibabaChatMessages({
|
|
|
182
183
|
contentValue = output.value;
|
|
183
184
|
break;
|
|
184
185
|
case 'execution-denied':
|
|
185
|
-
contentValue = output.reason ?? 'Tool execution denied.';
|
|
186
|
+
contentValue = output.reason ?? 'Tool call execution denied.';
|
|
186
187
|
break;
|
|
187
188
|
case 'content':
|
|
188
189
|
case 'json':
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
AlibabaChatModelId,
|
|
3
|
-
|
|
4
|
-
/** @deprecated Use `
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
AlibabaLanguageModelChatOptions,
|
|
4
|
+
/** @deprecated Use `AlibabaLanguageModelChatOptions` instead. */
|
|
5
|
+
AlibabaLanguageModelChatOptions as AlibabaLanguageModelOptions,
|
|
6
|
+
/** @deprecated Use `AlibabaLanguageModelChatOptions` instead. */
|
|
7
|
+
AlibabaLanguageModelChatOptions as AlibabaProviderOptions,
|
|
8
|
+
} from './alibaba-chat-language-model-options';
|
|
7
9
|
export type { AlibabaCacheControl } from './alibaba-chat-prompt';
|
|
10
|
+
export type {
|
|
11
|
+
AlibabaEmbeddingModelId,
|
|
12
|
+
AlibabaEmbeddingModelOptions,
|
|
13
|
+
} from './alibaba-embedding-model-options';
|
|
8
14
|
export {
|
|
9
15
|
type AlibabaProvider,
|
|
10
16
|
type AlibabaProviderSettings,
|
|
@@ -15,7 +21,7 @@ export type {
|
|
|
15
21
|
AlibabaVideoModelOptions,
|
|
16
22
|
/** @deprecated Use `AlibabaVideoModelOptions` instead. */
|
|
17
23
|
AlibabaVideoModelOptions as AlibabaVideoProviderOptions,
|
|
18
|
-
} from './alibaba-video-model';
|
|
24
|
+
} from './alibaba-video-model-options';
|
|
19
25
|
export type { AlibabaVideoModelId } from './alibaba-video-settings';
|
|
20
26
|
export type { AlibabaUsage } from './convert-alibaba-usage';
|
|
21
27
|
export { VERSION } from './version';
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const VERSION =
|
|
1
|
+
// Version string of this package injected at build time.
|
|
2
|
+
declare const __PACKAGE_VERSION__: string | undefined;
|
|
3
|
+
export const VERSION: string =
|
|
4
|
+
typeof __PACKAGE_VERSION__ !== 'undefined'
|
|
5
|
+
? __PACKAGE_VERSION__
|
|
6
|
+
: '0.0.0-test';
|
package/dist/index.d.mts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { ProviderV4, LanguageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
4
|
-
|
|
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
|
-
declare const alibabaLanguageModelOptions: z.ZodObject<{
|
|
7
|
-
enableThinking: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
thinkingBudget: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
type AlibabaLanguageModelOptions = z.infer<typeof alibabaLanguageModelOptions>;
|
|
12
|
-
|
|
13
|
-
type AlibabaCacheControl = {
|
|
14
|
-
type: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | (string & {});
|
|
18
|
-
|
|
19
|
-
interface AlibabaProvider extends ProviderV4 {
|
|
20
|
-
(modelId: AlibabaChatModelId): LanguageModelV4;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a model for text generation.
|
|
23
|
-
*/
|
|
24
|
-
languageModel(modelId: AlibabaChatModelId): LanguageModelV4;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a chat model for text generation.
|
|
27
|
-
*/
|
|
28
|
-
chatModel(modelId: AlibabaChatModelId): LanguageModelV4;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a model for video generation.
|
|
31
|
-
*/
|
|
32
|
-
video(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a model for video generation.
|
|
35
|
-
*/
|
|
36
|
-
videoModel(modelId: AlibabaVideoModelId): Experimental_VideoModelV4;
|
|
37
|
-
}
|
|
38
|
-
interface AlibabaProviderSettings {
|
|
39
|
-
/**
|
|
40
|
-
* Use a different URL prefix for API calls, e.g. to use proxy servers or regional endpoints.
|
|
41
|
-
* The default prefix is `https://dashscope-intl.aliyuncs.com/compatible-mode/v1`.
|
|
42
|
-
*/
|
|
43
|
-
baseURL?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Use a different URL prefix for video generation API calls.
|
|
46
|
-
* The video API uses the DashScope native endpoint (not the OpenAI-compatible endpoint).
|
|
47
|
-
* The default prefix is `https://dashscope-intl.aliyuncs.com`.
|
|
48
|
-
*/
|
|
49
|
-
videoBaseURL?: string;
|
|
50
|
-
/**
|
|
51
|
-
* API key that is being sent using the `Authorization` header.
|
|
52
|
-
* It defaults to the `ALIBABA_API_KEY` environment variable.
|
|
53
|
-
*/
|
|
54
|
-
apiKey?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Custom headers to include in the requests.
|
|
57
|
-
*/
|
|
58
|
-
headers?: Record<string, string>;
|
|
59
|
-
/**
|
|
60
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
61
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
62
|
-
*/
|
|
63
|
-
fetch?: FetchFunction;
|
|
64
|
-
/**
|
|
65
|
-
* Include usage information in streaming responses.
|
|
66
|
-
* When enabled, token usage will be included in the final chunk.
|
|
67
|
-
*
|
|
68
|
-
* @default true
|
|
69
|
-
*/
|
|
70
|
-
includeUsage?: boolean;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Create an Alibaba Cloud (Qwen) provider instance.
|
|
74
|
-
*/
|
|
75
|
-
declare function createAlibaba(options?: AlibabaProviderSettings): AlibabaProvider;
|
|
76
|
-
declare const alibaba: AlibabaProvider;
|
|
77
|
-
|
|
78
|
-
type AlibabaVideoModelOptions = {
|
|
79
|
-
/** Negative prompt to specify what to avoid (max 500 chars). */
|
|
80
|
-
negativePrompt?: string | null;
|
|
81
|
-
/** URL to audio file for audio-video sync (WAV/MP3, 3-30s, max 15MB). */
|
|
82
|
-
audioUrl?: string | null;
|
|
83
|
-
/** Enable prompt extension/rewriting for better generation. Defaults to true. */
|
|
84
|
-
promptExtend?: boolean | null;
|
|
85
|
-
/** Shot type: 'single' for single-shot or 'multi' for multi-shot narrative. */
|
|
86
|
-
shotType?: 'single' | 'multi' | null;
|
|
87
|
-
/** Whether to add watermark to generated video. Defaults to false. */
|
|
88
|
-
watermark?: boolean | null;
|
|
89
|
-
/** Enable audio generation (for I2V/R2V models). */
|
|
90
|
-
audio?: boolean | null;
|
|
91
|
-
/**
|
|
92
|
-
* Reference URLs for reference-to-video mode.
|
|
93
|
-
* Array of URLs to images (0-5) and/or videos (0-3), max 5 total.
|
|
94
|
-
* Use character identifiers (character1, character2) in prompts to reference them.
|
|
95
|
-
*/
|
|
96
|
-
referenceUrls?: string[] | null;
|
|
97
|
-
/** Polling interval in milliseconds. Defaults to 5000 (5 seconds). */
|
|
98
|
-
pollIntervalMs?: number | null;
|
|
99
|
-
/** Maximum wait time in milliseconds for video generation. Defaults to 600000 (10 minutes). */
|
|
100
|
-
pollTimeoutMs?: number | null;
|
|
101
|
-
[key: string]: unknown;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
type AlibabaUsage = {
|
|
105
|
-
prompt_tokens?: number | null;
|
|
106
|
-
completion_tokens?: number | null;
|
|
107
|
-
total_tokens?: number | null;
|
|
108
|
-
prompt_tokens_details?: {
|
|
109
|
-
cached_tokens?: number | null;
|
|
110
|
-
cache_creation_input_tokens?: number | null;
|
|
111
|
-
} | null;
|
|
112
|
-
completion_tokens_details?: {
|
|
113
|
-
reasoning_tokens?: number | null;
|
|
114
|
-
} | null;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
declare const VERSION: string;
|
|
118
|
-
|
|
119
|
-
export { type AlibabaCacheControl, type AlibabaChatModelId, type AlibabaLanguageModelOptions, type AlibabaProvider, type AlibabaLanguageModelOptions as AlibabaProviderOptions, type AlibabaProviderSettings, type AlibabaUsage, type AlibabaVideoModelId, type AlibabaVideoModelOptions, type AlibabaVideoModelOptions as AlibabaVideoProviderOptions, VERSION, alibaba, createAlibaba };
|