@arnilo/prism-provider-zai 0.0.7 → 0.0.10
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 +25 -0
- package/dist/provider.js +13 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [0.0.10] - 2026-07-21
|
|
3
|
+
|
|
4
|
+
### Changed
|
|
5
|
+
|
|
6
|
+
- Released with exact 0.0.10 graph.
|
|
7
|
+
|
|
8
|
+
## [0.0.96] - 2026-07-21
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Released with exact 0.0.96 graph.
|
|
13
|
+
|
|
14
|
+
## [0.0.9] - 2026-07-21
|
|
15
|
+
|
|
16
|
+
- Released with the exact 0.0.9 first-party package graph.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Malformed streamed tool-call arguments yield recoverable tool calls via `toolCallFromArgumentsText` instead of throwing `ProviderTransportError` / terminal stream errors.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [0.0.8] - 2026-07-20
|
|
24
|
+
|
|
25
|
+
- Released with the exact 0.0.8 first-party package graph.
|
|
26
|
+
|
|
2
27
|
## [0.0.7] - 2026-07-19
|
|
3
28
|
|
|
4
29
|
- Released with the exact 0.0.7 first-party package graph.
|
package/dist/provider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assertStructuredOutputRequestSupported, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, resolveCredentialValue,
|
|
2
|
-
import { applyOpenAIChatStructuredOutput, mapOpenAIChatUsage, serializeOpenAITool
|
|
3
|
-
import {
|
|
4
|
-
import { zaiPreserveThinking, zaiReasoningEffort, zaiThinking, zaiToolStream
|
|
1
|
+
import { assertStructuredOutputRequestSupported, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, resolveCredentialValue, toolCallFromArgumentsText } from "@arnilo/prism";
|
|
2
|
+
import { applyOpenAIChatStructuredOutput, mapOpenAIChatUsage, serializeOpenAITool } from "@arnilo/prism/providers/openai";
|
|
3
|
+
import { readBoundedResponseText, readSseData } from "@arnilo/prism/providers/transport";
|
|
4
|
+
import { zaiPreserveThinking, zaiReasoningEffort, zaiThinking, zaiToolStream } from "./thinking.js";
|
|
5
5
|
/** Official international Chat Completions base (China `open.bigmodel.cn` remains overridable). */
|
|
6
6
|
export const ZAI_DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
7
7
|
export function createZaiProvider(options = {}) {
|
|
@@ -20,10 +20,10 @@ export function createZaiProvider(options = {}) {
|
|
|
20
20
|
headers: {
|
|
21
21
|
...request.options?.headers,
|
|
22
22
|
"content-type": "application/json",
|
|
23
|
-
...(token ? { authorization: `Bearer ${token}` } : {})
|
|
23
|
+
...(token ? { authorization: `Bearer ${token}` } : {})
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify(zaiBody(request)),
|
|
26
|
-
signal: request.signal
|
|
26
|
+
signal: request.signal
|
|
27
27
|
});
|
|
28
28
|
if (!response.ok) {
|
|
29
29
|
return yield providerError(new Error(`Z.AI request failed: ${response.status} ${await readBoundedResponseText(response, { secrets })}`), secrets);
|
|
@@ -35,7 +35,7 @@ export function createZaiProvider(options = {}) {
|
|
|
35
35
|
catch (error) {
|
|
36
36
|
yield providerError(error, secrets);
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export function zaiBody(request) {
|
|
@@ -55,7 +55,7 @@ export function zaiBody(request) {
|
|
|
55
55
|
// Resolved official fields win over raw compat/extra escape hatches.
|
|
56
56
|
thinking: zaiThinking(request),
|
|
57
57
|
reasoning_effort: zaiReasoningEffort(request),
|
|
58
|
-
tool_stream: zaiToolStream(request)
|
|
58
|
+
tool_stream: zaiToolStream(request)
|
|
59
59
|
};
|
|
60
60
|
applyOpenAIChatStructuredOutput(body, request.options?.structuredOutput);
|
|
61
61
|
return clean(body);
|
|
@@ -91,14 +91,14 @@ export async function* zaiEvents(body, signal) {
|
|
|
91
91
|
index,
|
|
92
92
|
id: tool.id,
|
|
93
93
|
name: tool.function?.name,
|
|
94
|
-
argumentsText: tool.function?.arguments
|
|
94
|
+
argumentsText: tool.function?.arguments
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
for (const call of tools.values()) {
|
|
100
100
|
if (call.id && call.name) {
|
|
101
|
-
yield providerToolCall(
|
|
101
|
+
yield providerToolCall(toolCallFromArgumentsText(call.id, call.name, call.argumentsText));
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
yield providerDone(usage);
|
|
@@ -120,7 +120,7 @@ export function toZaiMessage(message, model, preserveThinking = false) {
|
|
|
120
120
|
return {
|
|
121
121
|
role: "tool",
|
|
122
122
|
tool_call_id: result?.toolCallId ?? "",
|
|
123
|
-
content: result ? JSON.stringify(result.result ?? result.error ?? null) : ""
|
|
123
|
+
content: result ? JSON.stringify(result.result ?? result.error ?? null) : ""
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
if (message.role === "assistant") {
|
|
@@ -133,9 +133,9 @@ export function toZaiMessage(message, model, preserveThinking = false) {
|
|
|
133
133
|
tool_calls: toolCalls.map((call) => ({
|
|
134
134
|
id: call.id,
|
|
135
135
|
type: "function",
|
|
136
|
-
function: { name: call.name, arguments: JSON.stringify(call.arguments) }
|
|
136
|
+
function: { name: call.name, arguments: JSON.stringify(call.arguments) }
|
|
137
137
|
})),
|
|
138
|
-
reasoning_content: reasoningContent
|
|
138
|
+
reasoning_content: reasoningContent
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism-provider-zai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Z.AI provider package for Prism.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"pack:dry-run": "npm pack --dry-run"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@arnilo/prism": "0.0.
|
|
28
|
+
"@arnilo/prism": "0.0.10"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@arnilo/prism": "file:../.."
|