Skip to content

Commit 11fd63b

Browse files
committed
Support local models, non tool calling models, restricted commands
1 parent 69c6302 commit 11fd63b

File tree

6 files changed

+283
-181
lines changed

6 files changed

+283
-181
lines changed

interpreter_1/cli.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99
from .profiles import Profile
1010

1111

12+
def _parse_list_arg(value: str) -> list:
13+
"""Parse a comma-separated or JSON-formatted string into a list"""
14+
if not value:
15+
return []
16+
17+
# Try parsing as JSON first
18+
if value.startswith("["):
19+
try:
20+
import json
21+
22+
return json.loads(value)
23+
except json.JSONDecodeError:
24+
pass
25+
26+
# Fall back to comma-separated parsing
27+
return [item.strip() for item in value.split(",") if item.strip()]
28+
29+
1230
def _profile_to_arg_params(profile: Profile) -> Dict[str, Dict[str, Any]]:
1331
"""Convert Profile attributes to argparse parameter definitions"""
1432
return {
@@ -54,17 +72,20 @@ def _profile_to_arg_params(profile: Profile) -> Dict[str, Dict[str, Any]]:
5472
"tools": {
5573
"flags": ["--tools"],
5674
"default": profile.tools,
57-
"help": "Specify enabled tools (comma-separated)",
75+
"help": "Specify enabled tools (comma-separated or JSON list)",
76+
"type": _parse_list_arg,
5877
},
5978
"allowed_commands": {
6079
"flags": ["--allowed-commands"],
6180
"default": profile.allowed_commands,
62-
"help": "Specify allowed commands",
81+
"help": "Specify allowed commands (comma-separated or JSON list)",
82+
"type": _parse_list_arg,
6383
},
6484
"allowed_paths": {
6585
"flags": ["--allowed-paths"],
6686
"default": profile.allowed_paths,
67-
"help": "Specify allowed paths",
87+
"help": "Specify allowed paths (comma-separated or JSON list)",
88+
"type": _parse_list_arg,
6889
},
6990
"auto_run": {
7091
"flags": ["--auto-run", "-y"],

0 commit comments

Comments
 (0)