@wuzhiguocarter/zhipu-ai-provider 0.2.1 → 0.2.3
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/README.md +86 -2
- package/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -13979,7 +13979,7 @@ var ZhipuChatLanguageModel = class {
|
|
|
13979
13979
|
tools,
|
|
13980
13980
|
toolChoice
|
|
13981
13981
|
}) {
|
|
13982
|
-
var _a3;
|
|
13982
|
+
var _a3, _b;
|
|
13983
13983
|
const warnings = [];
|
|
13984
13984
|
if (!this.config.isMultiModel && prompt.every(
|
|
13985
13985
|
(msg) => msg.role === "user" && !msg.content.every((part) => part.type === "text")
|
|
@@ -14055,6 +14055,20 @@ var ZhipuChatLanguageModel = class {
|
|
|
14055
14055
|
details: "JSON response format schema is only supported with structuredOutputs, provide the schema."
|
|
14056
14056
|
});
|
|
14057
14057
|
}
|
|
14058
|
+
if (((_a3 = this.settings.thinking) == null ? void 0 : _a3.clear_thinking) !== void 0 && !this.modelId.match(/^(glm-4\.[567]|glm-4\.5v)$/)) {
|
|
14059
|
+
warnings.push({
|
|
14060
|
+
type: "unsupported-setting",
|
|
14061
|
+
setting: "thinking.clear_thinking",
|
|
14062
|
+
details: "clear_thinking is only supported by GLM-4.5, GLM-4.6, and GLM-4.7 models."
|
|
14063
|
+
});
|
|
14064
|
+
}
|
|
14065
|
+
if (this.settings.toolStream !== void 0 && !this.modelId.match(/^glm-4\.[67]/)) {
|
|
14066
|
+
warnings.push({
|
|
14067
|
+
type: "unsupported-setting",
|
|
14068
|
+
setting: "toolStream",
|
|
14069
|
+
details: "tool_stream is only supported by GLM-4.7 and GLM-4.6 models."
|
|
14070
|
+
});
|
|
14071
|
+
}
|
|
14058
14072
|
const baseArgs = {
|
|
14059
14073
|
// model id:
|
|
14060
14074
|
model: this.modelId,
|
|
@@ -14063,19 +14077,25 @@ var ZhipuChatLanguageModel = class {
|
|
|
14063
14077
|
do_sample: this.settings.doSample,
|
|
14064
14078
|
request_id: this.settings.requestId,
|
|
14065
14079
|
thinking: this.settings.thinking ? {
|
|
14066
|
-
type: this.settings.thinking.type
|
|
14080
|
+
type: this.settings.thinking.type,
|
|
14081
|
+
...this.settings.thinking.clear_thinking !== void 0 && {
|
|
14082
|
+
clear_thinking: this.settings.thinking.clear_thinking
|
|
14083
|
+
}
|
|
14067
14084
|
} : void 0,
|
|
14068
14085
|
// standardized settings:
|
|
14069
14086
|
max_tokens: maxOutputTokens,
|
|
14070
14087
|
temperature,
|
|
14071
14088
|
top_p: topP,
|
|
14072
14089
|
// response format:
|
|
14073
|
-
response_format:
|
|
14090
|
+
response_format: responseFormat ? {
|
|
14091
|
+
type: responseFormat.type === "json" ? "json_object" : "text"
|
|
14092
|
+
} : void 0,
|
|
14074
14093
|
// messages:
|
|
14075
14094
|
messages: convertToZhipuChatMessages(prompt),
|
|
14076
14095
|
// tools:
|
|
14077
|
-
tool_choice: toolChoice
|
|
14078
|
-
|
|
14096
|
+
// tool_choice: toolChoice ?? "auto",
|
|
14097
|
+
tool_choice: "auto",
|
|
14098
|
+
tools: (_b = tools == null ? void 0 : tools.filter((tool) => tool.type === "function").map((tool) => {
|
|
14079
14099
|
var _a4;
|
|
14080
14100
|
return {
|
|
14081
14101
|
type: "function",
|
|
@@ -14085,8 +14105,10 @@ var ZhipuChatLanguageModel = class {
|
|
|
14085
14105
|
parameters: tool.inputSchema
|
|
14086
14106
|
}
|
|
14087
14107
|
};
|
|
14088
|
-
})) != null ?
|
|
14108
|
+
})) != null ? _b : void 0,
|
|
14089
14109
|
// TODO: add provider-specific tool (web_search|retrieval)
|
|
14110
|
+
// tool streaming:
|
|
14111
|
+
tool_stream: this.settings.toolStream
|
|
14090
14112
|
};
|
|
14091
14113
|
return {
|
|
14092
14114
|
args: baseArgs,
|