From b1fe2e9857c9161c5fdfd5ad0d58a57b45454fd2 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 27 Feb 2025 16:51:43 -0800 Subject: [PATCH] sort_keys=False in --save, closes #798 --- llm/cli.py | 1 + tests/test_templates.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/llm/cli.py b/llm/cli.py index ebf57d0..4f1fc4f 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -379,6 +379,7 @@ def prompt( to_save, indent=4, default_flow_style=False, + sort_keys=False, ), "utf-8", ) diff --git a/tests/test_templates.py b/tests/test_templates.py index 381fb42..1abb8ef 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -97,10 +97,17 @@ def test_templates_list(templates_path, args): {"system": "write python", "extract": True}, None, ), - # So should schemas + # So should schemas (and should not sort properties) ( - ["--schema", '{"properties": {"name": {"type": "string"}}}'], - {"schema_object": {"properties": {"name": {"type": "string"}}}}, + [ + "--schema", + '{"properties": {"b": {"type": "string"}, "a": {"type": "string"}}}', + ], + { + "schema_object": { + "properties": {"b": {"type": "string"}, "a": {"type": "string"}} + } + }, None, ), ),