@ai-sdk/zai 0.0.0 → 1.0.2
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 +29 -0
- package/LICENSE +13 -0
- package/README.md +45 -3
- package/dist/index.d.mts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +311 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +290 -0
- package/dist/index.mjs.map +1 -0
- package/docs/200-zai.mdx +159 -0
- package/package.json +66 -11
- package/src/index.ts +6 -0
- package/src/version.ts +6 -0
- package/src/zai-chat-language-model-options.ts +45 -0
- package/src/zai-chat-language-model.ts +252 -0
- package/src/zai-chat-options.ts +28 -0
- package/src/zai-error.ts +19 -0
- package/src/zai-provider.ts +103 -0
- package/index.js +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @ai-sdk/zai
|
|
2
|
+
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [26165ee]
|
|
8
|
+
- @ai-sdk/provider-utils@3.0.36
|
|
9
|
+
- @ai-sdk/openai-compatible@1.0.53
|
|
10
|
+
|
|
11
|
+
## 1.0.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [77d33c0]
|
|
16
|
+
- @ai-sdk/provider-utils@3.0.35
|
|
17
|
+
- @ai-sdk/openai-compatible@1.0.52
|
|
18
|
+
|
|
19
|
+
## 1.0.0
|
|
20
|
+
|
|
21
|
+
### Major Changes
|
|
22
|
+
|
|
23
|
+
- 326a47b: feat(zai): add the Z.AI provider with GLM chat completions, streaming, reasoning, tools, and multimodal inputs
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 326a47b: Backport: Add GLM-5.3-Flash model support to the Z.AI provider and AI Gateway.
|
|
28
|
+
- Updated dependencies [e264a35]
|
|
29
|
+
- @ai-sdk/openai-compatible@1.0.51
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AI SDK - Z.AI Provider
|
|
2
2
|
|
|
3
|
-
AI SDK
|
|
3
|
+
The **Z.AI provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Z.AI](https://z.ai/) GLM models.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Z.AI (and hundreds of models from other providers) without installing an additional provider package. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Install the Z.AI provider with:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @ai-sdk/zai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Provider Instance
|
|
16
|
+
|
|
17
|
+
Import the default provider instance from `@ai-sdk/zai`:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { zai } from '@ai-sdk/zai';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The provider reads the API key from `ZAI_API_KEY` by default. To configure it explicitly, use `createZai`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createZai } from '@ai-sdk/zai';
|
|
27
|
+
|
|
28
|
+
const zai = createZai({
|
|
29
|
+
apiKey: process.env.ZAI_API_KEY,
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Language Models
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { zai } from '@ai-sdk/zai';
|
|
37
|
+
import { generateText } from 'ai';
|
|
38
|
+
|
|
39
|
+
const { text } = await generateText({
|
|
40
|
+
model: zai('glm-5.3'),
|
|
41
|
+
prompt: 'Explain why the sky is blue.',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
console.log(text);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The provider supports streaming, reasoning, function tools, JSON object output, and URL-based image and video input on compatible GLM models.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
|
|
5
|
+
declare const zaiLanguageModelChatOptions: z.ZodObject<{
|
|
6
|
+
doSample: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
enabled: "enabled";
|
|
10
|
+
disabled: "disabled";
|
|
11
|
+
}>>;
|
|
12
|
+
clearThinking: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
none: "none";
|
|
16
|
+
minimal: "minimal";
|
|
17
|
+
low: "low";
|
|
18
|
+
medium: "medium";
|
|
19
|
+
high: "high";
|
|
20
|
+
xhigh: "xhigh";
|
|
21
|
+
max: "max";
|
|
22
|
+
}>>;
|
|
23
|
+
toolStream: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type ZaiLanguageModelChatOptions = z.infer<typeof zaiLanguageModelChatOptions>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Z.AI chat model ids from the official OpenAPI 1.0.0 specification,
|
|
31
|
+
* retrieved from https://docs.z.ai/openapi.json on 2026-08-26.
|
|
32
|
+
*/
|
|
33
|
+
type ZaiChatModelId = 'glm-5.3' | 'glm-5.2' | 'glm-5.1' | 'glm-5-turbo' | 'glm-5' | 'glm-4.7' | 'glm-4.7-flash' | 'glm-4.7-flashx' | 'glm-4.6' | 'glm-4.5' | 'glm-4.5-air' | 'glm-4.5-x' | 'glm-4.5-airx' | 'glm-4.5-flash' | 'glm-4-32b-0414-128k' | 'glm-5.3-flash' | 'glm-5v-turbo' | 'glm-4.6v' | 'glm-4.6v-flash' | 'glm-4.6v-flashx' | 'glm-4.5v' | 'autoglm-phone-multilingual' | (string & {});
|
|
34
|
+
|
|
35
|
+
declare const zaiErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
37
|
+
message: z.ZodString;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
error: z.ZodObject<{
|
|
40
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
}, z.core.$strip>]>;
|
|
44
|
+
type ZaiErrorData = z.infer<typeof zaiErrorSchema>;
|
|
45
|
+
|
|
46
|
+
interface ZaiProviderSettings {
|
|
47
|
+
/**
|
|
48
|
+
* Z.AI API key. Defaults to the `ZAI_API_KEY` environment variable.
|
|
49
|
+
*/
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Base URL for API calls. Defaults to
|
|
53
|
+
* `https://api.z.ai/api/paas/v4`.
|
|
54
|
+
*/
|
|
55
|
+
baseURL?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom headers to include in requests.
|
|
58
|
+
*/
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Custom fetch implementation.
|
|
62
|
+
*/
|
|
63
|
+
fetch?: FetchFunction;
|
|
64
|
+
}
|
|
65
|
+
interface ZaiProvider extends ProviderV2 {
|
|
66
|
+
/**
|
|
67
|
+
* Creates a Z.AI chat model for text generation.
|
|
68
|
+
*/
|
|
69
|
+
(modelId: ZaiChatModelId): LanguageModelV2;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a Z.AI language model.
|
|
72
|
+
*/
|
|
73
|
+
languageModel(modelId: ZaiChatModelId): LanguageModelV2;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a Z.AI chat model.
|
|
76
|
+
*/
|
|
77
|
+
chatModel(modelId: ZaiChatModelId): LanguageModelV2;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a Z.AI chat model.
|
|
80
|
+
*/
|
|
81
|
+
chat(modelId: ZaiChatModelId): LanguageModelV2;
|
|
82
|
+
}
|
|
83
|
+
declare function createZai(options?: ZaiProviderSettings): ZaiProvider;
|
|
84
|
+
declare const zai: ZaiProvider;
|
|
85
|
+
|
|
86
|
+
declare const VERSION: string;
|
|
87
|
+
|
|
88
|
+
export { VERSION, type ZaiChatModelId, type ZaiErrorData, type ZaiLanguageModelChatOptions, type ZaiProvider, type ZaiProviderSettings, createZai, zai };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
|
|
5
|
+
declare const zaiLanguageModelChatOptions: z.ZodObject<{
|
|
6
|
+
doSample: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
enabled: "enabled";
|
|
10
|
+
disabled: "disabled";
|
|
11
|
+
}>>;
|
|
12
|
+
clearThinking: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
none: "none";
|
|
16
|
+
minimal: "minimal";
|
|
17
|
+
low: "low";
|
|
18
|
+
medium: "medium";
|
|
19
|
+
high: "high";
|
|
20
|
+
xhigh: "xhigh";
|
|
21
|
+
max: "max";
|
|
22
|
+
}>>;
|
|
23
|
+
toolStream: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type ZaiLanguageModelChatOptions = z.infer<typeof zaiLanguageModelChatOptions>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Z.AI chat model ids from the official OpenAPI 1.0.0 specification,
|
|
31
|
+
* retrieved from https://docs.z.ai/openapi.json on 2026-08-26.
|
|
32
|
+
*/
|
|
33
|
+
type ZaiChatModelId = 'glm-5.3' | 'glm-5.2' | 'glm-5.1' | 'glm-5-turbo' | 'glm-5' | 'glm-4.7' | 'glm-4.7-flash' | 'glm-4.7-flashx' | 'glm-4.6' | 'glm-4.5' | 'glm-4.5-air' | 'glm-4.5-x' | 'glm-4.5-airx' | 'glm-4.5-flash' | 'glm-4-32b-0414-128k' | 'glm-5.3-flash' | 'glm-5v-turbo' | 'glm-4.6v' | 'glm-4.6v-flash' | 'glm-4.6v-flashx' | 'glm-4.5v' | 'autoglm-phone-multilingual' | (string & {});
|
|
34
|
+
|
|
35
|
+
declare const zaiErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
37
|
+
message: z.ZodString;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
error: z.ZodObject<{
|
|
40
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
}, z.core.$strip>]>;
|
|
44
|
+
type ZaiErrorData = z.infer<typeof zaiErrorSchema>;
|
|
45
|
+
|
|
46
|
+
interface ZaiProviderSettings {
|
|
47
|
+
/**
|
|
48
|
+
* Z.AI API key. Defaults to the `ZAI_API_KEY` environment variable.
|
|
49
|
+
*/
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Base URL for API calls. Defaults to
|
|
53
|
+
* `https://api.z.ai/api/paas/v4`.
|
|
54
|
+
*/
|
|
55
|
+
baseURL?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom headers to include in requests.
|
|
58
|
+
*/
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Custom fetch implementation.
|
|
62
|
+
*/
|
|
63
|
+
fetch?: FetchFunction;
|
|
64
|
+
}
|
|
65
|
+
interface ZaiProvider extends ProviderV2 {
|
|
66
|
+
/**
|
|
67
|
+
* Creates a Z.AI chat model for text generation.
|
|
68
|
+
*/
|
|
69
|
+
(modelId: ZaiChatModelId): LanguageModelV2;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a Z.AI language model.
|
|
72
|
+
*/
|
|
73
|
+
languageModel(modelId: ZaiChatModelId): LanguageModelV2;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a Z.AI chat model.
|
|
76
|
+
*/
|
|
77
|
+
chatModel(modelId: ZaiChatModelId): LanguageModelV2;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a Z.AI chat model.
|
|
80
|
+
*/
|
|
81
|
+
chat(modelId: ZaiChatModelId): LanguageModelV2;
|
|
82
|
+
}
|
|
83
|
+
declare function createZai(options?: ZaiProviderSettings): ZaiProvider;
|
|
84
|
+
declare const zai: ZaiProvider;
|
|
85
|
+
|
|
86
|
+
declare const VERSION: string;
|
|
87
|
+
|
|
88
|
+
export { VERSION, type ZaiChatModelId, type ZaiErrorData, type ZaiLanguageModelChatOptions, type ZaiProvider, type ZaiProviderSettings, createZai, zai };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
24
|
+
createZai: () => createZai,
|
|
25
|
+
zai: () => zai
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/zai-provider.ts
|
|
30
|
+
var import_provider = require("@ai-sdk/provider");
|
|
31
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
32
|
+
|
|
33
|
+
// src/version.ts
|
|
34
|
+
var VERSION = true ? "1.0.2" : "0.0.0-test";
|
|
35
|
+
|
|
36
|
+
// src/zai-chat-language-model.ts
|
|
37
|
+
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
38
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
39
|
+
|
|
40
|
+
// src/zai-chat-language-model-options.ts
|
|
41
|
+
var import_v4 = require("zod/v4");
|
|
42
|
+
var zaiLanguageModelChatOptions = import_v4.z.object({
|
|
43
|
+
/**
|
|
44
|
+
* Enables or disables sampling. When disabled, temperature and topP do not
|
|
45
|
+
* take effect.
|
|
46
|
+
*/
|
|
47
|
+
doSample: import_v4.z.boolean().optional(),
|
|
48
|
+
/**
|
|
49
|
+
* Controls model thinking and whether reasoning from earlier turns is kept.
|
|
50
|
+
*/
|
|
51
|
+
thinking: import_v4.z.object({
|
|
52
|
+
type: import_v4.z.enum(["enabled", "disabled"]).optional(),
|
|
53
|
+
clearThinking: import_v4.z.boolean().optional()
|
|
54
|
+
}).optional(),
|
|
55
|
+
/**
|
|
56
|
+
* Controls reasoning effort for GLM-5.2 and later models.
|
|
57
|
+
*/
|
|
58
|
+
reasoningEffort: import_v4.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
59
|
+
/**
|
|
60
|
+
* Enables incremental function-call argument streaming on supported models.
|
|
61
|
+
*/
|
|
62
|
+
toolStream: import_v4.z.boolean().optional(),
|
|
63
|
+
/**
|
|
64
|
+
* A caller-provided request identifier between 6 and 64 characters.
|
|
65
|
+
*/
|
|
66
|
+
requestId: import_v4.z.string().min(6).max(64).optional(),
|
|
67
|
+
/**
|
|
68
|
+
* A non-sensitive end-user identifier between 6 and 128 characters.
|
|
69
|
+
*/
|
|
70
|
+
userId: import_v4.z.string().min(6).max(128).optional()
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/zai-error.ts
|
|
74
|
+
var import_v42 = require("zod/v4");
|
|
75
|
+
var zaiErrorDetailsSchema = import_v42.z.object({
|
|
76
|
+
code: import_v42.z.union([import_v42.z.number(), import_v42.z.string()]).nullish(),
|
|
77
|
+
message: import_v42.z.string()
|
|
78
|
+
});
|
|
79
|
+
var zaiErrorSchema = import_v42.z.union([
|
|
80
|
+
zaiErrorDetailsSchema,
|
|
81
|
+
import_v42.z.object({ error: zaiErrorDetailsSchema })
|
|
82
|
+
]);
|
|
83
|
+
var zaiErrorStructure = {
|
|
84
|
+
errorSchema: zaiErrorSchema,
|
|
85
|
+
errorToMessage: (data) => "error" in data ? data.error.message : data.message
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/zai-chat-language-model.ts
|
|
89
|
+
function transformZaiRequestBody(args) {
|
|
90
|
+
const {
|
|
91
|
+
doSample,
|
|
92
|
+
frequency_penalty: _frequencyPenalty,
|
|
93
|
+
presence_penalty: _presencePenalty,
|
|
94
|
+
requestId,
|
|
95
|
+
seed: _seed,
|
|
96
|
+
thinking,
|
|
97
|
+
toolStream,
|
|
98
|
+
user: _user,
|
|
99
|
+
userId,
|
|
100
|
+
verbosity: _verbosity,
|
|
101
|
+
...restArgs
|
|
102
|
+
} = args;
|
|
103
|
+
return {
|
|
104
|
+
...restArgs,
|
|
105
|
+
...doSample !== void 0 && { do_sample: doSample },
|
|
106
|
+
...thinking !== void 0 && {
|
|
107
|
+
thinking: {
|
|
108
|
+
...thinking.type !== void 0 && { type: thinking.type },
|
|
109
|
+
...thinking.clearThinking !== void 0 && {
|
|
110
|
+
clear_thinking: thinking.clearThinking
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
...toolStream !== void 0 && { tool_stream: toolStream },
|
|
115
|
+
...requestId !== void 0 && { request_id: requestId },
|
|
116
|
+
...userId !== void 0 && { user_id: userId }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function mapZaiFinishReason(finishReason, rawFinishReason) {
|
|
120
|
+
switch (rawFinishReason) {
|
|
121
|
+
case "sensitive":
|
|
122
|
+
return "content-filter";
|
|
123
|
+
case "model_context_window_exceeded":
|
|
124
|
+
return "length";
|
|
125
|
+
case "network_error":
|
|
126
|
+
return "error";
|
|
127
|
+
default:
|
|
128
|
+
return finishReason;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getRawFinishReason(responseBody) {
|
|
132
|
+
if (responseBody == null || typeof responseBody !== "object") {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
const choices = responseBody.choices;
|
|
136
|
+
if (!Array.isArray(choices) || choices.length === 0) {
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
const choice = choices[0];
|
|
140
|
+
if (choice == null || typeof choice !== "object") {
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
const finishReason = choice.finish_reason;
|
|
144
|
+
return typeof finishReason === "string" ? finishReason : void 0;
|
|
145
|
+
}
|
|
146
|
+
var ZaiChatLanguageModel = class extends import_openai_compatible.OpenAICompatibleChatLanguageModel {
|
|
147
|
+
constructor(modelId, config) {
|
|
148
|
+
const headers = config.headers;
|
|
149
|
+
super(modelId, {
|
|
150
|
+
provider: config.provider,
|
|
151
|
+
url: ({ path }) => `${config.baseURL}${path}`,
|
|
152
|
+
headers: () => headers == null ? {} : typeof headers === "function" ? headers() : headers,
|
|
153
|
+
fetch: config.fetch,
|
|
154
|
+
errorStructure: zaiErrorStructure,
|
|
155
|
+
transformRequestBody: transformZaiRequestBody,
|
|
156
|
+
supportedUrls: () => ({
|
|
157
|
+
"image/*": [/^https?:\/\//],
|
|
158
|
+
"video/*": [/^https?:\/\//]
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async prepareCallOptions(options) {
|
|
163
|
+
const warnings = [];
|
|
164
|
+
const zaiOptions = await (0, import_provider_utils.parseProviderOptions)({
|
|
165
|
+
provider: "zai",
|
|
166
|
+
providerOptions: options.providerOptions,
|
|
167
|
+
schema: zaiLanguageModelChatOptions
|
|
168
|
+
});
|
|
169
|
+
if (options.frequencyPenalty != null) {
|
|
170
|
+
warnings.push({
|
|
171
|
+
type: "unsupported-setting",
|
|
172
|
+
setting: "frequencyPenalty"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (options.presencePenalty != null) {
|
|
176
|
+
warnings.push({
|
|
177
|
+
type: "unsupported-setting",
|
|
178
|
+
setting: "presencePenalty"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (options.seed != null) {
|
|
182
|
+
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
183
|
+
}
|
|
184
|
+
let tools = options.tools;
|
|
185
|
+
let toolChoice = options.toolChoice;
|
|
186
|
+
if ((toolChoice == null ? void 0 : toolChoice.type) === "none") {
|
|
187
|
+
tools = void 0;
|
|
188
|
+
toolChoice = void 0;
|
|
189
|
+
} else if (toolChoice != null && toolChoice.type !== "auto") {
|
|
190
|
+
warnings.push({
|
|
191
|
+
type: "unsupported-setting",
|
|
192
|
+
setting: "toolChoice",
|
|
193
|
+
details: "Z.AI currently supports only automatic tool selection."
|
|
194
|
+
});
|
|
195
|
+
toolChoice = void 0;
|
|
196
|
+
}
|
|
197
|
+
const normalizedOptions = {
|
|
198
|
+
...options,
|
|
199
|
+
frequencyPenalty: void 0,
|
|
200
|
+
presencePenalty: void 0,
|
|
201
|
+
seed: void 0,
|
|
202
|
+
tools,
|
|
203
|
+
toolChoice,
|
|
204
|
+
providerOptions: zaiOptions == null ? options.providerOptions : {
|
|
205
|
+
...options.providerOptions,
|
|
206
|
+
zai: zaiOptions
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return { normalizedOptions, warnings };
|
|
210
|
+
}
|
|
211
|
+
async doGenerate(options) {
|
|
212
|
+
var _a;
|
|
213
|
+
const { normalizedOptions, warnings } = await this.prepareCallOptions(options);
|
|
214
|
+
const result = await super.doGenerate(normalizedOptions);
|
|
215
|
+
return {
|
|
216
|
+
...result,
|
|
217
|
+
finishReason: mapZaiFinishReason(
|
|
218
|
+
result.finishReason,
|
|
219
|
+
getRawFinishReason((_a = result.response) == null ? void 0 : _a.body)
|
|
220
|
+
),
|
|
221
|
+
warnings: [...result.warnings, ...warnings]
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
async doStream(options) {
|
|
225
|
+
const originalIncludeRawChunks = options.includeRawChunks;
|
|
226
|
+
const { normalizedOptions, warnings } = await this.prepareCallOptions(options);
|
|
227
|
+
const result = await super.doStream({
|
|
228
|
+
...normalizedOptions,
|
|
229
|
+
includeRawChunks: true
|
|
230
|
+
});
|
|
231
|
+
let rawFinishReason;
|
|
232
|
+
return {
|
|
233
|
+
...result,
|
|
234
|
+
stream: result.stream.pipeThrough(
|
|
235
|
+
new TransformStream({
|
|
236
|
+
transform(part, controller) {
|
|
237
|
+
var _a;
|
|
238
|
+
if (part.type === "stream-start") {
|
|
239
|
+
controller.enqueue({
|
|
240
|
+
...part,
|
|
241
|
+
warnings: [...part.warnings, ...warnings]
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (part.type === "raw") {
|
|
246
|
+
rawFinishReason = (_a = getRawFinishReason(part.rawValue)) != null ? _a : rawFinishReason;
|
|
247
|
+
if (originalIncludeRawChunks) {
|
|
248
|
+
controller.enqueue(part);
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (part.type === "finish") {
|
|
253
|
+
controller.enqueue({
|
|
254
|
+
...part,
|
|
255
|
+
finishReason: mapZaiFinishReason(
|
|
256
|
+
part.finishReason,
|
|
257
|
+
rawFinishReason
|
|
258
|
+
)
|
|
259
|
+
});
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
controller.enqueue(part);
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
)
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// src/zai-provider.ts
|
|
271
|
+
function createZai(options = {}) {
|
|
272
|
+
var _a;
|
|
273
|
+
const baseURL = (_a = (0, import_provider_utils2.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.z.ai/api/paas/v4";
|
|
274
|
+
const getHeaders = () => (0, import_provider_utils2.withUserAgentSuffix)(
|
|
275
|
+
{
|
|
276
|
+
Authorization: `Bearer ${(0, import_provider_utils2.loadApiKey)({
|
|
277
|
+
apiKey: options.apiKey,
|
|
278
|
+
environmentVariableName: "ZAI_API_KEY",
|
|
279
|
+
description: "Z.AI API key"
|
|
280
|
+
})}`,
|
|
281
|
+
...options.headers
|
|
282
|
+
},
|
|
283
|
+
`ai-sdk/zai/${VERSION}`
|
|
284
|
+
);
|
|
285
|
+
const createLanguageModel = (modelId) => new ZaiChatLanguageModel(modelId, {
|
|
286
|
+
provider: "zai.chat",
|
|
287
|
+
baseURL,
|
|
288
|
+
headers: getHeaders,
|
|
289
|
+
fetch: options.fetch
|
|
290
|
+
});
|
|
291
|
+
const provider = (modelId) => createLanguageModel(modelId);
|
|
292
|
+
provider.specificationVersion = "v2";
|
|
293
|
+
provider.languageModel = createLanguageModel;
|
|
294
|
+
provider.chatModel = createLanguageModel;
|
|
295
|
+
provider.chat = createLanguageModel;
|
|
296
|
+
provider.textEmbeddingModel = (modelId) => {
|
|
297
|
+
throw new import_provider.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
298
|
+
};
|
|
299
|
+
provider.imageModel = (modelId) => {
|
|
300
|
+
throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
301
|
+
};
|
|
302
|
+
return provider;
|
|
303
|
+
}
|
|
304
|
+
var zai = createZai();
|
|
305
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
+
0 && (module.exports = {
|
|
307
|
+
VERSION,
|
|
308
|
+
createZai,
|
|
309
|
+
zai
|
|
310
|
+
});
|
|
311
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/zai-provider.ts","../src/version.ts","../src/zai-chat-language-model.ts","../src/zai-chat-language-model-options.ts","../src/zai-error.ts"],"sourcesContent":["export type { ZaiLanguageModelChatOptions } from './zai-chat-language-model-options';\nexport type { ZaiChatModelId } from './zai-chat-options';\nexport type { ZaiErrorData } from './zai-error';\nexport { createZai, zai } from './zai-provider';\nexport type { ZaiProvider, ZaiProviderSettings } from './zai-provider';\nexport { VERSION } from './version';\n","import {\n NoSuchModelError,\n type LanguageModelV2,\n type ProviderV2,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from './version';\nimport { ZaiChatLanguageModel } from './zai-chat-language-model';\nimport type { ZaiChatModelId } from './zai-chat-options';\n\nexport interface ZaiProviderSettings {\n /**\n * Z.AI API key. Defaults to the `ZAI_API_KEY` environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for API calls. Defaults to\n * `https://api.z.ai/api/paas/v4`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation.\n */\n fetch?: FetchFunction;\n}\n\nexport interface ZaiProvider extends ProviderV2 {\n /**\n * Creates a Z.AI chat model for text generation.\n */\n (modelId: ZaiChatModelId): LanguageModelV2;\n\n /**\n * Creates a Z.AI language model.\n */\n languageModel(modelId: ZaiChatModelId): LanguageModelV2;\n\n /**\n * Creates a Z.AI chat model.\n */\n chatModel(modelId: ZaiChatModelId): LanguageModelV2;\n\n /**\n * Creates a Z.AI chat model.\n */\n chat(modelId: ZaiChatModelId): LanguageModelV2;\n}\n\nexport function createZai(options: ZaiProviderSettings = {}): ZaiProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ?? 'https://api.z.ai/api/paas/v4';\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'ZAI_API_KEY',\n description: 'Z.AI API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/zai/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: ZaiChatModelId) =>\n new ZaiChatLanguageModel(modelId, {\n provider: 'zai.chat',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = (modelId: ZaiChatModelId) => createLanguageModel(modelId);\n\n provider.specificationVersion = 'v2' as const;\n provider.languageModel = createLanguageModel;\n provider.chatModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const zai = createZai();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport type {\n LanguageModelV2,\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n LanguageModelV2FinishReason,\n LanguageModelV2StreamPart,\n} from '@ai-sdk/provider';\nimport {\n parseProviderOptions,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport type { ZaiChatModelId } from './zai-chat-options';\nimport { zaiLanguageModelChatOptions } from './zai-chat-language-model-options';\nimport { zaiErrorStructure } from './zai-error';\n\nexport type ZaiChatConfig = {\n provider: string;\n baseURL: string;\n headers?:\n | Record<string, string | undefined>\n | (() => Record<string, string | undefined>);\n fetch?: FetchFunction;\n};\n\nfunction transformZaiRequestBody(\n args: Record<string, any>,\n): Record<string, any> {\n const {\n doSample,\n frequency_penalty: _frequencyPenalty,\n presence_penalty: _presencePenalty,\n requestId,\n seed: _seed,\n thinking,\n toolStream,\n user: _user,\n userId,\n verbosity: _verbosity,\n ...restArgs\n } = args;\n\n return {\n ...restArgs,\n ...(doSample !== undefined && { do_sample: doSample }),\n ...(thinking !== undefined && {\n thinking: {\n ...(thinking.type !== undefined && { type: thinking.type }),\n ...(thinking.clearThinking !== undefined && {\n clear_thinking: thinking.clearThinking,\n }),\n },\n }),\n ...(toolStream !== undefined && { tool_stream: toolStream }),\n ...(requestId !== undefined && { request_id: requestId }),\n ...(userId !== undefined && { user_id: userId }),\n };\n}\n\nfunction mapZaiFinishReason(\n finishReason: LanguageModelV2FinishReason,\n rawFinishReason: string | undefined,\n): LanguageModelV2FinishReason {\n switch (rawFinishReason) {\n case 'sensitive':\n return 'content-filter';\n case 'model_context_window_exceeded':\n return 'length';\n case 'network_error':\n return 'error';\n default:\n return finishReason;\n }\n}\n\nfunction getRawFinishReason(responseBody: unknown): string | undefined {\n if (responseBody == null || typeof responseBody !== 'object') {\n return undefined;\n }\n\n const choices = (responseBody as { choices?: unknown }).choices;\n if (!Array.isArray(choices) || choices.length === 0) {\n return undefined;\n }\n\n const choice = choices[0];\n if (choice == null || typeof choice !== 'object') {\n return undefined;\n }\n\n const finishReason = (choice as { finish_reason?: unknown }).finish_reason;\n return typeof finishReason === 'string' ? finishReason : undefined;\n}\n\nexport class ZaiChatLanguageModel\n extends OpenAICompatibleChatLanguageModel\n implements LanguageModelV2\n{\n constructor(modelId: ZaiChatModelId, config: ZaiChatConfig) {\n const headers = config.headers;\n\n super(modelId, {\n provider: config.provider,\n url: ({ path }) => `${config.baseURL}${path}`,\n headers: () =>\n headers == null\n ? {}\n : typeof headers === 'function'\n ? headers()\n : headers,\n fetch: config.fetch,\n errorStructure: zaiErrorStructure,\n transformRequestBody: transformZaiRequestBody,\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\//],\n 'video/*': [/^https?:\\/\\//],\n }),\n });\n }\n\n private async prepareCallOptions(options: LanguageModelV2CallOptions) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n const zaiOptions = await parseProviderOptions({\n provider: 'zai',\n providerOptions: options.providerOptions,\n schema: zaiLanguageModelChatOptions,\n });\n\n if (options.frequencyPenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'frequencyPenalty',\n });\n }\n if (options.presencePenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'presencePenalty',\n });\n }\n if (options.seed != null) {\n warnings.push({ type: 'unsupported-setting', setting: 'seed' });\n }\n\n let tools = options.tools;\n let toolChoice = options.toolChoice;\n\n if (toolChoice?.type === 'none') {\n tools = undefined;\n toolChoice = undefined;\n } else if (toolChoice != null && toolChoice.type !== 'auto') {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'toolChoice',\n details: 'Z.AI currently supports only automatic tool selection.',\n });\n toolChoice = undefined;\n }\n\n const normalizedOptions: LanguageModelV2CallOptions = {\n ...options,\n frequencyPenalty: undefined,\n presencePenalty: undefined,\n seed: undefined,\n tools,\n toolChoice,\n providerOptions:\n zaiOptions == null\n ? options.providerOptions\n : {\n ...options.providerOptions,\n zai: zaiOptions,\n },\n };\n\n return { normalizedOptions, warnings };\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { normalizedOptions, warnings } =\n await this.prepareCallOptions(options);\n const result = await super.doGenerate(normalizedOptions);\n\n return {\n ...result,\n finishReason: mapZaiFinishReason(\n result.finishReason,\n getRawFinishReason(result.response?.body),\n ),\n warnings: [...result.warnings, ...warnings],\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const originalIncludeRawChunks = options.includeRawChunks;\n const { normalizedOptions, warnings } =\n await this.prepareCallOptions(options);\n const result = await super.doStream({\n ...normalizedOptions,\n includeRawChunks: true,\n });\n\n let rawFinishReason: string | undefined;\n\n return {\n ...result,\n stream: result.stream.pipeThrough(\n new TransformStream<\n LanguageModelV2StreamPart,\n LanguageModelV2StreamPart\n >({\n transform(part, controller) {\n if (part.type === 'stream-start') {\n controller.enqueue({\n ...part,\n warnings: [...part.warnings, ...warnings],\n });\n return;\n }\n\n if (part.type === 'raw') {\n rawFinishReason =\n getRawFinishReason(part.rawValue) ?? rawFinishReason;\n if (originalIncludeRawChunks) {\n controller.enqueue(part);\n }\n return;\n }\n\n if (part.type === 'finish') {\n controller.enqueue({\n ...part,\n finishReason: mapZaiFinishReason(\n part.finishReason,\n rawFinishReason,\n ),\n });\n return;\n }\n\n controller.enqueue(part);\n },\n }),\n ),\n };\n }\n}\n","import { z } from 'zod/v4';\n\nexport const zaiLanguageModelChatOptions = z.object({\n /**\n * Enables or disables sampling. When disabled, temperature and topP do not\n * take effect.\n */\n doSample: z.boolean().optional(),\n\n /**\n * Controls model thinking and whether reasoning from earlier turns is kept.\n */\n thinking: z\n .object({\n type: z.enum(['enabled', 'disabled']).optional(),\n clearThinking: z.boolean().optional(),\n })\n .optional(),\n\n /**\n * Controls reasoning effort for GLM-5.2 and later models.\n */\n reasoningEffort: z\n .enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'])\n .optional(),\n\n /**\n * Enables incremental function-call argument streaming on supported models.\n */\n toolStream: z.boolean().optional(),\n\n /**\n * A caller-provided request identifier between 6 and 64 characters.\n */\n requestId: z.string().min(6).max(64).optional(),\n\n /**\n * A non-sensitive end-user identifier between 6 and 128 characters.\n */\n userId: z.string().min(6).max(128).optional(),\n});\n\nexport type ZaiLanguageModelChatOptions = z.infer<\n typeof zaiLanguageModelChatOptions\n>;\n","import type { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { z } from 'zod/v4';\n\nconst zaiErrorDetailsSchema = z.object({\n code: z.union([z.number(), z.string()]).nullish(),\n message: z.string(),\n});\n\nconst zaiErrorSchema = z.union([\n zaiErrorDetailsSchema,\n z.object({ error: zaiErrorDetailsSchema }),\n]);\n\nexport type ZaiErrorData = z.infer<typeof zaiErrorSchema>;\n\nexport const zaiErrorStructure: ProviderErrorStructure<ZaiErrorData> = {\n errorSchema: zaiErrorSchema,\n errorToMessage: data => ('error' in data ? data.error.message : data.message),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAIO;AACP,IAAAA,yBAKO;;;ACRA,IAAM,UACX,OACI,UACA;;;ACLN,+BAAkD;AAQlD,4BAGO;;;ACXP,gBAAkB;AAEX,IAAM,8BAA8B,YAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlD,UAAU,YAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAK/B,UAAU,YACP,OAAO;AAAA,IACN,MAAM,YAAE,KAAK,CAAC,WAAW,UAAU,CAAC,EAAE,SAAS;AAAA,IAC/C,eAAe,YAAE,QAAQ,EAAE,SAAS;AAAA,EACtC,CAAC,EACA,SAAS;AAAA;AAAA;AAAA;AAAA,EAKZ,iBAAiB,YACd,KAAK,CAAC,QAAQ,WAAW,OAAO,UAAU,QAAQ,SAAS,KAAK,CAAC,EACjE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKZ,YAAY,YAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKjC,WAAW,YAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAK9C,QAAQ,YAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;AAC9C,CAAC;;;ACvCD,IAAAC,aAAkB;AAElB,IAAM,wBAAwB,aAAE,OAAO;AAAA,EACrC,MAAM,aAAE,MAAM,CAAC,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,CAAC,EAAE,QA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