llm
llm copied to clipboard
Add `--input-style` feature for `prompt`
This adds --input-style for llm prompt, which lets the operator choose how input from stdin is passed to the prompt.
For llm prompt "describe this" and input from stdin as the input, the final prompts would be:
--input-style=prepend (the default, and the current behavior)
input from stdin describe this
--input-style=append
describe this input from stdin
--input-style=fence-prepend
```
input from stdin
```
describe this
--input-style=fence-append
describe this
```
input from stdin
```
Gentle review nudge, @simonw? 😅
Why would you need this?
I mean you can do:
(cat somefile; echo "describe this") | llm
or
(echo "describe this" ; cat somefile) | llm
or
(echo "describe this\n\n"'```' ; cat summarize.sh ; echo '```') | llm if you really want.
@Grynn Well, all of those are much less convenient to type and iterate upon than this option.
This just became even more relevant with this section of the GPT 4.1 prompting guide, emphasis mine:
Especially in long context usage, placement of instructions and context can impact performance. If you have long context in your prompt, ideally place your instructions at both the beginning and end of the provided context, as we found this to perform better than only above or below. If you’d prefer to only have your instructions once, then above the provided context works better than below.
I rebased this and added both and fence-both.
cc @simonw :)