@vectorx/ai-sdk 0.6.1 → 0.7.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/lib/ai.js +4 -1
- package/lib/models/Qwen25T2iPreview/index.js +1 -3
- package/lib/models/Qwen3VlPlus/index.d.ts +78 -0
- package/lib/models/Qwen3VlPlus/index.js +121 -0
- package/lib/models/QwenImageEdit/index.d.ts +1 -1
- package/lib/models/QwenImageEdit/index.js +2 -2
- package/lib/models/index.d.ts +11 -1
- package/lib/models/index.js +99 -1
- package/package.json +2 -2
package/lib/ai.js
CHANGED
|
@@ -57,8 +57,9 @@ class AI {
|
|
|
57
57
|
switch (model) {
|
|
58
58
|
case models.MultiModalModelName.QwenImage:
|
|
59
59
|
return new models.ReActModel(new models.QwenImageModel(this.request, models.QwenImageModel.BASE_URL, this.tokenManager));
|
|
60
|
+
case models.MultiModalModelName.QwenImageEditPlus:
|
|
60
61
|
case models.MultiModalModelName.QwenImageEdit:
|
|
61
|
-
return new models.ReActModel(new models.QwenImageEditModel(this.request, models.QwenImageEditModel.BASE_URL, this.tokenManager));
|
|
62
|
+
return new models.ReActModel(new models.QwenImageEditModel(this.request, models.QwenImageEditModel.BASE_URL, this.tokenManager, model));
|
|
62
63
|
case models.MultiModalModelName.WanxSketchToImageLite:
|
|
63
64
|
return new models.ReActModel(new models.WanxSketchToImageLiteModel(this.request, models.WanxSketchToImageLiteModel.BASE_URL, this.tokenManager));
|
|
64
65
|
case models.MultiModalModelName.QwenStyleRepaintV1:
|
|
@@ -67,6 +68,8 @@ class AI {
|
|
|
67
68
|
return new models.ReActModel(new models.Qwen25T2iPreviewModel(this.request, models.Qwen25T2iPreviewModel.BASE_URL, this.tokenManager));
|
|
68
69
|
case models.MultiModalModelName.QwenVlMax:
|
|
69
70
|
return new models.ReActModel(new models.QwenVlMax(this.request, models.QwenVlMax.BASE_URL, model, this.tokenManager));
|
|
71
|
+
case models.MultiModalModelName.Qwen3VlPlus:
|
|
72
|
+
return new models.ReActModel(new models.Qwen3VlPlus(this.request, models.Qwen3VlPlus.BASE_URL, model, this.tokenManager));
|
|
70
73
|
case models.MultiModalModelName.QwenDocTurbo:
|
|
71
74
|
return new models.ReActModel(new models.QwenDocTurbo(this.request, models.QwenDocTurbo.BASE_URL, model, this.tokenManager));
|
|
72
75
|
default:
|
|
@@ -123,9 +123,7 @@ class Qwen25T2iPreviewModel extends Chat_1.SimpleChatModel {
|
|
|
123
123
|
if (texts.length === 0)
|
|
124
124
|
throw new Error("Qwen25T2iPreview 需要提供至少一个文本提示词");
|
|
125
125
|
const prompt = texts.join(" ");
|
|
126
|
-
const parameters = Object.assign({
|
|
127
|
-
if (negativePrompt) {
|
|
128
|
-
}
|
|
126
|
+
const parameters = Object.assign({ n: 1, prompt_extend: false, watermark: false }, data.parameters);
|
|
129
127
|
return {
|
|
130
128
|
parameters,
|
|
131
129
|
model: this.modelName,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IAbstractRequest } from "@vectorx/ai-types";
|
|
2
|
+
import type { DoGenerateOutput, DoStreamOutput, ImageUrlContent, ModelRequestOptions, ReqOptions, TextContent } from "../../model-type";
|
|
3
|
+
import type { TokenManager } from "../../tokenManager";
|
|
4
|
+
import { SimpleChatModel } from "../Chat";
|
|
5
|
+
import type { MultiModalModelName } from "../index";
|
|
6
|
+
export interface Qwen3VlPlusMessage {
|
|
7
|
+
role: "system" | "user" | "assistant";
|
|
8
|
+
content: string | Array<TextContent | ImageUrlContent>;
|
|
9
|
+
}
|
|
10
|
+
export interface Qwen3VlPlusParameters {
|
|
11
|
+
seed?: number;
|
|
12
|
+
temperature?: number;
|
|
13
|
+
top_p?: number;
|
|
14
|
+
max_tokens?: number;
|
|
15
|
+
n?: number;
|
|
16
|
+
stream?: boolean;
|
|
17
|
+
stop?: string | string[];
|
|
18
|
+
frequency_penalty?: number;
|
|
19
|
+
presence_penalty?: number;
|
|
20
|
+
user?: string;
|
|
21
|
+
enable_search?: boolean;
|
|
22
|
+
enable_thinking?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface Qwen3VlPlusAPIInput extends Qwen3VlPlusParameters {
|
|
25
|
+
model: string;
|
|
26
|
+
messages: Qwen3VlPlusMessage[];
|
|
27
|
+
stream?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface Qwen3VlPlusResponse {
|
|
30
|
+
id: string;
|
|
31
|
+
object: string;
|
|
32
|
+
created: number;
|
|
33
|
+
model: string;
|
|
34
|
+
choices: Array<{
|
|
35
|
+
index: number;
|
|
36
|
+
message: {
|
|
37
|
+
role: string;
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
40
|
+
finish_reason: string;
|
|
41
|
+
}>;
|
|
42
|
+
usage: {
|
|
43
|
+
prompt_tokens: number;
|
|
44
|
+
completion_tokens: number;
|
|
45
|
+
total_tokens: number;
|
|
46
|
+
output_tokens?: number;
|
|
47
|
+
input_tokens?: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface Qwen3VlPlusStreamChunk {
|
|
51
|
+
id: string;
|
|
52
|
+
object: string;
|
|
53
|
+
created: number;
|
|
54
|
+
model: string;
|
|
55
|
+
choices: Array<{
|
|
56
|
+
index: number;
|
|
57
|
+
delta: {
|
|
58
|
+
role?: string;
|
|
59
|
+
content?: string;
|
|
60
|
+
};
|
|
61
|
+
finish_reason: string | null;
|
|
62
|
+
}>;
|
|
63
|
+
usage?: {
|
|
64
|
+
prompt_tokens: number;
|
|
65
|
+
completion_tokens: number;
|
|
66
|
+
total_tokens: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export declare class Qwen3VlPlus extends SimpleChatModel {
|
|
70
|
+
static BASE_URL: string;
|
|
71
|
+
modelName: MultiModalModelName;
|
|
72
|
+
constructor(req: IAbstractRequest, baseUrl: string, modelName: MultiModalModelName, tokenManager: TokenManager);
|
|
73
|
+
protected modelRequest(data: Qwen3VlPlusAPIInput, options?: ReqOptions): Promise<ReadableStream<Uint8Array> | Promise<unknown>>;
|
|
74
|
+
protected normalizeResponse(response: Qwen3VlPlusResponse): DoGenerateOutput;
|
|
75
|
+
doGenerate(data: ModelRequestOptions, options?: ReqOptions): Promise<DoGenerateOutput>;
|
|
76
|
+
doStream(data: ModelRequestOptions, options?: ReqOptions): Promise<DoStreamOutput>;
|
|
77
|
+
private convertToQwen3VlPlusRequestOptions;
|
|
78
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Qwen3VlPlus = void 0;
|
|
13
|
+
const model_type_1 = require("../../model-type");
|
|
14
|
+
const stream_1 = require("../../stream");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
const Chat_1 = require("../Chat");
|
|
17
|
+
const defaultParameters = {
|
|
18
|
+
max_tokens: 2000,
|
|
19
|
+
temperature: 1.0,
|
|
20
|
+
top_p: 1.0,
|
|
21
|
+
frequency_penalty: 0.0,
|
|
22
|
+
presence_penalty: 0.0,
|
|
23
|
+
stream: false,
|
|
24
|
+
enable_thinking: false,
|
|
25
|
+
enable_search: false,
|
|
26
|
+
n: 1,
|
|
27
|
+
};
|
|
28
|
+
class Qwen3VlPlus extends Chat_1.SimpleChatModel {
|
|
29
|
+
constructor(req, baseUrl, modelName, tokenManager) {
|
|
30
|
+
super(req, baseUrl, "compatible-mode/v1/chat/completions", tokenManager);
|
|
31
|
+
this.modelName = modelName;
|
|
32
|
+
}
|
|
33
|
+
modelRequest(data, options) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const fetchHeaders = yield this.createAuthHeaders(options === null || options === void 0 ? void 0 : options.headers);
|
|
36
|
+
const { data: responseData, header } = (yield this.req.fetch({
|
|
37
|
+
method: "post",
|
|
38
|
+
headers: Object.assign({}, fetchHeaders),
|
|
39
|
+
body: JSON.stringify(data),
|
|
40
|
+
url: `${this.baseUrl}/${this.subUrl}`,
|
|
41
|
+
stream: Boolean(data.stream),
|
|
42
|
+
}));
|
|
43
|
+
return (0, utils_1.handleResponseData)(responseData, header);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
normalizeResponse(response) {
|
|
47
|
+
var _a, _b, _c, _d;
|
|
48
|
+
const choice = (_a = response.choices) === null || _a === void 0 ? void 0 : _a[0];
|
|
49
|
+
const message = choice === null || choice === void 0 ? void 0 : choice.message;
|
|
50
|
+
return {
|
|
51
|
+
id: response.id,
|
|
52
|
+
object: response.object,
|
|
53
|
+
created: response.created,
|
|
54
|
+
model: response.model,
|
|
55
|
+
log_id: response.id,
|
|
56
|
+
error: "",
|
|
57
|
+
code: 0,
|
|
58
|
+
choices: [
|
|
59
|
+
{
|
|
60
|
+
index: (choice === null || choice === void 0 ? void 0 : choice.index) || 0,
|
|
61
|
+
message: {
|
|
62
|
+
id: response.id,
|
|
63
|
+
role: (message === null || message === void 0 ? void 0 : message.role) || "assistant",
|
|
64
|
+
type: "answer",
|
|
65
|
+
content: (message === null || message === void 0 ? void 0 : message.content) || "",
|
|
66
|
+
reasoning_content: "",
|
|
67
|
+
},
|
|
68
|
+
finish_reason: (choice === null || choice === void 0 ? void 0 : choice.finish_reason) || "stop",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
usage: {
|
|
72
|
+
prompt_tokens: ((_b = response.usage) === null || _b === void 0 ? void 0 : _b.prompt_tokens) || 0,
|
|
73
|
+
completion_tokens: ((_c = response.usage) === null || _c === void 0 ? void 0 : _c.completion_tokens) || 0,
|
|
74
|
+
knowledge_tokens: 0,
|
|
75
|
+
reasoning_tokens: 0,
|
|
76
|
+
total_tokens: ((_d = response.usage) === null || _d === void 0 ? void 0 : _d.total_tokens) || 0,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
doGenerate(data, options) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const qwen3VlPlusData = this.convertToQwen3VlPlusRequestOptions(data);
|
|
83
|
+
const requestData = Object.assign(Object.assign({}, qwen3VlPlusData), { stream: false });
|
|
84
|
+
const res = yield this.modelRequest(requestData, options);
|
|
85
|
+
return this.normalizeResponse(res);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
doStream(data, options) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const qwen3VlPlusData = this.convertToQwen3VlPlusRequestOptions(data);
|
|
91
|
+
const requestData = Object.assign(Object.assign({}, qwen3VlPlusData), { stream: true });
|
|
92
|
+
const _stream = (yield this.modelRequest(requestData, options));
|
|
93
|
+
const stream = (0, stream_1.toPolyfillReadable)(_stream);
|
|
94
|
+
const standardStream = (0, stream_1.intoStandardStream)(stream);
|
|
95
|
+
return (0, stream_1.createAsyncIterable)(standardStream);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
convertToQwen3VlPlusRequestOptions(data) {
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
const clamp = (value, min, max, defaultValue) => value !== undefined ? Math.max(min, Math.min(max, value)) : defaultValue;
|
|
101
|
+
const messages = (data.messages || []).map((msg) => ({
|
|
102
|
+
role: msg.role,
|
|
103
|
+
content: Array.isArray(msg.content) ? (0, model_type_1.filterContentByTypes)(msg.content, ["text", "image_url"]) : msg.content,
|
|
104
|
+
}));
|
|
105
|
+
return {
|
|
106
|
+
model: this.modelName,
|
|
107
|
+
messages,
|
|
108
|
+
temperature: clamp(data.temperature, 0, 2, defaultParameters.temperature),
|
|
109
|
+
top_p: clamp(data.top_p, 0, 1, defaultParameters.top_p),
|
|
110
|
+
frequency_penalty: clamp(data.frequency_penalty, -2, 2, defaultParameters.frequency_penalty),
|
|
111
|
+
presence_penalty: clamp(data.presence_penalty, -2, 2, defaultParameters.presence_penalty),
|
|
112
|
+
max_tokens: clamp(data.max_tokens, 1, Number.POSITIVE_INFINITY, defaultParameters.max_tokens),
|
|
113
|
+
n: clamp(data.n, 1, Number.POSITIVE_INFINITY, defaultParameters.n),
|
|
114
|
+
stream: (_a = data.stream) !== null && _a !== void 0 ? _a : defaultParameters.stream,
|
|
115
|
+
enable_search: (_b = data.enable_search) !== null && _b !== void 0 ? _b : defaultParameters.enable_search,
|
|
116
|
+
enable_thinking: (_c = data.enable_thinking) !== null && _c !== void 0 ? _c : defaultParameters.enable_thinking,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.Qwen3VlPlus = Qwen3VlPlus;
|
|
121
|
+
Qwen3VlPlus.BASE_URL = "https://dashscope.aliyuncs.com";
|
|
@@ -66,7 +66,7 @@ export declare class QwenImageEditModel extends SimpleChatModel {
|
|
|
66
66
|
static BASE_URL: string;
|
|
67
67
|
static SUB_GENERATION_URL: string;
|
|
68
68
|
modelName: string;
|
|
69
|
-
constructor(req: IAbstractRequest, baseUrl: string, tokenManager: TokenManager);
|
|
69
|
+
constructor(req: IAbstractRequest, baseUrl: string, tokenManager: TokenManager, modelName?: string);
|
|
70
70
|
protected normalizeStandardImageEditCompletion(res: QwenImageEditAPIResponse, fallbackModel: string): DoGenerateOutput;
|
|
71
71
|
protected coverModelRequestToQwenInput(data: ModelRequestOptions & {
|
|
72
72
|
parameters?: QwenImageEditParameters;
|
|
@@ -14,9 +14,9 @@ const stream_1 = require("../../stream");
|
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
15
|
const Chat_1 = require("../Chat");
|
|
16
16
|
class QwenImageEditModel extends Chat_1.SimpleChatModel {
|
|
17
|
-
constructor(req, baseUrl, tokenManager) {
|
|
17
|
+
constructor(req, baseUrl, tokenManager, modelName = "qwen-image-edit") {
|
|
18
18
|
super(req, baseUrl, QwenImageEditModel.SUB_GENERATION_URL, tokenManager);
|
|
19
|
-
this.modelName =
|
|
19
|
+
this.modelName = modelName;
|
|
20
20
|
}
|
|
21
21
|
normalizeStandardImageEditCompletion(res, fallbackModel) {
|
|
22
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefaultSimpleModel } from "./Default";
|
|
2
|
+
import { Qwen3VlPlus } from "./Qwen3VlPlus";
|
|
2
3
|
import { Qwen25T2iPreviewModel } from "./Qwen25T2iPreview";
|
|
3
4
|
import { QwenDocTurbo } from "./QwenDocTurbo";
|
|
4
5
|
import { QwenImageModel } from "./QwenImage";
|
|
@@ -20,12 +21,14 @@ export declare enum ModelName {
|
|
|
20
21
|
export declare enum MultiModalModelName {
|
|
21
22
|
QvqMaxLatest = "qvq-max-latest",
|
|
22
23
|
QwenVlMax = "qwen-vl-max",
|
|
24
|
+
Qwen3VlPlus = "qwen3-vl-plus",
|
|
23
25
|
QwenDocTurbo = "qwen-doc-turbo",
|
|
24
26
|
QwenOmniTurboRealtime = "qwen-omni-turbo-realtime",
|
|
25
27
|
Wanx21T2iPlus = "wanx2.1-t2i-plus",
|
|
26
28
|
Wanx21T2iTurbo = "wanx2.1-t2i-turbo",
|
|
27
29
|
QwenImage = "qwen-image",
|
|
28
30
|
QwenImageEdit = "qwen-image-edit",
|
|
31
|
+
QwenImageEditPlus = "qwen-image-edit-plus",
|
|
29
32
|
Qwen25T2iPreview = "wan2.5-i2i-preview",
|
|
30
33
|
WanxSketchToImageLite = "wanx-sketch-to-image-lite",
|
|
31
34
|
QwenStyleRepaintV1 = "wanx-style-repaint-v1"
|
|
@@ -40,12 +43,14 @@ export declare const modelName: {
|
|
|
40
43
|
"qwen-vl-ocr": string;
|
|
41
44
|
"qvq-max-latest": string;
|
|
42
45
|
"qwen-vl-max": string;
|
|
46
|
+
"qwen3-vl-plus": string;
|
|
43
47
|
"qwen-doc-turbo": string;
|
|
44
48
|
"qwen-omni-turbo-realtime": string;
|
|
45
49
|
"wanx2.1-t2i-plus": string;
|
|
46
50
|
"wanx2.1-t2i-turbo": string;
|
|
47
51
|
"qwen-image": string;
|
|
48
52
|
"qwen-image-edit": string;
|
|
53
|
+
"qwen-image-edit-plus": string;
|
|
49
54
|
"wan2.5-i2i-preview": string;
|
|
50
55
|
"wanx-sketch-to-image-lite": string;
|
|
51
56
|
"wanx-style-repaint-v1": string;
|
|
@@ -53,4 +58,9 @@ export declare const modelName: {
|
|
|
53
58
|
export declare const isValidModel: (model: ModelName | MultiModalModelName) => model is ModelName | MultiModalModelName;
|
|
54
59
|
export declare const isMultiModalModel: (model: ModelName | MultiModalModelName) => model is MultiModalModelName;
|
|
55
60
|
declare const toolMap: Map<string, Function>;
|
|
56
|
-
export
|
|
61
|
+
export declare const MODEL_REQUEST_PATTERNS: Map<string, {
|
|
62
|
+
domain: string;
|
|
63
|
+
paths: string[];
|
|
64
|
+
}>;
|
|
65
|
+
export declare function isModelRequestUrl(url: string): boolean;
|
|
66
|
+
export { DefaultSimpleModel, QwenDocTurbo, ReActModel, toolMap, WanxSketchToImageLiteModel, QwenImageModel, QwenImageEditModel, Qwen25T2iPreviewModel, Qwen3VlPlus, QwenVlMax, QwenStyleRepaintV1Model, };
|
package/lib/models/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QwenStyleRepaintV1Model = exports.QwenVlMax = exports.Qwen25T2iPreviewModel = exports.QwenImageEditModel = exports.QwenImageModel = exports.WanxSketchToImageLiteModel = exports.toolMap = exports.ReActModel = exports.QwenDocTurbo = exports.DefaultSimpleModel = exports.isMultiModalModel = exports.isValidModel = exports.modelName = exports.MultiModalModelName = exports.ModelName = void 0;
|
|
3
|
+
exports.QwenStyleRepaintV1Model = exports.QwenVlMax = exports.Qwen3VlPlus = exports.Qwen25T2iPreviewModel = exports.QwenImageEditModel = exports.QwenImageModel = exports.WanxSketchToImageLiteModel = exports.toolMap = exports.ReActModel = exports.QwenDocTurbo = exports.DefaultSimpleModel = exports.MODEL_REQUEST_PATTERNS = exports.isMultiModalModel = exports.isValidModel = exports.modelName = exports.MultiModalModelName = exports.ModelName = void 0;
|
|
4
|
+
exports.isModelRequestUrl = isModelRequestUrl;
|
|
4
5
|
const Default_1 = require("./Default");
|
|
5
6
|
Object.defineProperty(exports, "DefaultSimpleModel", { enumerable: true, get: function () { return Default_1.DefaultSimpleModel; } });
|
|
7
|
+
const Qwen3VlPlus_1 = require("./Qwen3VlPlus");
|
|
8
|
+
Object.defineProperty(exports, "Qwen3VlPlus", { enumerable: true, get: function () { return Qwen3VlPlus_1.Qwen3VlPlus; } });
|
|
6
9
|
const Qwen25T2iPreview_1 = require("./Qwen25T2iPreview");
|
|
7
10
|
Object.defineProperty(exports, "Qwen25T2iPreviewModel", { enumerable: true, get: function () { return Qwen25T2iPreview_1.Qwen25T2iPreviewModel; } });
|
|
8
11
|
const QwenDocTurbo_1 = require("./QwenDocTurbo");
|
|
@@ -34,12 +37,14 @@ var MultiModalModelName;
|
|
|
34
37
|
(function (MultiModalModelName) {
|
|
35
38
|
MultiModalModelName["QvqMaxLatest"] = "qvq-max-latest";
|
|
36
39
|
MultiModalModelName["QwenVlMax"] = "qwen-vl-max";
|
|
40
|
+
MultiModalModelName["Qwen3VlPlus"] = "qwen3-vl-plus";
|
|
37
41
|
MultiModalModelName["QwenDocTurbo"] = "qwen-doc-turbo";
|
|
38
42
|
MultiModalModelName["QwenOmniTurboRealtime"] = "qwen-omni-turbo-realtime";
|
|
39
43
|
MultiModalModelName["Wanx21T2iPlus"] = "wanx2.1-t2i-plus";
|
|
40
44
|
MultiModalModelName["Wanx21T2iTurbo"] = "wanx2.1-t2i-turbo";
|
|
41
45
|
MultiModalModelName["QwenImage"] = "qwen-image";
|
|
42
46
|
MultiModalModelName["QwenImageEdit"] = "qwen-image-edit";
|
|
47
|
+
MultiModalModelName["QwenImageEditPlus"] = "qwen-image-edit-plus";
|
|
43
48
|
MultiModalModelName["Qwen25T2iPreview"] = "wan2.5-i2i-preview";
|
|
44
49
|
MultiModalModelName["WanxSketchToImageLite"] = "wanx-sketch-to-image-lite";
|
|
45
50
|
MultiModalModelName["QwenStyleRepaintV1"] = "wanx-style-repaint-v1";
|
|
@@ -54,12 +59,14 @@ exports.modelName = {
|
|
|
54
59
|
[ModelName.QwenVlOcr]: "qwen-vl-ocr",
|
|
55
60
|
[MultiModalModelName.QvqMaxLatest]: "qvq-max-latest",
|
|
56
61
|
[MultiModalModelName.QwenVlMax]: "qwen-vl-max",
|
|
62
|
+
[MultiModalModelName.Qwen3VlPlus]: "qwen3-vl-plus",
|
|
57
63
|
[MultiModalModelName.QwenDocTurbo]: "qwen-doc-turbo",
|
|
58
64
|
[MultiModalModelName.QwenOmniTurboRealtime]: "qwen-omni-turbo-realtime",
|
|
59
65
|
[MultiModalModelName.Wanx21T2iPlus]: "wanx2.1-t2i-plus",
|
|
60
66
|
[MultiModalModelName.Wanx21T2iTurbo]: "wanx2.1-t2i-turbo",
|
|
61
67
|
[MultiModalModelName.QwenImage]: "qwen-image",
|
|
62
68
|
[MultiModalModelName.QwenImageEdit]: "qwen-image-edit",
|
|
69
|
+
[MultiModalModelName.QwenImageEditPlus]: "qwen-image-edit-plus",
|
|
63
70
|
[MultiModalModelName.Qwen25T2iPreview]: "wan2.5-i2i-preview",
|
|
64
71
|
[MultiModalModelName.WanxSketchToImageLite]: "wanx-sketch-to-image-lite",
|
|
65
72
|
[MultiModalModelName.QwenStyleRepaintV1]: "wanx-style-repaint-v1",
|
|
@@ -75,3 +82,94 @@ const isMultiModalModel = (model) => {
|
|
|
75
82
|
exports.isMultiModalModel = isMultiModalModel;
|
|
76
83
|
const toolMap = new Map();
|
|
77
84
|
exports.toolMap = toolMap;
|
|
85
|
+
exports.MODEL_REQUEST_PATTERNS = new Map([
|
|
86
|
+
["default", { domain: "*", paths: ["conversation/chat"] }],
|
|
87
|
+
[
|
|
88
|
+
"qwen-image",
|
|
89
|
+
{
|
|
90
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
91
|
+
paths: [
|
|
92
|
+
"api/v1/services/aigc/multimodal-generation/generation",
|
|
93
|
+
"api/v1/services/aigc/text2image/image-synthesis",
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
"qwen-image-edit",
|
|
99
|
+
{
|
|
100
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
101
|
+
paths: ["api/v1/services/aigc/multimodal-generation/generation"],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"wanx-sketch-to-image-lite",
|
|
106
|
+
{
|
|
107
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
108
|
+
paths: ["api/v1/services/aigc/image2image/image-synthesis"],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"wanx-style-repaint-v1",
|
|
113
|
+
{
|
|
114
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
115
|
+
paths: ["api/v1/services/aigc/image-generation/generation"],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
"wan2.5-i2i-preview",
|
|
120
|
+
{
|
|
121
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
122
|
+
paths: ["api/v1/services/aigc/image2image/image-synthesis"],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
"qwen-vl-max",
|
|
127
|
+
{
|
|
128
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
129
|
+
paths: ["compatible-mode/v1/chat/completions"],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
"qwen3-vl-plus",
|
|
134
|
+
{
|
|
135
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
136
|
+
paths: ["compatible-mode/v1/chat/completions"],
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
"qwen-doc-turbo",
|
|
141
|
+
{
|
|
142
|
+
domain: "https://dashscope.aliyuncs.com",
|
|
143
|
+
paths: ["api/v1/services/aigc/text-generation/generation", "compatible-mode/v1/chat/completions"],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
]);
|
|
147
|
+
function isModelRequestUrl(url) {
|
|
148
|
+
if (!url)
|
|
149
|
+
return false;
|
|
150
|
+
try {
|
|
151
|
+
const urlObj = new URL(url);
|
|
152
|
+
const fullPath = urlObj.pathname;
|
|
153
|
+
for (const [, { domain, paths }] of exports.MODEL_REQUEST_PATTERNS) {
|
|
154
|
+
if (domain !== "*" && urlObj.origin !== domain) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
for (const path of paths) {
|
|
158
|
+
if (fullPath.includes(path) || fullPath.endsWith(path)) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
catch (_a) {
|
|
166
|
+
for (const [, { paths }] of exports.MODEL_REQUEST_PATTERNS) {
|
|
167
|
+
for (const path of paths) {
|
|
168
|
+
if (url.includes(path)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorx/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Cloud AI SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@mattiasbuelens/web-streams-adapter": "^0.1.0",
|
|
25
|
-
"@vectorx/ai-types": "0.
|
|
25
|
+
"@vectorx/ai-types": "0.6.0",
|
|
26
26
|
"langfuse": "^3.38.4",
|
|
27
27
|
"openai": "^4.103.0",
|
|
28
28
|
"text-encoding-shim": "^1.0.5",
|