recursive-llm-ts 2.0.6 → 2.0.7
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/bunpy-bridge.js +24 -16
- package/dist/rlm-bridge.js +24 -16
- package/package.json +1 -1
package/dist/bunpy-bridge.js
CHANGED
|
@@ -62,6 +62,7 @@ class BunpyBridge {
|
|
|
62
62
|
}
|
|
63
63
|
ensureRLMModule() {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
var _a;
|
|
65
66
|
if (this.rlmModule)
|
|
66
67
|
return;
|
|
67
68
|
// Lazy load bunpy to avoid errors in Node.js environments
|
|
@@ -79,26 +80,33 @@ class BunpyBridge {
|
|
|
79
80
|
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
80
81
|
const pythonSrcPath = path.join(pythonPackagePath, 'src');
|
|
81
82
|
sys.path.insert(0, pythonSrcPath);
|
|
82
|
-
// Try to import rlm, install deps if
|
|
83
|
+
// Try to import rlm, install deps if import fails
|
|
83
84
|
try {
|
|
84
|
-
// First check if litellm is available
|
|
85
|
-
try {
|
|
86
|
-
this.python.import('litellm');
|
|
87
|
-
}
|
|
88
|
-
catch (_a) {
|
|
89
|
-
// litellm not found, install dependencies
|
|
90
|
-
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
91
|
-
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
92
|
-
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
93
|
-
execSync(pipCmd, { stdio: 'inherit' });
|
|
94
|
-
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
95
|
-
}
|
|
96
85
|
this.rlmModule = this.python.import('rlm');
|
|
97
86
|
}
|
|
98
87
|
catch (error) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
// If import fails, try installing dependencies
|
|
89
|
+
if ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('No module named')) {
|
|
90
|
+
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
91
|
+
try {
|
|
92
|
+
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
93
|
+
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
94
|
+
execSync(pipCmd, { stdio: 'inherit' });
|
|
95
|
+
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
96
|
+
// Try import again
|
|
97
|
+
this.rlmModule = this.python.import('rlm');
|
|
98
|
+
}
|
|
99
|
+
catch (installError) {
|
|
100
|
+
throw new Error('Failed to import rlm module after installing dependencies.\n' +
|
|
101
|
+
`Manual installation: pip install -e ${pythonPackagePath}\n` +
|
|
102
|
+
`Error: ${installError.message || installError}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
throw new Error('Failed to import rlm module.\n' +
|
|
107
|
+
`Run: pip install -e ${pythonPackagePath}\n` +
|
|
108
|
+
`Original error: ${error.message || error}`);
|
|
109
|
+
}
|
|
102
110
|
}
|
|
103
111
|
});
|
|
104
112
|
}
|
package/dist/rlm-bridge.js
CHANGED
|
@@ -62,6 +62,7 @@ class PythoniaBridge {
|
|
|
62
62
|
}
|
|
63
63
|
ensureRLMModule() {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
var _a;
|
|
65
66
|
if (this.rlmModule)
|
|
66
67
|
return;
|
|
67
68
|
// Lazy load pythonia to avoid errors in Bun environments
|
|
@@ -80,26 +81,33 @@ class PythoniaBridge {
|
|
|
80
81
|
const sys = yield this.python('sys');
|
|
81
82
|
const pathList = yield sys.path;
|
|
82
83
|
yield pathList.insert(0, path.join(pythonPackagePath, 'src'));
|
|
83
|
-
// Try to import rlm, install deps if
|
|
84
|
+
// Try to import rlm, install deps if import fails
|
|
84
85
|
try {
|
|
85
|
-
// First check if litellm is available
|
|
86
|
-
try {
|
|
87
|
-
yield this.python('litellm');
|
|
88
|
-
}
|
|
89
|
-
catch (_a) {
|
|
90
|
-
// litellm not found, install dependencies
|
|
91
|
-
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
92
|
-
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
93
|
-
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
94
|
-
execSync(pipCmd, { stdio: 'inherit' });
|
|
95
|
-
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
96
|
-
}
|
|
97
86
|
this.rlmModule = yield this.python('rlm');
|
|
98
87
|
}
|
|
99
88
|
catch (error) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
// If import fails, try installing dependencies
|
|
90
|
+
if ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('No module named')) {
|
|
91
|
+
console.log('[recursive-llm-ts] Installing Python dependencies (first time only)...');
|
|
92
|
+
try {
|
|
93
|
+
const { execSync } = yield Promise.resolve().then(() => __importStar(require('child_process')));
|
|
94
|
+
const pipCmd = `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
95
|
+
execSync(pipCmd, { stdio: 'inherit' });
|
|
96
|
+
console.log('[recursive-llm-ts] ✓ Python dependencies installed');
|
|
97
|
+
// Try import again
|
|
98
|
+
this.rlmModule = yield this.python('rlm');
|
|
99
|
+
}
|
|
100
|
+
catch (installError) {
|
|
101
|
+
throw new Error('Failed to import rlm module after installing dependencies.\n' +
|
|
102
|
+
`Manual installation: pip install -e ${pythonPackagePath}\n` +
|
|
103
|
+
`Error: ${installError.message || installError}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw new Error('Failed to import rlm module.\n' +
|
|
108
|
+
`Run: pip install -e ${pythonPackagePath}\n` +
|
|
109
|
+
`Original error: ${error.message || error}`);
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
});
|
|
105
113
|
}
|
package/package.json
CHANGED