-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (41 loc) · 1.11 KB
/
main.go
File metadata and controls
50 lines (41 loc) · 1.11 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 (
"fmt"
"os"
"runtime/debug"
tea "github.com/charmbracelet/bubbletea"
"github.com/UnitVectorY-Labs/goauthorllm/internal/app"
"github.com/UnitVectorY-Labs/goauthorllm/internal/config"
"github.com/UnitVectorY-Labs/goauthorllm/internal/llm"
)
var Version = "dev"
func main() {
if Version == "dev" || Version == "" {
if bi, ok := debug.ReadBuildInfo(); ok {
if bi.Main.Version != "" && bi.Main.Version != "(devel)" {
Version = bi.Main.Version
}
}
}
args := os.Args[1:]
if len(args) == 1 && (args[0] == "--version" || args[0] == "-version") {
fmt.Println(Version)
return
}
cfg, err := config.Load(args)
if err != nil {
fmt.Fprintf(os.Stderr, "config error: %v\n", err)
os.Exit(1)
}
client := llm.NewClient(cfg.BaseURL, cfg.Model, cfg.APIKey, cfg.Timeout)
model, err := app.NewModel(cfg, client)
if err != nil {
fmt.Fprintf(os.Stderr, "startup error: %v\n", err)
os.Exit(1)
}
program := tea.NewProgram(&model, tea.WithAltScreen(), tea.WithMouseCellMotion())
if _, err := program.Run(); err != nil {
fmt.Fprintf(os.Stderr, "runtime error: %v\n", err)
os.Exit(1)
}
}