@blaxel/langgraph 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.
@@ -0,0 +1,2 @@
1
+ import { LanguageModelLike } from "@langchain/core/language_models/base";
2
+ export declare const blModel: (model: string, options?: Record<string, unknown>) => Promise<LanguageModelLike>;
package/dist/model.js ADDED
@@ -0,0 +1,104 @@
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("@langchain/anthropic");
6
+ const cohere_1 = require("@langchain/cohere");
7
+ const deepseek_1 = require("@langchain/deepseek");
8
+ const openai_1 = require("@langchain/openai");
9
+ const cohere_ai_1 = require("cohere-ai");
10
+ const index_js_1 = require("./model/google-genai/index.js");
11
+ const xai_js_1 = require("./model/xai.js");
12
+ const blModel = async (model, options) => {
13
+ const url = `${core_1.settings.runUrl}/${core_1.settings.workspace}/models/${model}`;
14
+ const modelData = await (0, core_1.getModelMetadata)(model);
15
+ if (!modelData) {
16
+ throw new Error(`Model ${model} not found`);
17
+ }
18
+ await (0, core_1.authenticate)();
19
+ const type = modelData?.spec?.runtime?.type || "openai";
20
+ try {
21
+ if (type === "gemini") {
22
+ return new index_js_1.ChatGoogleGenerativeAI({
23
+ apiKey: core_1.settings.token,
24
+ model: modelData?.spec?.runtime?.model,
25
+ baseUrl: url,
26
+ ...options,
27
+ });
28
+ }
29
+ else if (type === "mistral") {
30
+ return new openai_1.ChatOpenAI({
31
+ apiKey: core_1.settings.token,
32
+ model: modelData?.spec?.runtime?.model,
33
+ configuration: {
34
+ baseURL: `${url}/v1`,
35
+ },
36
+ ...options,
37
+ });
38
+ }
39
+ else if (type === "cohere") {
40
+ return new cohere_1.ChatCohere({
41
+ apiKey: core_1.settings.token,
42
+ model: modelData?.spec?.runtime?.model,
43
+ client: new cohere_ai_1.CohereClient({
44
+ token: core_1.settings.token,
45
+ environment: url,
46
+ }),
47
+ });
48
+ }
49
+ else if (type === "deepseek") {
50
+ return new deepseek_1.ChatDeepSeek({
51
+ apiKey: core_1.settings.token,
52
+ model: modelData?.spec?.runtime?.model,
53
+ configuration: {
54
+ baseURL: `${url}/v1`,
55
+ },
56
+ ...options,
57
+ });
58
+ }
59
+ else if (type === "anthropic") {
60
+ return new anthropic_1.ChatAnthropic({
61
+ anthropicApiUrl: url,
62
+ model: modelData?.spec?.runtime?.model,
63
+ clientOptions: {
64
+ defaultHeaders: core_1.settings.headers,
65
+ },
66
+ ...options,
67
+ });
68
+ }
69
+ else if (type === "xai") {
70
+ return new xai_js_1.ChatXAI({
71
+ apiKey: core_1.settings.token,
72
+ configuration: {
73
+ baseURL: `${url}/v1`,
74
+ },
75
+ model: modelData?.spec?.runtime?.model,
76
+ ...options,
77
+ });
78
+ }
79
+ else if (type === "cerebras") {
80
+ // We don't use ChatCerebras because there is a problem with apiKey headers
81
+ return new openai_1.ChatOpenAI({
82
+ apiKey: core_1.settings.token,
83
+ model: modelData?.spec?.runtime?.model,
84
+ configuration: {
85
+ baseURL: `${url}/v1`,
86
+ },
87
+ ...options,
88
+ });
89
+ }
90
+ return new openai_1.ChatOpenAI({
91
+ apiKey: core_1.settings.token,
92
+ model: modelData?.spec?.runtime?.model,
93
+ configuration: {
94
+ baseURL: `${url}/v1`,
95
+ },
96
+ ...options,
97
+ });
98
+ }
99
+ catch (err) {
100
+ (0, core_1.handleDynamicImportError)(err);
101
+ throw err;
102
+ }
103
+ };
104
+ exports.blModel = blModel;
@@ -0,0 +1,14 @@
1
+ export declare function blTool(name: string): Promise<import("@langchain/core/tools").DynamicStructuredTool<import("zod").ZodObject<any, import("zod").UnknownKeysParam, import("zod").ZodTypeAny, {
2
+ [x: string]: any;
3
+ }, {
4
+ [x: string]: any;
5
+ }>, unknown, {
6
+ [x: string]: any;
7
+ }>[]>;
8
+ export declare function blTools(names: string[]): Promise<import("@langchain/core/tools").DynamicStructuredTool<import("zod").ZodObject<any, import("zod").UnknownKeysParam, import("zod").ZodTypeAny, {
9
+ [x: string]: any;
10
+ }, {
11
+ [x: string]: any;
12
+ }>, unknown, {
13
+ [x: string]: any;
14
+ }>[]>;
package/dist/tools.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blTool = blTool;
4
+ exports.blTools = blTools;
5
+ const core_1 = require("@blaxel/core");
6
+ const tools_1 = require("@langchain/core/tools");
7
+ async function blTool(name) {
8
+ try {
9
+ const blaxelTool = await (0, core_1.getTool)(name);
10
+ return blaxelTool.map((t) => (0, tools_1.tool)(t.call.bind(t), {
11
+ name: t.name,
12
+ description: t.description,
13
+ schema: t.inputSchema,
14
+ }));
15
+ }
16
+ catch (err) {
17
+ (0, core_1.handleDynamicImportError)(err);
18
+ throw err;
19
+ }
20
+ }
21
+ async function blTools(names) {
22
+ const toolArrays = await Promise.all(names.map(blTool));
23
+ return toolArrays.flat();
24
+ }
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@blaxel/langgraph",
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
+ "@google/generative-ai": "^0.24.1",
57
+ "@langchain/anthropic": "^0.3.20",
58
+ "@langchain/cohere": "^0.3.3",
59
+ "@langchain/core": "^0.3.51",
60
+ "@langchain/deepseek": "^0.0.1",
61
+ "@langchain/openai": "^0.5.10",
62
+ "cohere-ai": "^7.17.1",
63
+ "zod": "^3.24.3",
64
+ "zod-to-json-schema": "^3.24.5",
65
+ "@blaxel/core": "0.2.0-dev1"
66
+ },
67
+ "devDependencies": {
68
+ "@eslint/js": "^9.26.0",
69
+ "typescript": "^5.0.0",
70
+ "typescript-eslint": "^8.31.1"
71
+ },
72
+ "scripts": {
73
+ "lint": "eslint src/",
74
+ "build": "tsc"
75
+ }
76
+ }