-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
42 lines (34 loc) · 914 Bytes
/
main.go
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
package main
import (
"encoding/json"
"flag"
"path/filepath"
"reflect"
"runtime"
"strings"
)
var (
model string
lang string
temperature float64
steps string
)
func init() {
flag.StringVar(&model, "model", defaultModel, "The model to use")
flag.Float64Var(&temperature, "temperature", defaultTemperature, "The temperature to use")
flag.StringVar(&lang, "lang", defaultLang, "The language to use")
flag.StringVar(&steps, "steps", "default", "The steps to run")
}
func main() {
flag.Parse()
ai := NewAI(model, temperature, lang)
rootPath, _ := filepath.Abs("./")
dbs := NewDBs(rootPath)
for _, step := range STEPS[steps] {
messages := step(ai, dbs)
pc := runtime.FuncForPC(reflect.ValueOf(step).Pointer())
funcName := strings.ReplaceAll(pc.Name(), "main.", "") // 去除包名
contents, _ := json.Marshal(messages)
dbs.logs.Set(funcName, string(contents))
}
}