-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
72 lines (61 loc) · 1.47 KB
/
main.go
File metadata and controls
72 lines (61 loc) · 1.47 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"log"
"os"
"os/signal"
"syscall"
)
func main() {
// Initialize conversation cache
initConversationCache()
// Initialize activity tracking database
err := initActivityDatabase()
if err != nil {
log.Printf("Error initializing activity database: %v", err)
}
// Initialize classes table
err = initClassesTable()
if err != nil {
log.Printf("Error initializing classes table: %v", err)
}
if os.Getenv("GPT_TOKEN") != "" {
model := os.Getenv("GPT_MODEL")
if model == "" {
model = "not specified"
}
log.Printf("GPT_TOKEN is set, using model: %s", model)
initGPT()
}
// Initialize Gemini for image generation if API key is set
if os.Getenv("GEMINI_API_KEY") != "" {
err = initGemini()
if err != nil {
log.Printf("Error initializing Gemini: %v", err)
}
}
// Initialize Qdrant client if memory feature is enabled
if os.Getenv("MEMORY_GROUP_ID") != "" {
log.Println("[INFO] MEMORY_GROUP_ID is set, initializing Qdrant client...")
err = initQdrantClient()
if err != nil {
log.Fatalf("Error initializing Qdrant client: %v", err)
}
}
// Set up graceful shutdown
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
go func() {
<-sigChan
log.Println("[INFO] Shutdown signal received")
stopClassScheduler()
stopNewsScheduler()
SaveConversationsOnShutdown()
if db != nil {
db.Close()
}
os.Exit(0)
}()
// Start scheduled tasks
go scheduleActivityCleanup()
botGo()
}