Who it is forA developer building a chat screen, terminal tool, or log viewer who wants output to appear as it is produced.
The problemWaiting for a full response before showing anything makes long answers feel slow and hides progress.
The outcomeText appears incrementally, and a running generation can be stopped from another goroutine with Context.Interrupt.
What you need first
- A Go toolchain installed on your machine
- A GGUF model file, such as model.gguf
- Enough memory for the model weights and KV cache, since the README notes wasm32 caps linear memory at 4 GiB
Steps
- Load a GGUF model and create a context as shown in the README example.
- Call Context.Stream instead of Generate and write each callback piece to your output.
- Run a second goroutine that calls Context.Interrupt to test stopping a long generation.
- Run
go run .and watch text print as it decodes. (inferred, check the README)
Prompt for your agent
In the Go project at <project-path>, use goccy/go-llama's Context.Stream to print each generated piece for the prompt "<prompt>" from <model-file>.gguf. Expected output: text that appears in pieces before the program finishes. Verify that calling Context.Interrupt from another goroutine stops the generation.
Caveat. The README describes the Stream callback and Interrupt method but does not show their full signatures, so check the package documentation on pkg.go.dev before relying on exact parameter types.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for goccy/go-llama and "Show model output token by token as it generates"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer