@llmrtc/llmrtc-provider-zai 1.2.0
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 +26 -0
- package/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +19 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/dist/tool-adapter.d.ts +32 -0
- package/dist/tool-adapter.js +90 -0
- package/dist/tool-adapter.js.map +1 -0
- package/package.json +50 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @llmrtc/llmrtc-provider-zai
|
|
2
|
+
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 246b6f6: New model ecosystems: Z.ai GLM and current local vision models.
|
|
8
|
+
- New @llmrtc/llmrtc-provider-zai package: ZaiLLMProvider for Z.ai's GLM
|
|
9
|
+
family (default glm-5.2 - 1M context, open weights, strong tool calling)
|
|
10
|
+
via the OpenAI-compatible API, with full tool-calling and streaming
|
|
11
|
+
support. CLI: LLM_PROVIDER=zai with ZAI_API_KEY/ZAI_MODEL.
|
|
12
|
+
- Local vision generalized: OllamaVisionProvider works with any
|
|
13
|
+
vision-capable Ollama model and defaults to qwen3-vl;
|
|
14
|
+
LlavaVisionProvider remains as a compatible alias defaulting to llava.
|
|
15
|
+
CLI: OLLAMA_VISION_MODEL selects the model (the CLI default stays
|
|
16
|
+
llava, so existing LOCAL_ONLY deployments are unaffected - set
|
|
17
|
+
OLLAMA_VISION_MODEL=qwen3-vl to opt in). The CLI vision provider now
|
|
18
|
+
also honors OLLAMA_BASE_URL. Qwen 3.6 multimodal runs through LM
|
|
19
|
+
Studio vision attachments (Ollama GGUF support pending upstream).
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [fd91344]
|
|
24
|
+
- Updated dependencies [319bb47]
|
|
25
|
+
- Updated dependencies [a7d1ecc]
|
|
26
|
+
- @llmrtc/llmrtc-core@1.2.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @llmrtc/llmrtc-provider-zai
|
|
2
|
+
|
|
3
|
+
Z.ai GLM adapter for [LLMRTC](https://www.llmrtc.org) - realtime voice and
|
|
4
|
+
vision AI agents over WebRTC.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
import { ZaiLLMProvider } from '@llmrtc/llmrtc-provider-zai';
|
|
8
|
+
|
|
9
|
+
const llm = new ZaiLLMProvider({
|
|
10
|
+
apiKey: process.env.ZAI_API_KEY!,
|
|
11
|
+
model: 'glm-5.2'
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
GLM 5.2 is an open-weight (MIT) MoE model with a 1M-token context window and
|
|
16
|
+
strong tool calling at low cost. GLM models are also reachable through
|
|
17
|
+
OpenRouter (`@llmrtc/llmrtc-provider-openrouter` with model `z-ai/glm-5.2`).
|
|
18
|
+
|
|
19
|
+
See the [documentation](https://www.llmrtc.org) for the full guide.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LLMChunk, LLMProvider, LLMRequest, LLMResult } from '@llmrtc/llmrtc-core';
|
|
2
|
+
export interface ZaiConfig {
|
|
3
|
+
/** Z.ai API key */
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Model name (default: 'glm-5.2') */
|
|
6
|
+
model?: string;
|
|
7
|
+
/** Base URL (default: 'https://api.z.ai/api/paas/v4') */
|
|
8
|
+
baseURL?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Z.ai GLM LLM Provider - Zhipu's GLM models via the OpenAI-compatible API.
|
|
12
|
+
*
|
|
13
|
+
* GLM 5.2 is an open-weight (MIT) MoE model with a 1M-token context window
|
|
14
|
+
* and strong tool calling at low cost, which makes it a good fit for
|
|
15
|
+
* cost-sensitive voice agents.
|
|
16
|
+
*
|
|
17
|
+
* GLM models are also reachable through OpenRouter
|
|
18
|
+
* (`OpenRouterLLMProvider` with model 'z-ai/glm-5.2') if you prefer a
|
|
19
|
+
* single gateway key.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const provider = new ZaiLLMProvider({
|
|
24
|
+
* apiKey: process.env.ZAI_API_KEY!,
|
|
25
|
+
* model: 'glm-5.2'
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class ZaiLLMProvider implements LLMProvider {
|
|
30
|
+
private readonly config;
|
|
31
|
+
readonly name = "zai-llm";
|
|
32
|
+
private client;
|
|
33
|
+
private model;
|
|
34
|
+
constructor(config: ZaiConfig);
|
|
35
|
+
complete(request: LLMRequest): Promise<LLMResult>;
|
|
36
|
+
stream(request: LLMRequest): AsyncIterable<LLMChunk>;
|
|
37
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { mapToolsToOpenAI, mapToolChoiceToOpenAI, parseToolCallsFromOpenAI, mapStopReasonFromOpenAI, processToolCallDelta, finalizeToolCalls, } from './tool-adapter.js';
|
|
3
|
+
/**
|
|
4
|
+
* Z.ai GLM LLM Provider - Zhipu's GLM models via the OpenAI-compatible API.
|
|
5
|
+
*
|
|
6
|
+
* GLM 5.2 is an open-weight (MIT) MoE model with a 1M-token context window
|
|
7
|
+
* and strong tool calling at low cost, which makes it a good fit for
|
|
8
|
+
* cost-sensitive voice agents.
|
|
9
|
+
*
|
|
10
|
+
* GLM models are also reachable through OpenRouter
|
|
11
|
+
* (`OpenRouterLLMProvider` with model 'z-ai/glm-5.2') if you prefer a
|
|
12
|
+
* single gateway key.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const provider = new ZaiLLMProvider({
|
|
17
|
+
* apiKey: process.env.ZAI_API_KEY!,
|
|
18
|
+
* model: 'glm-5.2'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class ZaiLLMProvider {
|
|
23
|
+
constructor(config) {
|
|
24
|
+
Object.defineProperty(this, "config", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: config
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "name", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: 'zai-llm'
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "client", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "model", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
this.model = config.model ?? 'glm-5.2';
|
|
49
|
+
this.client = new OpenAI({
|
|
50
|
+
apiKey: config.apiKey,
|
|
51
|
+
baseURL: config.baseURL ?? 'https://api.z.ai/api/paas/v4'
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async complete(request) {
|
|
55
|
+
const completion = await this.client.chat.completions.create({
|
|
56
|
+
model: this.model,
|
|
57
|
+
messages: mapMessages(request.messages),
|
|
58
|
+
temperature: request.config?.temperature,
|
|
59
|
+
top_p: request.config?.topP,
|
|
60
|
+
max_tokens: request.config?.maxTokens,
|
|
61
|
+
stream: false,
|
|
62
|
+
...(request.tools?.length && {
|
|
63
|
+
tools: mapToolsToOpenAI(request.tools),
|
|
64
|
+
tool_choice: mapToolChoiceToOpenAI(request.toolChoice),
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const choice = completion.choices?.[0];
|
|
68
|
+
const fullText = choice?.message?.content ?? '';
|
|
69
|
+
const toolCalls = parseToolCallsFromOpenAI(choice?.message?.tool_calls);
|
|
70
|
+
const stopReason = mapStopReasonFromOpenAI(choice?.finish_reason);
|
|
71
|
+
return { fullText, raw: completion, toolCalls, stopReason };
|
|
72
|
+
}
|
|
73
|
+
async *stream(request) {
|
|
74
|
+
const stream = await this.client.chat.completions.create({
|
|
75
|
+
model: this.model,
|
|
76
|
+
messages: mapMessages(request.messages),
|
|
77
|
+
temperature: request.config?.temperature,
|
|
78
|
+
top_p: request.config?.topP,
|
|
79
|
+
max_tokens: request.config?.maxTokens,
|
|
80
|
+
stream: true,
|
|
81
|
+
...(request.tools?.length && {
|
|
82
|
+
tools: mapToolsToOpenAI(request.tools),
|
|
83
|
+
tool_choice: mapToolChoiceToOpenAI(request.toolChoice),
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
const toolCallAccumulators = new Map();
|
|
87
|
+
let finishReason = null;
|
|
88
|
+
for await (const part of stream) {
|
|
89
|
+
const choice = part.choices?.[0];
|
|
90
|
+
const delta = choice?.delta;
|
|
91
|
+
if (delta?.tool_calls) {
|
|
92
|
+
for (const toolCallDelta of delta.tool_calls) {
|
|
93
|
+
processToolCallDelta(toolCallAccumulators, toolCallDelta);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (choice?.finish_reason)
|
|
97
|
+
finishReason = choice.finish_reason;
|
|
98
|
+
yield { content: delta?.content ?? '', done: false, raw: part };
|
|
99
|
+
}
|
|
100
|
+
const toolCalls = toolCallAccumulators.size > 0 ? finalizeToolCalls(toolCallAccumulators) : undefined;
|
|
101
|
+
const stopReason = mapStopReasonFromOpenAI(finishReason);
|
|
102
|
+
yield { content: '', done: true, toolCalls, stopReason };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function mapMessages(messages) {
|
|
106
|
+
return messages.map((m) => {
|
|
107
|
+
if (m.role === 'tool') {
|
|
108
|
+
return {
|
|
109
|
+
role: 'tool',
|
|
110
|
+
content: m.content,
|
|
111
|
+
tool_call_id: m.toolCallId ?? '',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Assistant messages must carry their tool_calls when replayed;
|
|
115
|
+
// OpenAI-compatible APIs reject tool results with no matching call
|
|
116
|
+
if (m.role === 'assistant') {
|
|
117
|
+
const assistantMsg = {
|
|
118
|
+
role: 'assistant',
|
|
119
|
+
content: m.content || null,
|
|
120
|
+
};
|
|
121
|
+
if (m.toolCalls?.length) {
|
|
122
|
+
assistantMsg.tool_calls = m.toolCalls.map(tc => ({
|
|
123
|
+
id: tc.callId,
|
|
124
|
+
type: 'function',
|
|
125
|
+
function: {
|
|
126
|
+
name: tc.name,
|
|
127
|
+
arguments: JSON.stringify(tc.arguments),
|
|
128
|
+
},
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
return assistantMsg;
|
|
132
|
+
}
|
|
133
|
+
if (!m.attachments?.length) {
|
|
134
|
+
return { role: m.role, content: m.content };
|
|
135
|
+
}
|
|
136
|
+
// Vision support for multimodal GLM variants - attachments map to
|
|
137
|
+
// OpenAI-style image_url parts
|
|
138
|
+
const imageParts = m.attachments.map((att) => ({
|
|
139
|
+
type: 'image_url',
|
|
140
|
+
image_url: { url: att.data }
|
|
141
|
+
}));
|
|
142
|
+
return {
|
|
143
|
+
role: m.role,
|
|
144
|
+
content: [{ type: 'text', text: m.content }, ...imageParts]
|
|
145
|
+
};
|
|
146
|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/
|
|
6
|
+
import type { ChatCompletionTool, ChatCompletionToolChoiceOption } from 'openai/resources/chat/completions';
|
|
7
|
+
import type { ToolDefinition, ToolCallRequest, ToolChoice, StopReason } from '@llmrtc/llmrtc-core';
|
|
8
|
+
export declare function mapToolsToOpenAI(tools: ToolDefinition[]): ChatCompletionTool[];
|
|
9
|
+
export declare function mapToolChoiceToOpenAI(choice?: ToolChoice): ChatCompletionToolChoiceOption | undefined;
|
|
10
|
+
export declare function parseToolCallsFromOpenAI(toolCalls?: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
type: 'function';
|
|
13
|
+
function: {
|
|
14
|
+
name: string;
|
|
15
|
+
arguments: string;
|
|
16
|
+
};
|
|
17
|
+
}>): ToolCallRequest[] | undefined;
|
|
18
|
+
export interface StreamingToolCallAccumulator {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
arguments: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function processToolCallDelta(accumulators: Map<number, StreamingToolCallAccumulator>, delta: {
|
|
24
|
+
index: number;
|
|
25
|
+
id?: string;
|
|
26
|
+
function?: {
|
|
27
|
+
name?: string;
|
|
28
|
+
arguments?: string;
|
|
29
|
+
};
|
|
30
|
+
}): void;
|
|
31
|
+
export declare function finalizeToolCalls(accumulators: Map<number, StreamingToolCallAccumulator>): ToolCallRequest[];
|
|
32
|
+
export declare function mapStopReasonFromOpenAI(finishReason: string | null | undefined): StopReason | undefined;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Z.ai Tool Adapter
|
|
3
|
+
*
|
|
4
|
+
* Z.ai's GLM API is OpenAI-compatible, so we reuse the same tool format.
|
|
5
|
+
*/
|
|
6
|
+
export function mapToolsToOpenAI(tools) {
|
|
7
|
+
return tools.map(tool => ({
|
|
8
|
+
type: 'function',
|
|
9
|
+
function: {
|
|
10
|
+
name: tool.name,
|
|
11
|
+
description: tool.description,
|
|
12
|
+
parameters: tool.parameters,
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
export function mapToolChoiceToOpenAI(choice) {
|
|
17
|
+
if (!choice)
|
|
18
|
+
return undefined;
|
|
19
|
+
if (typeof choice === 'string') {
|
|
20
|
+
switch (choice) {
|
|
21
|
+
case 'auto': return 'auto';
|
|
22
|
+
case 'none': return 'none';
|
|
23
|
+
case 'required': return 'required';
|
|
24
|
+
default: return 'auto';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { type: 'function', function: { name: choice.name } };
|
|
28
|
+
}
|
|
29
|
+
export function parseToolCallsFromOpenAI(toolCalls) {
|
|
30
|
+
if (!toolCalls?.length)
|
|
31
|
+
return undefined;
|
|
32
|
+
return toolCalls.map(call => ({
|
|
33
|
+
callId: call.id,
|
|
34
|
+
name: call.function.name,
|
|
35
|
+
...parseArguments(call.function.arguments),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
export function processToolCallDelta(accumulators, delta) {
|
|
39
|
+
const { index, id, function: fn } = delta;
|
|
40
|
+
if (!accumulators.has(index)) {
|
|
41
|
+
accumulators.set(index, { id: id ?? '', name: fn?.name ?? '', arguments: '' });
|
|
42
|
+
}
|
|
43
|
+
const acc = accumulators.get(index);
|
|
44
|
+
if (id)
|
|
45
|
+
acc.id = id;
|
|
46
|
+
if (fn?.name)
|
|
47
|
+
acc.name = fn.name;
|
|
48
|
+
if (fn?.arguments)
|
|
49
|
+
acc.arguments += fn.arguments;
|
|
50
|
+
}
|
|
51
|
+
export function finalizeToolCalls(accumulators) {
|
|
52
|
+
return Array.from(accumulators.entries())
|
|
53
|
+
.sort(([a], [b]) => a - b)
|
|
54
|
+
.map(([index, acc]) => ({
|
|
55
|
+
// Some OpenAI-compatible backends omit ids on streamed tool calls;
|
|
56
|
+
// generate one so tool results can still be correlated in history
|
|
57
|
+
callId: acc.id || `call_${index}_${Date.now()}`,
|
|
58
|
+
name: acc.name,
|
|
59
|
+
...parseArguments(acc.arguments),
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse the model's arguments JSON. Empty input means "no arguments";
|
|
64
|
+
* unparseable input is flagged so executors can fail the call instead of
|
|
65
|
+
* running the tool with silently-empty arguments.
|
|
66
|
+
*/
|
|
67
|
+
function parseArguments(str) {
|
|
68
|
+
if (!str || !str.trim()) {
|
|
69
|
+
return { arguments: {} };
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
return { arguments: JSON.parse(str) };
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
arguments: {},
|
|
77
|
+
parseError: err instanceof Error ? err.message : String(err),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function mapStopReasonFromOpenAI(finishReason) {
|
|
82
|
+
switch (finishReason) {
|
|
83
|
+
case 'stop': return 'end_turn';
|
|
84
|
+
case 'tool_calls': return 'tool_use';
|
|
85
|
+
case 'length': return 'max_tokens';
|
|
86
|
+
case 'content_filter': return 'content_filter';
|
|
87
|
+
default: return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=tool-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-adapter.js","sourceRoot":"","sources":["../src/tool-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,UAAU,gBAAgB,CAAC,KAAuB;IACtD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,UAAmB;QACzB,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAA2C;SAC7D;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAmB;IAEnB,IAAI,CAAC,MAAM;QAAE,OA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SAC7D,CAAC;IACJ,CAAC;AACH,CAAC;AAGD,MAAM,UAAU,uBAAuB,CACrC,YAAuC;IAEvC,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM,CAAC,CAAC,OAAO,UAAU,CAAC;QAC/B,KAAK,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC;QACrC,KAAK,QAAQ,CAAC,CAAC,OAAO,YAAY,CAAC;QACnC,KAAK,gBAAgB,CAAC,CAAC,OAAO,gBAAgB,CAAC;QAC/C,OAAO,CAAC,CAAC,OAAO,SAAS,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@llmrtc/llmrtc-provider-zai",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Z.ai GLM LLM adapter for @llmrtc/LLMRTC",
|
|
5
|
+
"homepage": "https://www.llmrtc.org",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/llmrtc/llmrtc.git",
|
|
21
|
+
"directory": "packages/providers/zai"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/llmrtc/llmrtc/issues",
|
|
25
|
+
"email": "contact@llmrtc.org"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"NOTICE",
|
|
35
|
+
"CHANGELOG.md"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -b",
|
|
39
|
+
"clean": "rimraf dist",
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
41
|
+
},
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@llmrtc/llmrtc-core": "^1.2.0",
|
|
48
|
+
"openai": "^4.72.0"
|
|
49
|
+
}
|
|
50
|
+
}
|