Pin that one override still asks, and say where the catalog and the entry go
This commit is contained in:
+2
-2
@@ -276,14 +276,14 @@ def read_models(saved):
|
||||
|
||||
def ask_model(name, saved):
|
||||
if not (sys.stdin.isatty() and sys.stdout.isatty()):
|
||||
print(f"{name} has no model in {saved}, and stdin or stdout is not a terminal to ask on; run it on a terminal or add \"{name}\": \"<model>\" to {saved}", file=sys.stderr)
|
||||
print(f"{name} has no model in {saved}, and stdin or stdout is not a terminal to ask on; run it on a terminal or add \"{name}\": \"<model>\" to the JSON object in {saved}", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
offered = catalog()
|
||||
print(f"\nThe model to run {name} on, saved in {saved}:", file=sys.stderr)
|
||||
for number, (model_id, label) in enumerate(offered, 1):
|
||||
print(f" {number}. {label} ({model_id})", file=sys.stderr)
|
||||
if not offered:
|
||||
print(" no model catalog cached; running claude once fills it", file=sys.stderr)
|
||||
print(" no model catalog cached in ~/.claude/cache/model-catalog", file=sys.stderr)
|
||||
while True:
|
||||
try:
|
||||
answer = input(f"{'A number, or any' if offered else 'A'} name claude --model takes: ").strip()
|
||||
|
||||
@@ -158,10 +158,13 @@ class ProjectModel(unittest.TestCase):
|
||||
with unittest.mock.patch("sys.stdin.isatty", return_value=False), self.assertRaises(SystemExit) as stopped:
|
||||
loop.project_model("/srv/a")
|
||||
self.assertEqual(stopped.exception.code, 2)
|
||||
self.assertIn(f'add "srv/a": "<model>" to {saved}', sys.stderr.getvalue())
|
||||
self.assertIn(f'add "srv/a": "<model>" to the JSON object in {saved}', sys.stderr.getvalue())
|
||||
self.assertFalse(saved.exists())
|
||||
with unittest.mock.patch.dict(os.environ, {"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": "w"}), unittest.mock.patch("sys.stdin.isatty", return_value=False):
|
||||
self.assertEqual(loop.project_model("/srv/a"), "")
|
||||
with unittest.mock.patch.dict(os.environ, {"LOOP_CLAUDE_JUDGE_MODEL": "j"}), unittest.mock.patch("sys.stdin.isatty", return_value=False), self.assertRaises(SystemExit) as stopped:
|
||||
loop.project_model("/srv/a")
|
||||
self.assertEqual(stopped.exception.code, 2)
|
||||
with (
|
||||
unittest.mock.patch("sys.stdin.isatty", return_value=True),
|
||||
unittest.mock.patch("sys.stdout.isatty", return_value=True),
|
||||
|
||||
Reference in New Issue
Block a user