Merge branch 'screening'

This commit is contained in:
HugeFrog24
2024-10-22 19:29:40 +02:00
4 changed files with 5 additions and 4 deletions

5
bot.go
View File

@@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"log" "log"
"os"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -76,8 +75,8 @@ func NewBot(db *gorm.DB, config BotConfig, clock Clock, tgClient TelegramClient)
return nil, err return nil, err
} }
// Initialize Anthropic client // Use the per-bot Anthropic API key
anthropicClient := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY")) anthropicClient := anthropic.NewClient(config.AnthropicAPIKey)
b := &Bot{ b := &Bot{
db: db, db: db,

View File

@@ -20,6 +20,7 @@ type BotConfig struct {
SystemPrompts map[string]string `json:"system_prompts"` SystemPrompts map[string]string `json:"system_prompts"`
Active bool `json:"active"` // New field to control bot activity Active bool `json:"active"` // New field to control bot activity
OwnerTelegramID int64 `json:"owner_telegram_id"` OwnerTelegramID int64 `json:"owner_telegram_id"`
AnthropicAPIKey string `json:"anthropic_api_key"` // Add this line
} }
// Custom unmarshalling to handle anthropic.Model // Custom unmarshalling to handle anthropic.Model

View File

@@ -3,6 +3,7 @@
"active": false, "active": false,
"telegram_token": "YOUR_TELEGRAM_BOT_TOKEN", "telegram_token": "YOUR_TELEGRAM_BOT_TOKEN",
"owner_telegram_id": 111111111, "owner_telegram_id": 111111111,
"anthropic_api_key": "YOUR_SPECIFIC_ANTHROPIC_API_KEY",
"memory_size": 10, "memory_size": 10,
"messages_per_hour": 20, "messages_per_hour": 20,
"messages_per_day": 100, "messages_per_day": 100,

View File

@@ -25,7 +25,7 @@ func main() {
} }
// Check for required environment variables // Check for required environment variables
checkRequiredEnvVars() // checkRequiredEnvVars()
// Initialize database // Initialize database
db, err := initDB() db, err := initDB()