-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (28 loc) · 753 Bytes
/
main.go
File metadata and controls
33 lines (28 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/bit8bytes/beago/llm"
"github.com/bit8bytes/beago/llm/ollama"
"github.com/bit8bytes/beago/pipe"
)
// Usage: echo "What is the capital of France?" | go run .
//
// Tee splits the stream like a Unix tee(1): the LLM response flows to stdout
// while a copy is written to stderr for inspection.
// This is especially useful for debugging streaming handlers,
// as it allows you to see the output without interrupting the flow of the pipeline.
func main() {
model := ollama.New("gemma4:e4b", "")
ctx := context.Background()
err := pipe.Execute(ctx, os.Stdin, os.Stdout,
llm.Generate(model),
pipe.Tee(os.Stderr),
)
if err != nil {
log.Fatal(err)
}
fmt.Fprintln(os.Stdout)
}