[GH-ISSUE #2740] Cannot pass file as suggested in example with windows #1647

Closed
opened 2026-04-12 11:36:16 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @mattjoyce on GitHub (Feb 25, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2740

Originally assigned to: @dhiltgen on GitHub.

ollama version is 0.1.27

Here's the example provided in the documentation.

ollama run llama2 "Summarize this file: $(cat README.md)"

Here's what I tried use the windows versions and the response

ollama run phi "summarize this file $(type 5_QGU5D7mLk.md)"
I'm sorry, but as an AI language model, I cannot provide a summary of any specific text without access to its contents.
Please provide me with more context or information about the text you would like me to summarize.

Originally created by @mattjoyce on GitHub (Feb 25, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2740 Originally assigned to: @dhiltgen on GitHub. ollama version is 0.1.27 Here's the example provided in the documentation. > ollama run llama2 "Summarize this file: $(cat README.md)" Here's what I tried use the windows versions and the response > ollama run phi "summarize this file $(type 5_QGU5D7mLk.md)" > I'm sorry, but as an AI language model, I cannot provide a summary of any specific text without access to its contents. > Please provide me with more context or information about the text you would like me to summarize.
Author
Owner

@easp commented on GitHub (Feb 25, 2024):

There may be something else going on with actually providing the file text in the prompt, but it's also possible that the model is getting hung up on the word "file" What if your prompt is "summarize this text," instead?

Also, another thing to try is passing the text using IO redirection, rather than as a long command line argument. On UNIX, these work ollama run phi "summarize this text" < textfile.md or cat textfile.md | ollama run phi "summarize this text"

<!-- gh-comment-id:1963007817 --> @easp commented on GitHub (Feb 25, 2024): There may be something else going on with actually providing the file text in the prompt, but it's also possible that the model is getting hung up on the word "file" What if your prompt is "summarize this text," instead? Also, another thing to try is passing the text using IO redirection, rather than as a long command line argument. On UNIX, these work `ollama run phi "summarize this text" < textfile.md` or `cat textfile.md | ollama run phi "summarize this text"`
Author
Owner

@mattjoyce commented on GitHub (Feb 25, 2024):

Piping in works, but does have an error ( https://github.com/ollama/ollama/issues/2698 )
Same for redirection, works but has the stdin handle error.

It does seem to expand the command line, when I use echo it works.

ollama run gemma:2b "$(echo what is the capital of australia)"
The capital of Australia is Canberra.

Canberra is the capital city of Australia and is located in the Australian Capital Territory.

so seem just when acting on a file

<!-- gh-comment-id:1963039047 --> @mattjoyce commented on GitHub (Feb 25, 2024): Piping in works, but does have an error ( https://github.com/ollama/ollama/issues/2698 ) Same for redirection, works but has the stdin handle error. It does seem to expand the command line, when I use echo it works. > ollama run gemma:2b "$(echo what is the capital of australia)" > The capital of Australia is Canberra. > > Canberra is the capital city of Australia and is located in the Australian Capital Territory. so seem just when acting on a file
Author
Owner

@dhiltgen commented on GitHub (Mar 11, 2024):

I think this is a shell problem. cmd doesn't support the syntax of subshelling with $(commands here) but powershell does.

cmd terminal:

> ollama run phi "summarize this document $(type .\README.md)"
 I'm sorry, as an AI language model, I cannot access external files or webpages to read and summarize them for
you. However, you can use a text summarization tool like Google Summarize or Microsoft's summarization feature in
Word to create a summary of the document. Simply copy and paste the entire text into the tool and it will generate
a concise summary for you

Powershell:

> ollama run phi "summarize this document $(type .\README.md)"
 The most relevant topic for the user's query is "Ollama" as it appears in all the given links and examples, along
with being mentioned as a language model on its own.
<!-- gh-comment-id:1989508714 --> @dhiltgen commented on GitHub (Mar 11, 2024): I think this is a shell problem. cmd doesn't support the syntax of subshelling with `$(commands here)` but powershell does. cmd terminal: ```cmd > ollama run phi "summarize this document $(type .\README.md)" I'm sorry, as an AI language model, I cannot access external files or webpages to read and summarize them for you. However, you can use a text summarization tool like Google Summarize or Microsoft's summarization feature in Word to create a summary of the document. Simply copy and paste the entire text into the tool and it will generate a concise summary for you ``` Powershell: ```powershell > ollama run phi "summarize this document $(type .\README.md)" The most relevant topic for the user's query is "Ollama" as it appears in all the given links and examples, along with being mentioned as a language model on its own. ```
Author
Owner

@mattjoyce commented on GitHub (Mar 12, 2024):

I agree, I get the same experience.

<!-- gh-comment-id:1990914081 --> @mattjoyce commented on GitHub (Mar 12, 2024): I agree, I get the same experience.
Author
Owner

@kerbymart commented on GitHub (Jun 17, 2024):

This works in my Windows Terminal cat <file> | ollama run <model> "prompt"

<!-- gh-comment-id:2173888537 --> @kerbymart commented on GitHub (Jun 17, 2024): This works in my Windows Terminal `cat <file> | ollama run <model> "prompt"`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1647