@ai-sdk/alibaba 2.0.72 → 2.0.73
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 +10 -0
- package/dist/index.d.ts +14 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/alibaba-chat-language-model-options.ts +38 -29
- package/src/alibaba-chat-language-model.ts +88 -76
- package/src/alibaba-embedding-model-options.ts +30 -21
- package/src/alibaba-embedding-model.ts +29 -22
- package/src/alibaba-error.ts +18 -9
- package/src/alibaba-video-model.ts +63 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ai-sdk/alibaba
|
|
2
2
|
|
|
3
|
+
## 2.0.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 39a776b: Add a shared encodePathSegment helper and use it to encode provider-returned identifiers in credentialed follow-up request paths.
|
|
8
|
+
- debdc6a: Defer construction of provider validation schemas until first use to reduce package import time.
|
|
9
|
+
- Updated dependencies [b089ce8]
|
|
10
|
+
- Updated dependencies [39a776b]
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.65
|
|
12
|
+
|
|
3
13
|
## 2.0.72
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { EmbeddingModelV4, Experimental_VideoModelV4, LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
|
|
2
|
-
import { FetchFunction } from "@ai-sdk/provider-utils";
|
|
3
|
-
import { z } from "zod/v4";
|
|
2
|
+
import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
|
|
4
3
|
//#region src/alibaba-chat-language-model-options.d.ts
|
|
5
4
|
type AlibabaChatModelId = 'qwen3.7-max' | '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 alibabaLanguageModelChatOptions:
|
|
7
|
-
enableThinking
|
|
8
|
-
thinkingBudget
|
|
9
|
-
preserveThinking
|
|
10
|
-
parallelToolCalls
|
|
11
|
-
}
|
|
12
|
-
type AlibabaLanguageModelChatOptions =
|
|
5
|
+
declare const alibabaLanguageModelChatOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
6
|
+
enableThinking?: boolean | undefined;
|
|
7
|
+
thinkingBudget?: number | undefined;
|
|
8
|
+
preserveThinking?: boolean | undefined;
|
|
9
|
+
parallelToolCalls?: boolean | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
type AlibabaLanguageModelChatOptions = InferSchema<typeof alibabaLanguageModelChatOptions>;
|
|
13
12
|
//#endregion
|
|
14
13
|
//#region src/alibaba-chat-prompt.d.ts
|
|
15
14
|
type AlibabaCacheControl = {
|
|
@@ -18,19 +17,12 @@ type AlibabaCacheControl = {
|
|
|
18
17
|
//#endregion
|
|
19
18
|
//#region src/alibaba-embedding-model-options.d.ts
|
|
20
19
|
type AlibabaEmbeddingModelId = 'text-embedding-v4' | 'text-embedding-v3' | (string & {});
|
|
21
|
-
declare const alibabaEmbeddingModelOptions:
|
|
22
|
-
textType
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
outputType: z.ZodOptional<z.ZodEnum<{
|
|
28
|
-
dense: "dense";
|
|
29
|
-
sparse: "sparse";
|
|
30
|
-
"dense&sparse": "dense&sparse";
|
|
31
|
-
}>>;
|
|
32
|
-
}, z.core.$strip>;
|
|
33
|
-
type AlibabaEmbeddingModelOptions = z.infer<typeof alibabaEmbeddingModelOptions>;
|
|
20
|
+
declare const alibabaEmbeddingModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
21
|
+
textType?: "query" | "document" | undefined;
|
|
22
|
+
dimension?: number | undefined;
|
|
23
|
+
outputType?: "dense" | "sparse" | "dense&sparse" | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
type AlibabaEmbeddingModelOptions = InferSchema<typeof alibabaEmbeddingModelOptions>;
|
|
34
26
|
//#endregion
|
|
35
27
|
//#region src/alibaba-video-settings.d.ts
|
|
36
28
|
type AlibabaVideoModelId = 'wan2.6-t2v' | 'wan2.5-t2v-preview' | 'wan2.7-t2v' | 'wan2.7-t2v-2026-06-12' | 'wan2.6-i2v' | 'wan2.6-i2v-flash' | 'wan2.6-r2v' | 'wan2.6-r2v-flash' | 'wan2.7-r2v' | 'wan2.7-r2v-2026-06-12' | 'wan3.0-video' | (string & {});
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/alibaba-chat-language-model-options.ts","../src/alibaba-chat-prompt.ts","../src/alibaba-embedding-model-options.ts","../src/alibaba-video-settings.ts","../src/alibaba-provider.ts","../src/alibaba-video-model-options.ts","../src/convert-alibaba-usage.ts","../src/version.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/alibaba-chat-language-model-options.ts","../src/alibaba-chat-prompt.ts","../src/alibaba-embedding-model-options.ts","../src/alibaba-video-settings.ts","../src/alibaba-provider.ts","../src/alibaba-video-model-options.ts","../src/convert-alibaba-usage.ts","../src/version.ts"],"mappings":";;;KAQY;cA4BC,kEAA+B;;;;;;KAoChC,kCAAkC,mBACrC;;;KCzEG;EAAwB;;;;KCOxB;cAKC,+DAA4B;;;;;KA2B7B,+BAA+B,mBAClC;;;KCvCG;;;UCuBK,wBAAwB;GACtC,SAAS,qBAAqB;;;;EAK/B,cAAc,SAAS,qBAAqB;;;;EAK5C,UAAU,SAAS,qBAAqB;;;;EAKxC,UAAU,SAAS,0BAA0B;;;;EAK7C,eAAe,SAAS,0BAA0B;;;;EAKlD,MAAM,SAAS,sBAAsB;;;;EAKrC,WAAW,SAAS,sBAAsB;;UAG3B;;;;;EAKf;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;;;;;;EAQR;;;;;wBAMc,cACd,UAAS,0BACR;qBA4EU,SAAO;;;KCvLR;;EAEV;;EAEA;;EAEA;;;;;EAKA;;EAEA;;;;;EAKA;;;;;;EAMA;;;;;;;;;;;EAWA,QAAQ;IACN;;IASA;;IAEA;;;;;;EAMF;;EAEA;;EAEA;GACC;;;;;;;;;;;;;KCjDS;EACV;EACA;EACA;EACA;IACE;IACA;;;;;;;;IAQA;;EAEF;IACE;;;;;qBC3BS"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AISDKError, NoSuchModelError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
2
|
-
import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertImageModelFileToDataUri, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, generateId, getFromApi, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderBudget, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertImageModelFileToDataUri, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, encodePathSegment, generateId, getFromApi, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderBudget, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/alibaba-chat-language-model-options.ts
|
|
5
|
-
const alibabaLanguageModelChatOptions = z.object({
|
|
5
|
+
const alibabaLanguageModelChatOptions = lazySchema(() => zodSchema(z.object({
|
|
6
6
|
/**
|
|
7
7
|
* Enable thinking/reasoning mode for supported models.
|
|
8
8
|
* When enabled, the model generates reasoning content before the response.
|
|
@@ -29,14 +29,14 @@ const alibabaLanguageModelChatOptions = z.object({
|
|
|
29
29
|
* @default true
|
|
30
30
|
*/
|
|
31
31
|
parallelToolCalls: z.boolean().optional()
|
|
32
|
-
});
|
|
32
|
+
})));
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/alibaba-error.ts
|
|
35
|
-
const alibabaErrorDataSchema = z.object({ error: z.object({
|
|
35
|
+
const alibabaErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
|
|
36
36
|
message: z.string(),
|
|
37
37
|
code: z.string().nullish(),
|
|
38
38
|
type: z.string().nullish()
|
|
39
|
-
}) });
|
|
39
|
+
}) })));
|
|
40
40
|
const alibabaFailedResponseHandler = createJsonErrorResponseHandler({
|
|
41
41
|
errorSchema: alibabaErrorDataSchema,
|
|
42
42
|
errorToMessage: (data) => data.error.message
|
|
@@ -638,7 +638,7 @@ function resolveAlibabaThinking({ reasoning, alibabaOptions, warnings }) {
|
|
|
638
638
|
* Reference for schemas below:
|
|
639
639
|
* https://www.alibabacloud.com/help/en/model-studio/qwen-api-via-openai-chat-completions
|
|
640
640
|
*/
|
|
641
|
-
const alibabaUsageSchema = z.looseObject({
|
|
641
|
+
const alibabaUsageSchema = () => z.looseObject({
|
|
642
642
|
prompt_tokens: z.number(),
|
|
643
643
|
completion_tokens: z.number(),
|
|
644
644
|
total_tokens: z.number(),
|
|
@@ -649,7 +649,7 @@ const alibabaUsageSchema = z.looseObject({
|
|
|
649
649
|
}).nullish(),
|
|
650
650
|
completion_tokens_details: z.looseObject({ reasoning_tokens: z.number().nullish() }).nullish()
|
|
651
651
|
});
|
|
652
|
-
const alibabaChatResponseSchema = z.object({
|
|
652
|
+
const alibabaChatResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
653
653
|
id: z.string().nullish(),
|
|
654
654
|
created: z.number().nullish(),
|
|
655
655
|
model: z.string().nullish(),
|
|
@@ -670,9 +670,9 @@ const alibabaChatResponseSchema = z.object({
|
|
|
670
670
|
finish_reason: z.string().nullish(),
|
|
671
671
|
index: z.number()
|
|
672
672
|
})),
|
|
673
|
-
usage: alibabaUsageSchema.nullish()
|
|
674
|
-
});
|
|
675
|
-
const alibabaChatChunkSchema = z.object({
|
|
673
|
+
usage: alibabaUsageSchema().nullish()
|
|
674
|
+
})));
|
|
675
|
+
const alibabaChatChunkSchema = lazySchema(() => zodSchema(z.object({
|
|
676
676
|
id: z.string().nullish(),
|
|
677
677
|
created: z.number().nullish(),
|
|
678
678
|
model: z.string().nullish(),
|
|
@@ -694,11 +694,11 @@ const alibabaChatChunkSchema = z.object({
|
|
|
694
694
|
finish_reason: z.string().nullish(),
|
|
695
695
|
index: z.number()
|
|
696
696
|
})),
|
|
697
|
-
usage: alibabaUsageSchema.nullish()
|
|
698
|
-
});
|
|
697
|
+
usage: alibabaUsageSchema().nullish()
|
|
698
|
+
})));
|
|
699
699
|
//#endregion
|
|
700
700
|
//#region src/alibaba-embedding-model-options.ts
|
|
701
|
-
const alibabaEmbeddingModelOptions = z.object({
|
|
701
|
+
const alibabaEmbeddingModelOptions = lazySchema(() => zodSchema(z.object({
|
|
702
702
|
/**
|
|
703
703
|
* Differentiates query text from document text for asymmetric retrieval tasks.
|
|
704
704
|
* Defaults to `document`.
|
|
@@ -721,7 +721,7 @@ const alibabaEmbeddingModelOptions = z.object({
|
|
|
721
721
|
"sparse",
|
|
722
722
|
"dense&sparse"
|
|
723
723
|
]).optional()
|
|
724
|
-
});
|
|
724
|
+
})));
|
|
725
725
|
//#endregion
|
|
726
726
|
//#region src/alibaba-embedding-model.ts
|
|
727
727
|
const alibabaEmbeddingFailedResponseHandler = createJsonErrorResponseHandler({
|
|
@@ -802,19 +802,19 @@ var AlibabaEmbeddingModel = class AlibabaEmbeddingModel {
|
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
804
|
};
|
|
805
|
-
const alibabaTextEmbeddingSparseEmbeddingSchema = z.object({
|
|
805
|
+
const alibabaTextEmbeddingSparseEmbeddingSchema = () => z.object({
|
|
806
806
|
index: z.number(),
|
|
807
807
|
value: z.number(),
|
|
808
808
|
token: z.string().nullish()
|
|
809
809
|
});
|
|
810
|
-
const alibabaTextEmbeddingResponseSchema = z.object({
|
|
810
|
+
const alibabaTextEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
811
811
|
output: z.object({ embeddings: z.array(z.object({
|
|
812
812
|
embedding: z.array(z.number()),
|
|
813
813
|
text_index: z.number(),
|
|
814
|
-
sparse_embedding: z.array(alibabaTextEmbeddingSparseEmbeddingSchema).nullish()
|
|
814
|
+
sparse_embedding: z.array(alibabaTextEmbeddingSparseEmbeddingSchema()).nullish()
|
|
815
815
|
})) }),
|
|
816
816
|
usage: z.object({ total_tokens: z.number() }).nullish()
|
|
817
|
-
});
|
|
817
|
+
})));
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region src/alibaba-video-model-options.ts
|
|
820
820
|
const alibabaVideoModelOptionsSchema = lazySchema(() => zodSchema(z.looseObject({
|
|
@@ -851,23 +851,23 @@ const alibabaVideoModelOptionsSchema = lazySchema(() => zodSchema(z.looseObject(
|
|
|
851
851
|
})));
|
|
852
852
|
//#endregion
|
|
853
853
|
//#region src/alibaba-video-model.ts
|
|
854
|
-
const alibabaVideoErrorSchema = z.object({
|
|
854
|
+
const alibabaVideoErrorSchema = lazySchema(() => zodSchema(z.object({
|
|
855
855
|
code: z.string().nullish(),
|
|
856
856
|
message: z.string(),
|
|
857
857
|
request_id: z.string().nullish()
|
|
858
|
-
});
|
|
858
|
+
})));
|
|
859
859
|
const alibabaVideoFailedResponseHandler = createJsonErrorResponseHandler({
|
|
860
860
|
errorSchema: alibabaVideoErrorSchema,
|
|
861
861
|
errorToMessage: (data) => data.message
|
|
862
862
|
});
|
|
863
|
-
const alibabaVideoCreateTaskSchema = z.object({
|
|
863
|
+
const alibabaVideoCreateTaskSchema = lazySchema(() => zodSchema(z.object({
|
|
864
864
|
output: z.object({
|
|
865
865
|
task_status: z.string(),
|
|
866
866
|
task_id: z.string()
|
|
867
867
|
}).nullish(),
|
|
868
868
|
request_id: z.string().nullish()
|
|
869
|
-
});
|
|
870
|
-
const alibabaVideoTaskStatusSchema = z.object({
|
|
869
|
+
})));
|
|
870
|
+
const alibabaVideoTaskStatusSchema = lazySchema(() => zodSchema(z.object({
|
|
871
871
|
output: z.object({
|
|
872
872
|
task_id: z.string(),
|
|
873
873
|
task_status: z.string(),
|
|
@@ -890,7 +890,7 @@ const alibabaVideoTaskStatusSchema = z.object({
|
|
|
890
890
|
ratio: z.string().nullish()
|
|
891
891
|
}).nullish(),
|
|
892
892
|
request_id: z.string().nullish()
|
|
893
|
-
});
|
|
893
|
+
})));
|
|
894
894
|
function detectMode(modelId) {
|
|
895
895
|
if (modelId.includes("-i2v")) return "i2v";
|
|
896
896
|
if (modelId.includes("-r2v")) return "r2v";
|
|
@@ -1186,7 +1186,7 @@ var AlibabaVideoModel = class {
|
|
|
1186
1186
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
1187
1187
|
const { taskId } = options.operation;
|
|
1188
1188
|
const { value: statusResponse, responseHeaders } = await getFromApi({
|
|
1189
|
-
url: `${this.config.baseURL}/api/v1/tasks/${taskId}`,
|
|
1189
|
+
url: `${this.config.baseURL}/api/v1/tasks/${encodePathSegment(taskId)}`,
|
|
1190
1190
|
validateUrl: false,
|
|
1191
1191
|
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1192
1192
|
successfulResponseHandler: createJsonResponseHandler(alibabaVideoTaskStatusSchema),
|
|
@@ -1217,7 +1217,7 @@ var AlibabaVideoModel = class {
|
|
|
1217
1217
|
};
|
|
1218
1218
|
//#endregion
|
|
1219
1219
|
//#region src/version.ts
|
|
1220
|
-
const VERSION = "2.0.
|
|
1220
|
+
const VERSION = "2.0.73";
|
|
1221
1221
|
//#endregion
|
|
1222
1222
|
//#region src/alibaba-provider.ts
|
|
1223
1223
|
/**
|