-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.go
47 lines (38 loc) · 889 Bytes
/
utils.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
43
44
45
46
47
package main
import (
"encoding/base64"
"fmt"
"os"
"path/filepath"
"github.com/freesrz93/ask-gpt/consts"
)
const (
configFile = "config.yaml"
sessionDir = "sessions"
tempSession = "temp"
defaultRole = "default"
backendOpenai = "openai"
defaultPrompt = "You are a polymath. Your role is to provide accurate and clear answer to the user's questions. Include necessary technical details and terminologies in your answer."
AIPrefix = "Assistant: "
UserPrefix = "User: "
)
var CfgDir = func() string {
home, err := os.UserHomeDir()
if err != nil {
panic(err)
}
return filepath.Join(home, ".config", consts.AppName)
}()
func safeName(raw string) string {
return base64.URLEncoding.EncodeToString([]byte(raw))
}
func P(s string) {
_, _ = os.Stdout.WriteString(s)
}
func Pln() {
P("\n")
}
func PFatal(v any) {
P("error: " + fmt.Sprint(v))
os.Exit(1)
}