Skip to content

Commit aab36b0

Browse files
committed
Allow std input
We used to have this feature, got dropped recently accidentally, can do things like: `cat text_file_with_prompt.txt | ramalama run smollm:135m` or `cat some_doc | ramalama run smollm:135m Explain this document:` Signed-off-by: Eric Curtin <[email protected]>
1 parent 2526ab6 commit aab36b0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ramalama/chat.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,19 @@ def __init__(self, args):
7474
self.url = f"{args.url}/chat/completions"
7575

7676
def handle_args(self):
77-
if self.args.ARGS:
78-
self.default(" ".join(self.args.ARGS))
77+
prompt = " ".join(self.args.ARGS) if self.args.ARGS else None
78+
if not sys.stdin.isatty():
79+
stdin = sys.stdin.read()
80+
if prompt:
81+
prompt += f"\n\n{stdin}"
82+
else:
83+
prompt = stdin
84+
85+
if prompt:
86+
self.default(prompt)
7987
self.kills()
8088
return True
89+
8190
return False
8291

8392
def do_EOF(self, user_content):

0 commit comments

Comments
 (0)