Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions llm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def cli():


@cli.command(name="prompt")
@click.argument("prompt", required=False)
@click.argument("prompt", nargs=-1, required=False)
@click.option("-s", "--system", help="System prompt to use")
@click.option("model_id", "-m", "--model", help="Model to use", envvar="LLM_MODEL")
@click.option(
Expand Down Expand Up @@ -564,19 +564,17 @@ def prompt(
def read_prompt():
nonlocal prompt, schema

bits = []

# Is there extra prompt available on stdin?
stdin_prompt = None
if not sys.stdin.isatty():
stdin_prompt = sys.stdin.read()
bits.append(sys.stdin.read())

if stdin_prompt:
bits = [stdin_prompt]
if prompt:
bits.append(prompt)
prompt = " ".join(bits)
# Populate prompt from command line arguments
bits.extend(prompt)

if (
prompt is None
not bits
and not save
and sys.stdin.isatty()
and not attachments
Expand All @@ -585,8 +583,9 @@ def read_prompt():
and not fragments
):
# Hang waiting for input to stdin (unless --save)
prompt = sys.stdin.read()
return prompt
bits.append(sys.stdin.read())

return " ".join(bits)

if save:
# We are saving their prompt/system/etc to a new template
Expand Down