ai-world-sdk 1.0.3 → 1.0.6
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 +313 -772
- package/dist/__tests__/example.test.js +485 -46
- package/dist/base.d.ts +4 -3
- package/dist/chat_models/google.js +1 -1
- package/dist/chat_models/openai.js +1 -1
- package/dist/index.js +16 -31
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.sdkConfig = exports.VideoGenerationClient = exports.ImageGenerationClien
|
|
|
10
10
|
exports.createChatModel = createChatModel;
|
|
11
11
|
const openai_1 = require("./chat_models/openai");
|
|
12
12
|
const google_1 = require("./chat_models/google");
|
|
13
|
-
const anthropic_1 = require("./chat_models/anthropic");
|
|
14
13
|
const doubao_image_generation_1 = require("./doubao-image-generation");
|
|
15
14
|
Object.defineProperty(exports, "DoubaoImageGenerationClient", { enumerable: true, get: function () { return doubao_image_generation_1.DoubaoImageGenerationClient; } });
|
|
16
15
|
Object.defineProperty(exports, "ImageGenerationClient", { enumerable: true, get: function () { return doubao_image_generation_1.DoubaoImageGenerationClient; } });
|
|
@@ -32,8 +31,8 @@ var openai_2 = require("./chat_models/openai");
|
|
|
32
31
|
Object.defineProperty(exports, "ChatOpenAI", { enumerable: true, get: function () { return openai_2.ChatOpenAI; } });
|
|
33
32
|
var google_2 = require("./chat_models/google");
|
|
34
33
|
Object.defineProperty(exports, "ChatGoogleGenerativeAI", { enumerable: true, get: function () { return google_2.ChatGoogleGenerativeAI; } });
|
|
35
|
-
var
|
|
36
|
-
Object.defineProperty(exports, "ChatAnthropic", { enumerable: true, get: function () { return
|
|
34
|
+
var anthropic_1 = require("./chat_models/anthropic");
|
|
35
|
+
Object.defineProperty(exports, "ChatAnthropic", { enumerable: true, get: function () { return anthropic_1.ChatAnthropic; } });
|
|
37
36
|
/**
|
|
38
37
|
* Create a chat model instance based on model name
|
|
39
38
|
*/
|
|
@@ -49,33 +48,19 @@ function createChatModel(model, config) {
|
|
|
49
48
|
...config.headers,
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
else if (modelLower.startsWith("gemini")) {
|
|
67
|
-
return new google_1.ChatGoogleGenerativeAI({
|
|
68
|
-
modelName: model,
|
|
69
|
-
...finalConfig,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
else if (modelLower.startsWith("claude")) {
|
|
73
|
-
return new anthropic_1.ChatAnthropic({
|
|
74
|
-
modelName: model,
|
|
75
|
-
...finalConfig,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
throw new Error(`Unsupported model: ${model}. Supported models: gpt-*, o1-*, doubao-*, gemini-*, claude-*`);
|
|
51
|
+
switch (config.provider) {
|
|
52
|
+
case "doubao":
|
|
53
|
+
case "aihubmix":
|
|
54
|
+
return new openai_1.ChatOpenAI({
|
|
55
|
+
modelName: model,
|
|
56
|
+
...finalConfig,
|
|
57
|
+
});
|
|
58
|
+
case "gemini":
|
|
59
|
+
return new google_1.ChatGoogleGenerativeAI({
|
|
60
|
+
modelName: model,
|
|
61
|
+
...finalConfig,
|
|
62
|
+
});
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`Unsupported provider: ${config.provider}`);
|
|
80
65
|
}
|
|
81
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-world-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "TypeScript SDK for AI World Platform - Chat Models, Image Generation, and Video Generation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
"prepublishOnly": "npm run build",
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"test:watch": "jest --watch",
|
|
12
|
-
"test:non-stream": "jest -t 'ChatGoogleGenerativeAI - 非流式调用'",
|
|
13
|
-
"test:stream": "jest -t 'ChatGoogleGenerativeAI - 流式调用'",
|
|
12
|
+
"test:genimi-non-stream": "jest -t 'ChatGoogleGenerativeAI - 非流式调用'",
|
|
13
|
+
"test:genimi-stream": "jest -t 'ChatGoogleGenerativeAI - 流式调用'",
|
|
14
14
|
"test:factory": "jest -t '工厂函数'",
|
|
15
15
|
"test:bind": "jest -t 'bind 方法'",
|
|
16
16
|
"test:batch": "jest -t 'batch 方法'",
|
|
17
|
+
"test:openai": "jest -t 'ChatOpenAI - 基础测试'",
|
|
17
18
|
"test:aihubmix-no-stream": "jest -t 'aihubmix.com no stream'",
|
|
18
19
|
"test:aihubmix-stream": "jest -t 'aihubmix.com stream'",
|
|
19
20
|
"test:aihubmix-image": "jest -t 'aihubmix.com 图像生成'",
|