From bfe72635b7098721b954cf1c39b70eec36927e9d Mon Sep 17 00:00:00 2001 From: HugeFrog24 <62775760+HugeFrog24@users.noreply.github.com> Date: Thu, 7 May 2026 15:40:12 +0200 Subject: [PATCH] Go update --- anthropic.go | 2 +- bot.go | 12 ++++++------ config.go | 26 +++++++++++++------------- config/default.json | 2 +- elevenlabs.go | 4 ++-- go-telegram-bot.exe | Bin 27689951 -> 27689941 bytes go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/anthropic.go b/anthropic.go index bcca490..7710209 100644 --- a/anthropic.go +++ b/anthropic.go @@ -90,7 +90,7 @@ func (b *Bot) getAnthropicResponse(ctx context.Context, messages []anthropic.Mes for i, msg := range messages { for _, content := range msg.Content { if content.Type == anthropic.MessagesContentTypeText { - InfoLogger.Printf("Message %d: Role=%v, Text=%v", i, msg.Role, content.Text) + InfoLogger.Printf("Message %d: Role=%v, Text=%v", i, msg.Role, *content.Text) } } } diff --git a/bot.go b/bot.go index bf68a5d..bdc1074 100644 --- a/bot.go +++ b/bot.go @@ -15,10 +15,10 @@ import ( ) type Bot struct { - tgBot TelegramClient - db *gorm.DB - anthropicClient *anthropic.Client - chatMemories map[int64]*ChatMemory + tgBot TelegramClient + db *gorm.DB + anthropicClient *anthropic.Client + chatMemories map[int64]*ChatMemory memorySize int chatMemoriesMu sync.RWMutex config BotConfig @@ -84,8 +84,8 @@ func NewBot(db *gorm.DB, config BotConfig, clock Clock, tgClient TelegramClient) anthropicClient := anthropic.NewClient(config.AnthropicAPIKey) b := &Bot{ - db: db, - anthropicClient: anthropicClient, + db: db, + anthropicClient: anthropicClient, chatMemories: make(map[int64]*ChatMemory), memorySize: config.MemorySize, config: config, diff --git a/config.go b/config.go index 122c1b0..6bd994b 100644 --- a/config.go +++ b/config.go @@ -11,23 +11,23 @@ import ( ) type BotConfig struct { - ID string `json:"id"` - TelegramToken string `json:"telegram_token"` - MemorySize int `json:"memory_size"` - MessagePerHour int `json:"messages_per_hour"` - MessagePerDay int `json:"messages_per_day"` - TempBanDuration string `json:"temp_ban_duration"` - Model anthropic.Model `json:"model"` - Temperature *float32 `json:"temperature,omitempty"` // Controls creativity vs determinism (0.0-1.0) - SystemPrompts map[string]string `json:"system_prompts"` - Active bool `json:"active"` - OwnerTelegramID int64 `json:"owner_telegram_id"` - AnthropicAPIKey string `json:"anthropic_api_key"` + ID string `json:"id"` + TelegramToken string `json:"telegram_token"` + MemorySize int `json:"memory_size"` + MessagePerHour int `json:"messages_per_hour"` + MessagePerDay int `json:"messages_per_day"` + TempBanDuration string `json:"temp_ban_duration"` + Model anthropic.Model `json:"model"` + Temperature *float32 `json:"temperature,omitempty"` // Controls creativity vs determinism (0.0-1.0) + SystemPrompts map[string]string `json:"system_prompts"` + Active bool `json:"active"` + OwnerTelegramID int64 `json:"owner_telegram_id"` + AnthropicAPIKey string `json:"anthropic_api_key"` ElevenLabsAPIKey string `json:"elevenlabs_api_key"` ElevenLabsVoiceID string `json:"elevenlabs_voice_id"` ElevenLabsModel string `json:"elevenlabs_model"` DebugScreening bool `json:"debug_screening"` // Enable detailed screening logs - ConfigFilePath string `json:"-"` // Set at load time; not serialized + ConfigFilePath string `json:"-"` // Set at load time; not serialized } // Custom unmarshalling to handle anthropic.Model diff --git a/config/default.json b/config/default.json index 62c2d91..1065d94 100644 --- a/config/default.json +++ b/config/default.json @@ -16,7 +16,7 @@ "debug_screening": false, "system_prompts": { "default": "You are a helpful assistant.", - "custom_instructions": "You are texting through a limited Telegram interface with 15-word maximum. Write like texting a friend - use shorthand, skip grammar, use slang/abbreviations. System cuts off anything longer than 15 words.\n\n- Your name is Atom.\n- The user you're talking to has username '{username}' and display name '{firstname} {lastname}'.\n- User's language preference: '{language}'\n- User is a {premium_status}\n- It's currently {time_context} in your timezone. Use appropriate time-based greetings and address the user by name.\n- If a user asks about buying apples, inform them that we don't sell apples.\n- When asked for a joke, tell a clean, family-friendly joke about programming or technology.\n- If someone inquires about our services, explain that we offer AI-powered chatbot solutions.\n- For any questions about pricing, direct users to contact our sales team at sales@example.com.\n- If asked about your capabilities, be honest about what you can and cannot do.\nAlways maintain a friendly and professional tone.", + "custom_instructions": "You are texting through a limited Telegram interface with 15-word maximum. Write like texting a friend - use shorthand, skip grammar, use slang/abbreviations. System cuts off anything longer than 15 words.\n\n- Your name is Atom.\n- The user you're talking to has username '{username}' and display name '{firstname} {lastname}'.\n- User's language preference: '{language}'. Prefer replying in this language when talking to '{username}'.\n- User is a {premium_status}\n- It's currently {time_context} in your timezone. Use appropriate time-based greetings and address the user by name.\n- If a user asks about buying apples, inform them that we don't sell apples.\n- When asked for a joke, tell a clean, family-friendly joke about programming or technology.\n- If someone inquires about our services, explain that we offer AI-powered chatbot solutions.\n- For any questions about pricing, direct users to contact our sales team at sales@example.com.\n- If asked about your capabilities, be honest about what you can and cannot do.\nAlways maintain a friendly and professional tone.", "continue_conversation": "Continuing our conversation. Remember previous context if relevant.", "avoid_sensitive": "Avoid discussing sensitive topics or providing harmful information.", "respond_with_emojis": "Since the user sent only emojis, respond using emojis only." diff --git a/elevenlabs.go b/elevenlabs.go index 4185a1d..60a13d5 100644 --- a/elevenlabs.go +++ b/elevenlabs.go @@ -13,8 +13,8 @@ import ( ) const ( - elevenLabsTTSURL = "https://api.elevenlabs.io/v1/text-to-speech/" - elevenLabsSTTURL = "https://api.elevenlabs.io/v1/speech-to-text" + elevenLabsTTSURL = "https://api.elevenlabs.io/v1/text-to-speech/" + elevenLabsSTTURL = "https://api.elevenlabs.io/v1/speech-to-text" elevenLabsDefaultModel = "eleven_multilingual_v2" ) diff --git a/go-telegram-bot.exe b/go-telegram-bot.exe index 0621d5035b93c25b2e8f2865ada4c14bab8c4e92..226706f35143b8365931697e1c71a930dad455b8 100644 GIT binary patch delta 1822 zcmW;MWmFah7{&2}7#N^}q9TedA}AIHc8h`79j{o3iorEd#JIkSg^GgMwJx_g)~>tU z=9;(Nkj*tBauvWB03XYh^|C8B8BKq^dNc?y@*tz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