@blaxel/llamaindex 0.2.0-dev1
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/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +56 -0
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +30 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Beamlit, Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./model.js"), exports);
|
|
18
|
+
__exportStar(require("./tools.js"), exports);
|
package/dist/model.d.ts
ADDED
package/dist/model.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blModel = void 0;
|
|
4
|
+
const core_1 = require("@blaxel/core");
|
|
5
|
+
const anthropic_1 = require("@llamaindex/anthropic");
|
|
6
|
+
const mistral_1 = require("@llamaindex/mistral");
|
|
7
|
+
const openai_1 = require("@llamaindex/openai");
|
|
8
|
+
const blModel = async (model, options) => {
|
|
9
|
+
const url = `${core_1.settings.runUrl}/${core_1.settings.workspace}/models/${model}`;
|
|
10
|
+
const modelData = await (0, core_1.getModelMetadata)(model);
|
|
11
|
+
if (!modelData) {
|
|
12
|
+
throw new Error(`Model ${model} not found`);
|
|
13
|
+
}
|
|
14
|
+
await (0, core_1.authenticate)();
|
|
15
|
+
const type = modelData?.spec?.runtime?.type || "openai";
|
|
16
|
+
try {
|
|
17
|
+
if (type === "mistral") {
|
|
18
|
+
const llm = (0, mistral_1.mistral)({
|
|
19
|
+
// @ts-expect-error - We have dynamic model name, we don't want to check it here
|
|
20
|
+
model: modelData?.spec?.runtime?.model,
|
|
21
|
+
apiKey: core_1.settings.token,
|
|
22
|
+
baseURL: `${url}/v1`,
|
|
23
|
+
...options,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
...llm,
|
|
27
|
+
supportToolCall: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (type === "anthropic") {
|
|
31
|
+
const llm = (0, anthropic_1.anthropic)({
|
|
32
|
+
model: modelData?.spec?.runtime?.model,
|
|
33
|
+
session: new anthropic_1.AnthropicSession({
|
|
34
|
+
baseURL: url,
|
|
35
|
+
defaultHeaders: core_1.settings.headers,
|
|
36
|
+
}),
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
...llm,
|
|
41
|
+
supportToolCall: true,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return (0, openai_1.openai)({
|
|
45
|
+
model: modelData?.spec?.runtime?.model,
|
|
46
|
+
apiKey: core_1.settings.token,
|
|
47
|
+
baseURL: `${url}/v1`,
|
|
48
|
+
...options,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
(0, core_1.handleDynamicImportError)(err);
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.blModel = blModel;
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const blTool: (name: string) => Promise<import("llamaindex").FunctionTool<unknown, import("llamaindex").JSONValue | Promise<import("llamaindex").JSONValue>, object>[]>;
|
|
2
|
+
export declare const blTools: (names: string[]) => Promise<import("llamaindex").FunctionTool<unknown, import("llamaindex").JSONValue | Promise<import("llamaindex").JSONValue>, object>[]>;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blTools = exports.blTool = void 0;
|
|
4
|
+
// @ts-ignore - Required for build time due to missing types in 'llamaindex'
|
|
5
|
+
const core_1 = require("@blaxel/core");
|
|
6
|
+
const llamaindex_1 = require("llamaindex");
|
|
7
|
+
const blTool = async (name) => {
|
|
8
|
+
try {
|
|
9
|
+
const blaxelTool = await (0, core_1.getTool)(name);
|
|
10
|
+
const tools = blaxelTool.map((t) => {
|
|
11
|
+
// @ts-ignore - Required for build time due to missing types in 'llamaindex'
|
|
12
|
+
return (0, llamaindex_1.tool)(t.call.bind(t), {
|
|
13
|
+
name: t.name,
|
|
14
|
+
description: t.description,
|
|
15
|
+
parameters: t.inputSchema,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return tools;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
(0, core_1.handleDynamicImportError)(err);
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.blTool = blTool;
|
|
26
|
+
const blTools = async (names) => {
|
|
27
|
+
const toolArrays = await Promise.all(names.map(exports.blTool));
|
|
28
|
+
return toolArrays.flat();
|
|
29
|
+
};
|
|
30
|
+
exports.blTools = blTools;
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blaxel/llamaindex",
|
|
3
|
+
"version": "0.2.0-dev1",
|
|
4
|
+
"description": "Blaxel SDK for TypeScript",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Blaxel, INC (https://blaxel.ai)",
|
|
7
|
+
"homepage": "https://blaxel.ai",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/blaxel/toolkit/sdk-ts"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"blaxel",
|
|
17
|
+
"agent",
|
|
18
|
+
"mcp"
|
|
19
|
+
],
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./*": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/*.d.ts",
|
|
37
|
+
"default": "./dist/*.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/*.d.ts",
|
|
41
|
+
"default": "./dist/*.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"typesVersions": {
|
|
46
|
+
"*": {
|
|
47
|
+
"*": [
|
|
48
|
+
"./dist/*"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"dist"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@llamaindex/anthropic": "^0.3.4",
|
|
57
|
+
"@llamaindex/mistral": "^0.1.3",
|
|
58
|
+
"@llamaindex/openai": "^0.3.5",
|
|
59
|
+
"llamaindex": "^0.10.3",
|
|
60
|
+
"@blaxel/core": "0.2.0-dev1"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@eslint/js": "^9.26.0",
|
|
64
|
+
"typescript": "^5.0.0",
|
|
65
|
+
"typescript-eslint": "^8.31.1"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"lint": "eslint src/",
|
|
69
|
+
"build": "tsc"
|
|
70
|
+
}
|
|
71
|
+
}
|