-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
83 lines (71 loc) · 2.36 KB
/
Copy pathmain.go
File metadata and controls
83 lines (71 loc) · 2.36 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
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"ai-therapy/clients"
"ai-therapy/config"
"ai-therapy/conversation"
"ai-therapy/memory"
"log"
)
func main() {
log.Println("AI Therapy - Starting therapy session...")
// Load configuration
cfg, err := config.Load()
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
log.Printf("Configuration loaded:")
log.Printf("- Ollama URL: %s", cfg.OllamaURL)
log.Printf("- Ollama Model: %s", cfg.OllamaModel)
log.Printf("- Claude API URL: %s", cfg.ClaudeAPIURL)
log.Printf("- Max Rounds: %d", cfg.MaxRounds)
log.Printf("- Delay Between Messages: %s", cfg.DelayBetweenMsg)
log.Printf("- Output File: %s", cfg.OutputFile)
// Initialize clients
ollamaClient := clients.NewOllamaClient(cfg.OllamaURL, cfg.OllamaModel)
claudeClient := clients.NewClaudeClient(cfg.ClaudeAPIKey, cfg.ClaudeAPIURL)
// Initialize memory bank if enabled
var memoryBank *memory.MemoryBank
if cfg.MemoryEnabled {
log.Println("Initializing memory bank...")
var err error
memoryBank, err = memory.NewMemoryBank(cfg.MemoryDataDir, cfg.OpenAIAPIKey, cfg.MemoryRetentionDays)
if err != nil {
log.Fatalf("Failed to initialize memory bank: %v", err)
}
// Display memory stats
stats, err := memoryBank.GetMemoryStats()
if err == nil {
log.Printf("Memory bank initialized: %d existing memories, retention: %d days",
stats.TotalMemories, cfg.MemoryRetentionDays)
}
} else {
log.Println("Memory system disabled")
}
// Test connections
log.Println("Testing Ollama connection...")
_, err = ollamaClient.SendMessage("Hello, this is a connection test. Please respond with 'Connection successful'.")
if err != nil {
log.Fatalf("Failed to connect to Ollama: %v", err)
}
log.Println("✓ Ollama connection successful")
log.Println("Testing Claude connection...")
_, err = claudeClient.SendMessage("Hello, this is a connection test. Please respond with 'Connection successful'.")
if err != nil {
log.Fatalf("Failed to connect to Claude: %v", err)
}
log.Println("✓ Claude connection successful")
// Initialize conversation manager
manager := conversation.NewManager(
ollamaClient,
claudeClient,
memoryBank,
cfg.MaxRounds,
cfg.DelayBetweenMsg,
cfg.OutputFile,
)
// Start the conversation
if err := manager.StartConversation(); err != nil {
log.Fatalf("Conversation failed: %v", err)
}
log.Println("Program completed successfully!")
}