recursive-llm-ts 2.0.4 → 2.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 +3 -3
- package/dist/bunpy-bridge.js +13 -1
- package/dist/rlm-bridge.js +23 -5
- package/package.json +1 -1
- package/scripts/install-python-deps.js +24 -11
package/README.md
CHANGED
|
@@ -16,15 +16,15 @@ npm install recursive-llm-ts
|
|
|
16
16
|
|
|
17
17
|
### Python Dependencies
|
|
18
18
|
|
|
19
|
-
**
|
|
19
|
+
Python dependencies are **automatically installed** via the `postinstall` script when you run `npm install` or `bun install`. The script will install `litellm`, `RestrictedPython`, and other required Python packages.
|
|
20
|
+
|
|
21
|
+
If automatic installation fails (e.g., pip not in PATH), you can manually install:
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
cd node_modules/recursive-llm-ts/recursive-llm
|
|
23
25
|
pip install -e .
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
This installs `litellm`, `RestrictedPython`, and other required Python packages.
|
|
27
|
-
|
|
28
28
|
#### For Bun Users
|
|
29
29
|
Bunpy is included as a dependency, so no additional installation needed.
|
|
30
30
|
|
package/dist/bunpy-bridge.js
CHANGED
|
@@ -79,8 +79,20 @@ class BunpyBridge {
|
|
|
79
79
|
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
80
80
|
const pythonSrcPath = path.join(pythonPackagePath, 'src');
|
|
81
81
|
sys.path.insert(0, pythonSrcPath);
|
|
82
|
-
//
|
|
82
|
+
// Try to import rlm, install deps if needed
|
|
83
83
|
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
|
+
}
|
|
84
96
|
this.rlmModule = this.python.import('rlm');
|
|
85
97
|
}
|
|
86
98
|
catch (error) {
|
package/dist/rlm-bridge.js
CHANGED
|
@@ -75,14 +75,32 @@ class PythoniaBridge {
|
|
|
75
75
|
'Note: pythonia only works with Node.js runtime, not Bun');
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
const rlmPath = path.join(__dirname, '..', 'recursive-llm', 'src', 'rlm');
|
|
78
|
+
const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
|
|
80
79
|
// Import sys module to add path
|
|
81
80
|
const sys = yield this.python('sys');
|
|
82
81
|
const pathList = yield sys.path;
|
|
83
|
-
yield pathList.insert(0, path.join(
|
|
84
|
-
//
|
|
85
|
-
|
|
82
|
+
yield pathList.insert(0, path.join(pythonPackagePath, 'src'));
|
|
83
|
+
// Try to import rlm, install deps if needed
|
|
84
|
+
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
|
+
this.rlmModule = yield this.python('rlm');
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
throw new Error('Failed to import rlm module. Python dependencies may not be installed.\n' +
|
|
101
|
+
`Run: pip install -e ${pythonPackagePath}\n` +
|
|
102
|
+
`Original error: ${error.message || error}`);
|
|
103
|
+
}
|
|
86
104
|
});
|
|
87
105
|
}
|
|
88
106
|
completion(model_1, query_1, context_1) {
|
package/package.json
CHANGED
|
@@ -8,24 +8,37 @@ const pyprojectPath = path.join(pythonPackagePath, 'pyproject.toml');
|
|
|
8
8
|
|
|
9
9
|
// Check if pyproject.toml exists
|
|
10
10
|
if (!fs.existsSync(pyprojectPath)) {
|
|
11
|
-
console.
|
|
12
|
-
|
|
11
|
+
console.warn('[recursive-llm-ts] Warning: pyproject.toml not found at', pyprojectPath);
|
|
12
|
+
console.warn('[recursive-llm-ts] Python dependencies will need to be installed manually');
|
|
13
|
+
process.exit(0); // Don't fail the install
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
console.log('Installing Python dependencies
|
|
16
|
-
console.log('Note: Python source is vendored with patches pre-applied.');
|
|
16
|
+
console.log('[recursive-llm-ts] Installing Python dependencies...');
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
|
+
// Check if pip is available
|
|
20
|
+
try {
|
|
21
|
+
execSync('pip --version', { stdio: 'pipe' });
|
|
22
|
+
} catch {
|
|
23
|
+
// Try pip3
|
|
24
|
+
execSync('pip3 --version', { stdio: 'pipe' });
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
// Install the Python package in editable mode
|
|
20
|
-
|
|
28
|
+
const pipCommand = process.platform === 'win32'
|
|
29
|
+
? `pip install -e "${pythonPackagePath}"`
|
|
30
|
+
: `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
|
|
31
|
+
|
|
32
|
+
execSync(pipCommand, {
|
|
21
33
|
stdio: 'inherit',
|
|
22
34
|
cwd: pythonPackagePath
|
|
23
35
|
});
|
|
24
|
-
console.log('✓ Python dependencies installed successfully');
|
|
36
|
+
console.log('[recursive-llm-ts] ✓ Python dependencies installed successfully');
|
|
25
37
|
} catch (error) {
|
|
26
|
-
console.
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
30
|
-
|
|
38
|
+
console.warn('[recursive-llm-ts] Warning: Failed to auto-install Python dependencies');
|
|
39
|
+
console.warn('[recursive-llm-ts] This is not critical - you can install them manually:');
|
|
40
|
+
console.warn(`[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && pip install -e .`);
|
|
41
|
+
console.warn('[recursive-llm-ts] Or ensure Python 3.9+ and pip are in your PATH');
|
|
42
|
+
// Don't fail the npm install - exit with 0
|
|
43
|
+
process.exit(0);
|
|
31
44
|
}
|