recursive-llm-ts 1.0.1 → 1.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/README.md CHANGED
@@ -8,7 +8,13 @@ TypeScript bridge for [recursive-llm](https://github.com/grigori-gvadzabia/recur
8
8
  npm install recursive-llm-ts
9
9
  ```
10
10
 
11
- **That's it!** Python is bundled via [JSPyBridge](https://github.com/extremeheat/JSPyBridge) - no additional setup required.
11
+ ### Prerequisites
12
+
13
+ - **Node.js** (not Bun) - This package uses `pythonia` which requires Node.js internals
14
+ - **Python 3.9+** - Required for the underlying recursive-llm Python package
15
+ - **pip** - Python package manager
16
+
17
+ **Python dependencies are automatically installed** via the `postinstall` script when you `npm install`. The script will run `pip install -e` on the bundled Python package, installing `litellm`, `RestrictedPython`, and other dependencies.
12
18
 
13
19
  ## Usage
14
20
 
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "recursive-llm-ts",
3
- "version": "1.0.1",
3
+ "version": "1.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",
7
7
  "files": [
8
8
  "dist",
9
9
  "recursive-llm/src",
10
- "recursive-llm/pyproject.toml"
10
+ "recursive-llm/pyproject.toml",
11
+ "scripts/install-python-deps.js"
11
12
  ],
12
13
  "scripts": {
13
14
  "build": "tsc",
15
+ "postinstall": "node scripts/install-python-deps.js",
14
16
  "prepublishOnly": "npm run build",
15
17
  "release": "./scripts/release.sh",
16
18
  "start": "ts-node test/test.ts",
@@ -54,14 +54,31 @@ class RLM:
54
54
  _current_depth: Internal current depth tracker
55
55
  **llm_kwargs: Additional LiteLLM parameters
56
56
  """
57
- self.model = model
58
- self.recursive_model = recursive_model or model
59
- self.api_base = api_base
60
- self.api_key = api_key
61
- self.max_depth = max_depth
62
- self.max_iterations = max_iterations
57
+ # Patch for recursive-llm-ts bug where config is passed as 2nd positional arg
58
+ if isinstance(recursive_model, dict):
59
+ config = recursive_model
60
+ # Reset recursive_model default
61
+ self.recursive_model = config.get('recursive_model', model)
62
+ self.api_base = config.get('api_base', api_base)
63
+ self.api_key = config.get('api_key', api_key)
64
+ self.max_depth = config.get('max_depth', max_depth)
65
+ self.max_iterations = config.get('max_iterations', max_iterations)
66
+
67
+ # Extract other llm kwargs
68
+ excluded = {'recursive_model', 'api_base', 'api_key', 'max_depth', 'max_iterations'}
69
+ self.llm_kwargs = {k: v for k, v in config.items() if k not in excluded}
70
+ # Merge with any actual kwargs passed
71
+ self.llm_kwargs.update(llm_kwargs)
72
+ else:
73
+ self.recursive_model = recursive_model or model
74
+ self.api_base = api_base
75
+ self.api_key = api_key
76
+ self.max_depth = max_depth
77
+ self.max_iterations = max_iterations
78
+ self.llm_kwargs = llm_kwargs
79
+
63
80
  self._current_depth = _current_depth
64
- self.llm_kwargs = llm_kwargs
81
+ self.model = model
65
82
 
66
83
  self.repl = REPLExecutor()
67
84
 
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ const { execSync } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
7
+ const pyprojectPath = path.join(pythonPackagePath, 'pyproject.toml');
8
+
9
+ // Check if pyproject.toml exists
10
+ if (!fs.existsSync(pyprojectPath)) {
11
+ console.error('Error: pyproject.toml not found at', pyprojectPath);
12
+ process.exit(1);
13
+ }
14
+
15
+ console.log('Installing Python dependencies for recursive-llm...');
16
+
17
+ try {
18
+ // Install the Python package in editable mode
19
+ execSync(`pip install -e "${pythonPackagePath}"`, {
20
+ stdio: 'inherit',
21
+ cwd: pythonPackagePath
22
+ });
23
+ console.log('✓ Python dependencies installed successfully');
24
+ } catch (error) {
25
+ console.error('Failed to install Python dependencies.');
26
+ console.error('Please ensure Python 3.9+ and pip are installed.');
27
+ console.error('You can manually install by running:');
28
+ console.error(` cd ${pythonPackagePath} && pip install -e .`);
29
+ process.exit(1);
30
+ }