[GH-ISSUE #568] Enter multiline text via stdin in non-interactive mode #46768

Closed
opened 2026-04-27 23:56:25 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @tiborvass on GitHub (Sep 21, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/568

https://github.com/jmorganca/ollama/issues/169 only addressed interactive mode, but not stdin via non-interactive mode

cat multiline_file | ollama run llama2
Originally created by @tiborvass on GitHub (Sep 21, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/568 https://github.com/jmorganca/ollama/issues/169 only addressed interactive mode, but not stdin via non-interactive mode ``` cat multiline_file | ollama run llama2 ```
Author
Owner

@mxyng commented on GitHub (Sep 21, 2023):

Can you elaborate? Non-interactive multiline text was already possible since the shell handles the quotes

$ ollama run llama2 'this
quote> is
quote> a
quote> multiline
quote> prompt'
 Great, I'm ready to help! Please provide the text you would like me to read, and I will be happy to assist you.

<!-- gh-comment-id:1730500829 --> @mxyng commented on GitHub (Sep 21, 2023): Can you elaborate? Non-interactive multiline text was already possible since the shell handles the quotes ``` $ ollama run llama2 'this quote> is quote> a quote> multiline quote> prompt' Great, I'm ready to help! Please provide the text you would like me to read, and I will be happy to assist you. ```
Author
Owner

@tiborvass commented on GitHub (Sep 22, 2023):

@mxyng ah i see, I updated the issue to explain a little better hopefully!

<!-- gh-comment-id:1730521388 --> @tiborvass commented on GitHub (Sep 22, 2023): @mxyng ah i see, I updated the issue to explain a little better hopefully!
Author
Owner

@mxyng commented on GitHub (Sep 22, 2023):

Ah I see. This is by design. Each line of stdin is seen as a separate prompt. See #416 for more information.

If you're trying to ingest the entire file as a single prompt, an option could be as command line arguments:

$ ollama run llama2 "$(cat multiline_file)"
<!-- gh-comment-id:1730528895 --> @mxyng commented on GitHub (Sep 22, 2023): Ah I see. This is by design. Each line of stdin is seen as a separate prompt. See #416 for more information. If you're trying to ingest the entire file as a single prompt, an option could be as command line arguments: ``` $ ollama run llama2 "$(cat multiline_file)" ```
Author
Owner

@technovangelist commented on GitHub (Dec 4, 2023):

Looks like this issue was addressed by Mike's comment. I will go ahead and close it now. If you think there is anything we left out, reopen and we can address. Thanks for being part of this great community.

<!-- gh-comment-id:1839686968 --> @technovangelist commented on GitHub (Dec 4, 2023): Looks like this issue was addressed by Mike's comment. I will go ahead and close it now. If you think there is anything we left out, reopen and we can address. Thanks for being part of this great community.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#46768