-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
54 lines (44 loc) · 1.24 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"runtime/debug"
"github.com/gaurav-gosain/gollama/internal/utils"
_ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
)
func main() {
cfg := &gollamaConfig{}
cfg.ParseCLIArgs()
// if the version flag is set, print the version and exit
if cfg.Version {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
VERSION = info.Main.Version // set the version variable, if available
}
fmt.Println("Gollama version:", helpStyle.
Render(VERSION),
)
return
}
// any ollamanager related flags branch to the ollamanager process and exit
if cfg.Install || cfg.Manage || cfg.Monitor {
cfg.ollamanager()
return
}
// checks if the user has provided a model name and prompt
// if either the model name or prompt is empty, print an error and exit
if cfg.ModelName != "" || cfg.Prompt != "" {
if cfg.ModelName == "" {
utils.PrintError(fmt.Errorf("model name is required for generation"), true)
return
}
if cfg.Prompt == "" {
utils.PrintError(fmt.Errorf("prompt is required for generation"), true)
return
}
// calls the generate function to print the generated text to stdout
cfg.generate()
return
}
// the default case is to start the TUI
tui()
}