-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (43 loc) · 1.06 KB
/
main.go
File metadata and controls
50 lines (43 loc) · 1.06 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"fmt"
"log"
"os"
"time"
react "github.com/bit8bytes/beago/agents"
"github.com/bit8bytes/beago/history"
jsonpkg "github.com/bit8bytes/beago/json"
"github.com/bit8bytes/beago/llm"
"github.com/bit8bytes/beago/llm/ollama"
"github.com/bit8bytes/beago/pipe"
"github.com/bit8bytes/beago/tools"
)
// Usage: echo "Write a README for the pipe package based on its source files" | go run .
func main() {
model := ollama.New("gemma4:e4b", "")
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
defer cancel()
shell := tools.Exec("man", "ls", "grep", "cat", "find", "sed", "go")
write := tools.WriteFile()
hist := history.New()
err := pipe.Execute(ctx, os.Stdin, os.Stdout,
react.Instructions(shell, write),
hist.System(),
pipe.Loop(
hist.Replay(),
llm.Generate(model),
jsonpkg.Extract(),
hist.Assistant(),
jsonpkg.Pretty(os.Stderr),
react.ParseAction(),
tools.Execute(shell, write),
hist.User(),
react.Done(),
),
)
if err != nil {
log.Fatal(err)
}
fmt.Fprintln(os.Stdout)
}