[GH-ISSUE #9886] Allow entering prompt while model is loading #68529

Open
opened 2026-05-04 14:18:15 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @taladar on GitHub (Mar 19, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9886

It would be nice if an ollama run CLI command would allow the user to already enter a prompt while the model is loading.

This would allow the user to start the whole process including the prompt that made them start the ollama run command before switching away to do something else to wait for the model to load instead of having to remember what they wanted to ask when they get back to it after the model finishes loading.

Originally created by @taladar on GitHub (Mar 19, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9886 It would be nice if an ollama run CLI command would allow the user to already enter a prompt while the model is loading. This would allow the user to start the whole process including the prompt that made them start the ollama run command before switching away to do something else to wait for the model to load instead of having to remember what they wanted to ask when they get back to it after the model finishes loading.
GiteaMirror added the feature request label 2026-05-04 14:18:15 -05:00
Author
Owner

@rick-github commented on GitHub (Mar 19, 2025):

#!/usr/bin/env python3

import ollama
import argparse
import readline
import sys

parser = argparse.ArgumentParser()
parser.add_argument("model")
parser.add_argument("prompt", nargs='*')
args = parser.parse_args()

client = ollama.Client()
userprompt = ">>> " if sys.stdin.isatty() else ""

def chat(messages, prompt):
  messages.append({"role":"user", "content": prompt})
  response = client.chat(model=args.model, messages=messages, stream=True)
  m = ''
  for r in response:
    c = r['message']['content']
    print(c, end='', flush=True)
    m = m + c
  print()
  messages.append({"role": "assistant", "content": m})
  return messages

messages = []
if args.prompt:
  messages = chat(messages, " ".join(args.prompt))
while True:
  try:
    prompt = input(userprompt)
  except:
    print()
    break
  if prompt == "/bye":
    break
  messages = chat(messages, prompt)
$ ./ollama-prompt.py llama3.2 i am getting a coffee while i wait for you to load
Sounds like you're taking care of yourself until I'm ready. Go ahead and enjoy that coffee,
and I'll be here when you are! (Just a heads up, I should mention that I'm already loaded
and ready to chat, but I'll give you a moment if you'd like!)
>>> hello
It's nice to finally meet you. I hope your coffee is still hot and delicious after all this time.
How's your day going so far?
>>> /bye
<!-- gh-comment-id:2736394624 --> @rick-github commented on GitHub (Mar 19, 2025): ```python #!/usr/bin/env python3 import ollama import argparse import readline import sys parser = argparse.ArgumentParser() parser.add_argument("model") parser.add_argument("prompt", nargs='*') args = parser.parse_args() client = ollama.Client() userprompt = ">>> " if sys.stdin.isatty() else "" def chat(messages, prompt): messages.append({"role":"user", "content": prompt}) response = client.chat(model=args.model, messages=messages, stream=True) m = '' for r in response: c = r['message']['content'] print(c, end='', flush=True) m = m + c print() messages.append({"role": "assistant", "content": m}) return messages messages = [] if args.prompt: messages = chat(messages, " ".join(args.prompt)) while True: try: prompt = input(userprompt) except: print() break if prompt == "/bye": break messages = chat(messages, prompt) ``` ```console $ ./ollama-prompt.py llama3.2 i am getting a coffee while i wait for you to load Sounds like you're taking care of yourself until I'm ready. Go ahead and enjoy that coffee, and I'll be here when you are! (Just a heads up, I should mention that I'm already loaded and ready to chat, but I'll give you a moment if you'd like!) >>> hello It's nice to finally meet you. I hope your coffee is still hot and delicious after all this time. How's your day going so far? >>> /bye ```
Author
Owner

@taladar commented on GitHub (Mar 19, 2025):

Oh, it is completely possible to implement that myself of course in a custom wrapper of the ollama API, I just thought others might find it useful too.

<!-- gh-comment-id:2736400663 --> @taladar commented on GitHub (Mar 19, 2025): Oh, it is completely possible to implement that myself of course in a custom wrapper of the ollama API, I just thought others might find it useful too.
Author
Owner

@rick-github commented on GitHub (Mar 19, 2025):

The ollama cli is intentionally simple. Added functionality is achieved with wrappers or using a more featureful client.

<!-- gh-comment-id:2736411458 --> @rick-github commented on GitHub (Mar 19, 2025): The ollama cli is intentionally simple. Added functionality is achieved with wrappers or using a more featureful [client](https://github.com/ollama/ollama?tab=readme-ov-file#community-integrations).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#68529