Skip to content

Conversation

@gh-sandeep
Copy link

Summary

Fixes #1296

The --xl (--extract-last) and -x (--extract) command-line options were being completely overwritten when loading a template, instead of being combined with the template's settings. This meant that running:

llm --template my_template --xl

Would ignore the --xl flag if the template didn't have extract_last: true set.

The Bug

In cli.py, when a template is loaded, the code was:

extract = template_obj.extract
extract_last = template_obj.extract_last

This overwrites any CLI flags the user passed.

The Fix

Changed to use or to combine CLI flags with template settings:

extract = extract or template_obj.extract
extract_last = extract_last or template_obj.extract_last

Now the user can use --xl or -x with any template, regardless of whether the template has those options configured.

Testing

  • All 470 existing tests pass
  • Verified linting (ruff) and formatting (black) pass

Reproduction

Before this fix:

llm "Create an SVG of a pelican riding a bicycle." --save pelican
llm --template pelican --xl
# Returns full markdown response, ignoring --xl

After this fix:

llm --template pelican --xl
# Correctly extracts last fenced code block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--xl option does not work with templates

1 participant