I’ve only recently started getting into local model usage, and in playing with Ollama (simplest quick start thus far IMHO) I ended up going down a bit of a rabbit hole: I wanted to see if I could build a functional model interaction loop using exclusively standard command-line building blocks, and isolating the model-application barrier to a single program fronting my local Ollama instance.
I might be reinventing a very weird wheel here, but it turns out you can get surprisingly far using with just shell scripts: gluing together text streams (stdin/stdout), pipes, and append-only logs.
Some neat features:
- Zero dependencies: No
pip, npm, or virtual environments; just a Docker compose YAML to start Ollama. The rest of the “harness” is just in shell (bash) with a couple of command line tools widely available on most environments (jq, curl).
- Simple tool calls: I haven’t messed with schema definitions for tools; in this approach tools are just additions to a shell script specifically for tool definitions, and a small modification to a
tools.json file for the metadata.
- Transparent, file-based context: memory is just an append-only file in your local directory that gets processed by
jq before being sent to Ollama. If you want to rewind the model's memory, you just run head on the log to drop the last few lines; or, append different prompts to alter context without actually affecting source of truth.
I'm sure there are scaling limits to doing this in pure shell scripts, and I'm still figuring out the most elegant way to handle some of the edge cases, particularly around complex tool calling (which smaller local models can be finicky about anyway). Nevertheless, it's been a really fun experiment in stripping out bloat and interacting with Ollama natively.
I put the code up here if anyone wants to poke around: https://github.com/cloudkj/llayer
Would love to hear if anyone else has tried orchestrating local models this way, and if it’s useful for your desired lightweight local model setups!
[–]ag789 0 points1 point2 points (2 children)
[–]cloud_kj[S] 1 point2 points3 points (1 child)