-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (55 loc) · 1.51 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
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"flag"
"log"
"os"
"time"
)
func main() {
var (
modelFlag = flag.String("model", "zephyr", "llm model (e.g. mistral, gpt-4, ...)")
llmFlag = flag.String("llm", "ollama", "choose from openai or ollama")
tokenFlag = flag.String("token", "XYZ", "some llm require tokem authentication")
ai LLM
err error
)
flag.Parse()
switch *llmFlag {
case "ollama":
ai, err = newOllama(*modelFlag)
if err != nil {
log.Fatalf("Could not initialize AI: %v", err)
}
case "openai":
*tokenFlag, _ = os.LookupEnv("OPENAI_KEY")
ai, err = newOpenAI(*tokenFlag)
if err != nil {
log.Fatalf("Could not initialize AI: %v", err)
}
}
// TODO: insert your own bio
ai.bio("I am Luka Napotnik, the VP of Engineering, my primary focus is team output and influence, product quality, infrastructure cost, retention and people growth.")
gmail, err := newGmailProvider("credentials.json", 40)
if err != nil {
log.Fatalf("Could not initialize Gmail: %v", err)
}
d := newDesktop()
web := newWebAPI()
db := newLocalDB()
mbox := newMailbox(gmail, ai)
for {
if err := mbox.fetch(); err != nil {
log.Fatalf("Error fetching mail: %v", err)
}
mbox.summarize(func(from string, date string, subject string, message string, original string) {
h := hashMail(date, from, subject)
if db.wasRead(h) {
return
}
db.markRead(h)
d.notify(subject)
web.push(from, date, subject, highlightPriority(markdownMessage(message)), markdownMessage(original))
})
time.Sleep(10 * time.Minute)
}
}