beago brings the Unix philosophy to LLM applications: small, focused handlers connected by pipes. It is also inspired by the http.Handler and http.HandlerFunc (net/http). Each handler reads from an io.Reader, transforms the stream, and writes to an io.Writer.
Pipe is the core primitive: a Handler that reads io.Reader → transforms → writes io.Writer. Two combinators build on it:
- Do: chains handlers sequentially, connecting each output to the next input via
io.Pipe - Loop: runs a handler chain repeatedly, feeding each iteration's output as the next input; stops on
ErrDonevia context cancellation
Redact is a separate, composable layer: a Mask that anonymizes personal data to tokens before LLM processing and rehydrates them back after keeping sensitive values out of the model entirely. Redact is used in combination with Pipe and is safe for concurrent use.
package main
import (
"context"
"fmt"
"os"
"github.com/bit8bytes/beago/llm"
"github.com/bit8bytes/beago/llm/ollama"
"github.com/bit8bytes/beago/pipe"
)
// echo '[{"role":"user","content":"What is 2+2?"}]' | go run .
func main() {
client := ollama.New(ollama.WithModel("gemma4:e4b"))
pipe.Do(context.Background(), os.Stdin, os.Stdout,
llm.Generate(client),
)
fmt.Fprintln(os.Stdout)
}This example reads a prompt from stdin, sends it to an Ollama model, and streams the response to stdout.
More examples in /examples.
Contributions of any kind are welcome!