@zhivex-ai/qwen 0.2.1
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 +13 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +301 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CallableProviderAdapter, type ProviderAdapter } from "@zhivex-ai/core";
|
|
2
|
+
export interface QwenProviderOptions {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseURL?: string;
|
|
5
|
+
fetch?: typeof globalThis.fetch;
|
|
6
|
+
}
|
|
7
|
+
export interface QwenLanguageModelOptions {
|
|
8
|
+
top_p?: number;
|
|
9
|
+
frequency_penalty?: number;
|
|
10
|
+
presence_penalty?: number;
|
|
11
|
+
stop?: string | string[];
|
|
12
|
+
seed?: number;
|
|
13
|
+
user?: string;
|
|
14
|
+
tool_choice?: "none" | "auto" | "required" | {
|
|
15
|
+
type: "function";
|
|
16
|
+
function: {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare const createQwen: (options?: QwenProviderOptions) => CallableProviderAdapter & ProviderAdapter & {
|
|
23
|
+
rawFetch: typeof globalThis.fetch;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,uBAAuB,EAS5B,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC9F,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAsUD,eAAO,MAAM,UAAU,GACrB,UAAS,mBAAwB,KAChC,uBAAuB,GAAG,eAAe,GAAG;IAAE,QAAQ,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAejF,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { toJSONSchema } from "zod";
|
|
2
|
+
import { ConfigurationError, ProviderHTTPError, createProviderAdapter, normalizeFinishReason, streamSSE, withRetry, withTimeoutSignal } from "@zhivex-ai/core";
|
|
3
|
+
const capabilities = {
|
|
4
|
+
streaming: true,
|
|
5
|
+
tools: true,
|
|
6
|
+
structuredOutput: true,
|
|
7
|
+
jsonMode: true,
|
|
8
|
+
toolChoice: true,
|
|
9
|
+
parallelToolCalls: true,
|
|
10
|
+
vision: true,
|
|
11
|
+
files: false,
|
|
12
|
+
audioInput: false,
|
|
13
|
+
audioOutput: false,
|
|
14
|
+
embeddings: true,
|
|
15
|
+
reasoning: true,
|
|
16
|
+
webSearch: false
|
|
17
|
+
};
|
|
18
|
+
const jsonHeaders = (apiKey) => ({
|
|
19
|
+
"content-type": "application/json",
|
|
20
|
+
authorization: `Bearer ${apiKey}`
|
|
21
|
+
});
|
|
22
|
+
const parseJson = async (response) => {
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const body = await response.text();
|
|
25
|
+
throw new ProviderHTTPError(`Qwen request failed with status ${response.status}.`, response.status, {
|
|
26
|
+
responseBody: body
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return response.json();
|
|
30
|
+
};
|
|
31
|
+
const mapContentParts = (message) => {
|
|
32
|
+
const textParts = message.parts.filter((part) => part.type === "text");
|
|
33
|
+
const imageParts = message.parts.filter((part) => part.type === "image");
|
|
34
|
+
if (!imageParts.length) {
|
|
35
|
+
return textParts.map((part) => part.text).join("");
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
...textParts.map((part) => ({
|
|
39
|
+
type: "text",
|
|
40
|
+
text: part.text
|
|
41
|
+
})),
|
|
42
|
+
...imageParts.map((part) => ({
|
|
43
|
+
type: "image_url",
|
|
44
|
+
image_url: {
|
|
45
|
+
url: part.image
|
|
46
|
+
}
|
|
47
|
+
}))
|
|
48
|
+
];
|
|
49
|
+
};
|
|
50
|
+
const mapMessages = (messages) => messages.map((message) => {
|
|
51
|
+
if (message.role === "tool") {
|
|
52
|
+
const toolResult = message.parts.find((part) => part.type === "tool-result");
|
|
53
|
+
return {
|
|
54
|
+
role: "tool",
|
|
55
|
+
tool_call_id: toolResult?.type === "tool-result" ? toolResult.toolResult.toolCallId : undefined,
|
|
56
|
+
content: toolResult?.type === "tool-result"
|
|
57
|
+
? JSON.stringify(toolResult.toolResult.isError ? toolResult.toolResult.error : toolResult.toolResult.output)
|
|
58
|
+
: ""
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const toolCalls = message.parts
|
|
62
|
+
.filter((part) => part.type === "tool-call")
|
|
63
|
+
.map((part) => ({
|
|
64
|
+
id: part.toolCall.id,
|
|
65
|
+
type: "function",
|
|
66
|
+
function: {
|
|
67
|
+
name: part.toolCall.name,
|
|
68
|
+
arguments: JSON.stringify(part.toolCall.input)
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
const payload = {
|
|
72
|
+
role: message.role,
|
|
73
|
+
content: mapContentParts(message)
|
|
74
|
+
};
|
|
75
|
+
if (toolCalls.length) {
|
|
76
|
+
payload.tool_calls = toolCalls;
|
|
77
|
+
}
|
|
78
|
+
return payload;
|
|
79
|
+
});
|
|
80
|
+
const mapTools = (tools) => tools
|
|
81
|
+
? Object.values(tools).map((tool) => ({
|
|
82
|
+
type: "function",
|
|
83
|
+
function: {
|
|
84
|
+
name: tool.name,
|
|
85
|
+
description: tool.description,
|
|
86
|
+
parameters: toJSONSchema(tool.schema)
|
|
87
|
+
}
|
|
88
|
+
}))
|
|
89
|
+
: undefined;
|
|
90
|
+
const mapStructuredOutput = (input) => {
|
|
91
|
+
if (!input.structuredOutput || input.structuredOutput.mode !== "native") {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
type: "json_schema",
|
|
96
|
+
json_schema: {
|
|
97
|
+
name: input.structuredOutput.name ?? "response",
|
|
98
|
+
strict: true,
|
|
99
|
+
schema: toJSONSchema(input.structuredOutput.schema)
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const parseAssistantMessage = (message) => ({
|
|
104
|
+
role: "assistant",
|
|
105
|
+
parts: [
|
|
106
|
+
...(typeof message.content === "string" && message.content
|
|
107
|
+
? [{ type: "text", text: message.content }]
|
|
108
|
+
: []),
|
|
109
|
+
...((message.tool_calls ?? []).map((call) => ({
|
|
110
|
+
type: "tool-call",
|
|
111
|
+
toolCall: {
|
|
112
|
+
id: call.id,
|
|
113
|
+
name: call.function.name,
|
|
114
|
+
input: JSON.parse(call.function.arguments ?? "{}")
|
|
115
|
+
}
|
|
116
|
+
})) ?? [])
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
class QwenLanguageModel {
|
|
120
|
+
modelId;
|
|
121
|
+
apiKey;
|
|
122
|
+
baseURL;
|
|
123
|
+
fetcher;
|
|
124
|
+
provider = "qwen";
|
|
125
|
+
capabilities = capabilities;
|
|
126
|
+
constructor(modelId, apiKey, baseURL, fetcher) {
|
|
127
|
+
this.modelId = modelId;
|
|
128
|
+
this.apiKey = apiKey;
|
|
129
|
+
this.baseURL = baseURL;
|
|
130
|
+
this.fetcher = fetcher;
|
|
131
|
+
}
|
|
132
|
+
async generate(input) {
|
|
133
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
134
|
+
try {
|
|
135
|
+
const response = await withRetry(() => this.fetcher(`${this.baseURL}/chat/completions`, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
headers: jsonHeaders(this.apiKey),
|
|
138
|
+
signal,
|
|
139
|
+
body: JSON.stringify({
|
|
140
|
+
model: this.modelId,
|
|
141
|
+
messages: mapMessages(input.messages),
|
|
142
|
+
tools: mapTools(input.tools),
|
|
143
|
+
response_format: mapStructuredOutput(input),
|
|
144
|
+
temperature: input.temperature,
|
|
145
|
+
max_tokens: input.maxTokens,
|
|
146
|
+
stream: false,
|
|
147
|
+
...input.providerOptions
|
|
148
|
+
})
|
|
149
|
+
}), input);
|
|
150
|
+
const json = await parseJson(response);
|
|
151
|
+
const choice = json.choices?.[0];
|
|
152
|
+
const message = choice?.message ?? {};
|
|
153
|
+
const assistantMessage = parseAssistantMessage(message);
|
|
154
|
+
return {
|
|
155
|
+
messages: [assistantMessage],
|
|
156
|
+
text: assistantMessage.parts
|
|
157
|
+
.filter((part) => part.type === "text")
|
|
158
|
+
.map((part) => part.text)
|
|
159
|
+
.join(""),
|
|
160
|
+
finishReason: normalizeFinishReason(choice?.finish_reason),
|
|
161
|
+
providerFinishReason: choice?.finish_reason,
|
|
162
|
+
usage: {
|
|
163
|
+
inputTokens: json.usage?.prompt_tokens,
|
|
164
|
+
outputTokens: json.usage?.completion_tokens,
|
|
165
|
+
totalTokens: json.usage?.total_tokens
|
|
166
|
+
},
|
|
167
|
+
rawResponse: json
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
cleanup();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async stream(input) {
|
|
175
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
176
|
+
const response = await withRetry(() => this.fetcher(`${this.baseURL}/chat/completions`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: jsonHeaders(this.apiKey),
|
|
179
|
+
signal,
|
|
180
|
+
body: JSON.stringify({
|
|
181
|
+
model: this.modelId,
|
|
182
|
+
messages: mapMessages(input.messages),
|
|
183
|
+
tools: mapTools(input.tools),
|
|
184
|
+
response_format: mapStructuredOutput(input),
|
|
185
|
+
temperature: input.temperature,
|
|
186
|
+
max_tokens: input.maxTokens,
|
|
187
|
+
stream: true,
|
|
188
|
+
stream_options: { include_usage: true },
|
|
189
|
+
...input.providerOptions
|
|
190
|
+
})
|
|
191
|
+
}), input);
|
|
192
|
+
return (async function* () {
|
|
193
|
+
try {
|
|
194
|
+
const toolBuffers = new Map();
|
|
195
|
+
for await (const event of streamSSE(response)) {
|
|
196
|
+
if (event.data === "[DONE]") {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const json = JSON.parse(event.data);
|
|
200
|
+
const choice = json.choices?.[0];
|
|
201
|
+
const delta = choice?.delta;
|
|
202
|
+
if (delta?.content) {
|
|
203
|
+
yield { type: "text-delta", textDelta: delta.content };
|
|
204
|
+
}
|
|
205
|
+
for (const toolCall of delta?.tool_calls ?? []) {
|
|
206
|
+
const id = toolCall.id ?? `${toolCall.index}`;
|
|
207
|
+
const existing = toolBuffers.get(id) ?? {
|
|
208
|
+
name: toolCall.function?.name ?? "",
|
|
209
|
+
args: ""
|
|
210
|
+
};
|
|
211
|
+
existing.name ||= toolCall.function?.name ?? "";
|
|
212
|
+
existing.args += toolCall.function?.arguments ?? "";
|
|
213
|
+
toolBuffers.set(id, existing);
|
|
214
|
+
if (choice?.finish_reason === "tool_calls") {
|
|
215
|
+
yield {
|
|
216
|
+
type: "tool-call",
|
|
217
|
+
toolCall: {
|
|
218
|
+
id,
|
|
219
|
+
name: existing.name,
|
|
220
|
+
input: JSON.parse(existing.args || "{}")
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (choice?.finish_reason) {
|
|
226
|
+
yield {
|
|
227
|
+
type: "finish",
|
|
228
|
+
finishReason: normalizeFinishReason(choice.finish_reason),
|
|
229
|
+
providerFinishReason: choice.finish_reason,
|
|
230
|
+
usage: json.usage
|
|
231
|
+
? {
|
|
232
|
+
inputTokens: json.usage.prompt_tokens,
|
|
233
|
+
outputTokens: json.usage.completion_tokens,
|
|
234
|
+
totalTokens: json.usage.total_tokens
|
|
235
|
+
}
|
|
236
|
+
: undefined
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
cleanup();
|
|
243
|
+
}
|
|
244
|
+
})();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
class QwenEmbeddingModel {
|
|
248
|
+
modelId;
|
|
249
|
+
apiKey;
|
|
250
|
+
baseURL;
|
|
251
|
+
fetcher;
|
|
252
|
+
provider = "qwen";
|
|
253
|
+
capabilities = capabilities;
|
|
254
|
+
constructor(modelId, apiKey, baseURL, fetcher) {
|
|
255
|
+
this.modelId = modelId;
|
|
256
|
+
this.apiKey = apiKey;
|
|
257
|
+
this.baseURL = baseURL;
|
|
258
|
+
this.fetcher = fetcher;
|
|
259
|
+
}
|
|
260
|
+
async embed(input) {
|
|
261
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
262
|
+
try {
|
|
263
|
+
const response = await withRetry(() => this.fetcher(`${this.baseURL}/embeddings`, {
|
|
264
|
+
method: "POST",
|
|
265
|
+
headers: jsonHeaders(this.apiKey),
|
|
266
|
+
signal,
|
|
267
|
+
body: JSON.stringify({
|
|
268
|
+
model: this.modelId,
|
|
269
|
+
input: input.values
|
|
270
|
+
})
|
|
271
|
+
}), input);
|
|
272
|
+
const json = await parseJson(response);
|
|
273
|
+
return {
|
|
274
|
+
embeddings: json.data.map((entry) => entry.embedding),
|
|
275
|
+
usage: {
|
|
276
|
+
inputTokens: json.usage?.prompt_tokens,
|
|
277
|
+
totalTokens: json.usage?.total_tokens
|
|
278
|
+
},
|
|
279
|
+
rawResponse: json
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
cleanup();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export const createQwen = (options = {}) => {
|
|
288
|
+
const apiKey = options.apiKey ?? process.env.QWEN_API_KEY ?? process.env.DASHSCOPE_API_KEY;
|
|
289
|
+
if (!apiKey) {
|
|
290
|
+
throw new ConfigurationError("Missing Qwen API key.");
|
|
291
|
+
}
|
|
292
|
+
const baseURL = options.baseURL ?? "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
|
|
293
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
294
|
+
return createProviderAdapter({
|
|
295
|
+
name: "qwen",
|
|
296
|
+
languageModel: (modelId) => new QwenLanguageModel(modelId, apiKey, baseURL, fetcher),
|
|
297
|
+
embeddingModel: (modelId) => new QwenEmbeddingModel(modelId, apiKey, baseURL, fetcher),
|
|
298
|
+
rawFetch: fetcher
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,iBAAiB,EAYlB,MAAM,iBAAiB,CAAC;AAmBzB,MAAM,YAAY,GAAsB;IACtC,SAAS,EAAE,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C,KAAK,CAAC;IAElD,OAAO,qBAAqB,CAAC;QAC3B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;QACpF,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;QACtF,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhivex-ai/qwen",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Qwen adapter for Zhivex AI SDK.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18.18.0",
|
|
11
|
+
"bun": ">=1.3.7"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/Zhivex/zhivex-ai-sdk.git",
|
|
27
|
+
"directory": "packages/qwen"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/Zhivex/zhivex-ai-sdk#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Zhivex/zhivex-ai-sdk/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ai",
|
|
35
|
+
"sdk",
|
|
36
|
+
"qwen",
|
|
37
|
+
"llm",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@zhivex-ai/core": "^0.2.0",
|
|
45
|
+
"zod": "^4.3.6"
|
|
46
|
+
}
|
|
47
|
+
}
|