recursive-llm-ts 2.0.1 → 2.0.3
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/dist/bridge-factory.js +16 -3
- package/dist/bunpy-bridge.js +21 -2
- package/package.json +2 -9
package/dist/bridge-factory.js
CHANGED
|
@@ -62,6 +62,7 @@ function detectRuntime() {
|
|
|
62
62
|
*/
|
|
63
63
|
function createBridge() {
|
|
64
64
|
return __awaiter(this, arguments, void 0, function* (bridgeType = 'auto') {
|
|
65
|
+
var _a;
|
|
65
66
|
let selectedBridge;
|
|
66
67
|
if (bridgeType === 'auto') {
|
|
67
68
|
const runtime = detectRuntime();
|
|
@@ -80,12 +81,24 @@ function createBridge() {
|
|
|
80
81
|
selectedBridge = bridgeType;
|
|
81
82
|
}
|
|
82
83
|
if (selectedBridge === 'bunpy') {
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
try {
|
|
85
|
+
const { BunpyBridge } = yield Promise.resolve().then(() => __importStar(require('./bunpy-bridge')));
|
|
86
|
+
return new BunpyBridge();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (bridgeType === 'auto' && ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('bunpy is not installed'))) {
|
|
90
|
+
console.warn('[recursive-llm-ts] bunpy not found, falling back to pythonia');
|
|
91
|
+
selectedBridge = 'pythonia';
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
85
97
|
}
|
|
86
|
-
|
|
98
|
+
if (selectedBridge === 'pythonia') {
|
|
87
99
|
const { PythoniaBridge } = yield Promise.resolve().then(() => __importStar(require('./rlm-bridge')));
|
|
88
100
|
return new PythoniaBridge();
|
|
89
101
|
}
|
|
102
|
+
throw new Error('Failed to initialize bridge');
|
|
90
103
|
});
|
|
91
104
|
}
|
package/dist/bunpy-bridge.js
CHANGED
|
@@ -74,9 +74,28 @@ class BunpyBridge {
|
|
|
74
74
|
throw new Error('bunpy is not installed. Install it with: bun add bunpy\n' +
|
|
75
75
|
'Note: bunpy only works with Bun runtime, not Node.js');
|
|
76
76
|
}
|
|
77
|
-
// Import sys
|
|
77
|
+
// Import sys and subprocess modules
|
|
78
78
|
const sys = this.python.import('sys');
|
|
79
|
-
const
|
|
79
|
+
const subprocess = this.python.import('subprocess');
|
|
80
|
+
const os = this.python.import('os');
|
|
81
|
+
// Install Python dependencies if not already installed
|
|
82
|
+
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
83
|
+
try {
|
|
84
|
+
// Check if litellm is importable
|
|
85
|
+
try {
|
|
86
|
+
this.python.import('litellm');
|
|
87
|
+
}
|
|
88
|
+
catch (_a) {
|
|
89
|
+
// Install dependencies using pip
|
|
90
|
+
const result = subprocess.run([sys.executable, '-m', 'pip', 'install', '-e', pythonPackagePath], { capture_output: true, text: true, check: true });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (installError) {
|
|
94
|
+
console.warn('[recursive-llm-ts] Failed to auto-install Python dependencies:', installError);
|
|
95
|
+
console.warn('[recursive-llm-ts] Please manually run: pip install -e', pythonPackagePath);
|
|
96
|
+
}
|
|
97
|
+
// Add Python source path
|
|
98
|
+
const pythonSrcPath = path.join(pythonPackagePath, 'src');
|
|
80
99
|
sys.path.insert(0, pythonSrcPath);
|
|
81
100
|
// Import the rlm module
|
|
82
101
|
this.rlmModule = this.python.import('rlm');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recursive-llm-ts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "TypeScript bridge for recursive-llm: Recursive Language Models for unbounded context processing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,16 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/jbeck018/recursive-llm-ts#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"bunpy": "^0.1.0",
|
|
40
41
|
"pythonia": "^1.2.6"
|
|
41
42
|
},
|
|
42
|
-
"peerDependencies": {
|
|
43
|
-
"bunpy": "^0.1.0"
|
|
44
|
-
},
|
|
45
|
-
"peerDependenciesMeta": {
|
|
46
|
-
"bunpy": {
|
|
47
|
-
"optional": true
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
43
|
"devDependencies": {
|
|
51
44
|
"@types/node": "^20.11.19",
|
|
52
45
|
"dotenv": "^16.4.5",
|