Skip to content

serebii4/ollama-prompt-python-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Ollama Python Runner

Simple Python wrapper around Ollama's /api/generate endpoint.

Requirements

  • Ollama running locally at http://localhost:11434
  • Python 3.8+

Configuration

  • OLLAMA_HOST defaults to http://localhost:11434 in ollama_run.py.
    • If you run Ollama on another machine or inside a container, update this value.
    • Make sure Ollama has "Expose Ollama on network" enabled if you're accessing it remotely.
  • MODEL is set to nous-hermes2:latest by default. Update it to any installed model.

To list available models:

curl -i http://localhost:11434/api/tags

To add/pull a model:

ollama pull llama3

(Replace llama3 with the model you want.)

Usage

Regular (non-streaming) output:

python ollama_run.py "hello"

Streaming output as the model responds:

python ollama_run.py --stream "explain docker like I'm 5 years old"

The script supports two modes:

  • Regular mode: waits for the full response, then prints it.
  • Stream mode: prints tokens as they arrive.

About

A Python CLI for local Ollama LLM inference, prompt completion, and streaming text generation via the /api/generate endpoint.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages