From 015ffef17c81145c5ae44e1bd452eeebc331b731 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 22 May 2025 10:48:20 -0700 Subject: [PATCH] Refactor constants.go: improve organization and alignment --- constants.go | 84 ++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 45 deletions(-) diff --git a/constants.go b/constants.go index 963f577..9c47807 100644 --- a/constants.go +++ b/constants.go @@ -4,20 +4,51 @@ import ( "time" ) -// Database constants +// Application constants const ( + // Database dbPath = "articles.db" -) -// LLM constants -const ( // LLM system prompt SYSTEM_PROMPT = "You are a news analyst." - // Main LLM prompt for article summarization - ARTICLES_PROMPT = `Summarize each of these news items in under 165 - characters, optimizing for information density (common news headline - abbreviations OK) and rate their importance from 1 to 100. + // LLM batch processing settings + BATCH_SIZE = 5 + MAX_INDIVIDUAL_PROCESSING = 50 + + // Timing constants + RSS_CHECK_INTERVAL = 15 * time.Minute + SUMMARIZE_INTERVAL = 10 * time.Second + BROADCAST_INTERVAL = 1 * time.Hour + BROADCAST_CHECK_INTERVAL = 10 * time.Second // Interval to check if broadcasting is needed + DEVICE_REBOOT_INTERVAL = 6 * time.Hour // Interval to reboot Meshtastic device + STARTUP_DELAY = 60 * time.Second // Delay before first broadcast + BROADCAST_PREPARATION_DELAY = 30 * time.Second // Delay before executing broadcast command + ARTICLE_FRESHNESS_WINDOW = 24 * time.Hour // Time window for considering articles fresh + + // Message limits + MAX_MESSAGE_LENGTH = 200 // Maximum length of broadcast messages in characters + MAX_LOG_ENTRIES = 1000 // Maximum number of log entries to keep in memory +) + +// ANSI color codes for colorized logging +const ( + colorReset = "\033[0m" + colorRed = "\033[31m" + colorGreen = "\033[32m" + colorYellow = "\033[33m" + colorBlue = "\033[34m" + colorPurple = "\033[35m" + colorCyan = "\033[36m" + colorGray = "\033[37m" + colorWhite = "\033[97m" + bold = "\033[1m" +) + +// Main LLM prompt for article summarization +const ARTICLES_PROMPT = `Summarize each of these news items in under 165 +characters, optimizing for information density (common news headline +abbreviations OK) and rate their importance from 1 to 100. 100 means most important; 1 means least important. @@ -47,43 +78,6 @@ fields. Return your response as a JSON array of objects like: [{"id": Here are the articles: ` - // LLM batch processing settings - BATCH_SIZE = 5 - MAX_INDIVIDUAL_PROCESSING = 50 -) - -// Timing constants -const ( - RSS_CHECK_INTERVAL = 15 * time.Minute - SUMMARIZE_INTERVAL = 10 * time.Second - BROADCAST_INTERVAL = 1 * time.Hour - BROADCAST_CHECK_INTERVAL = 10 * time.Second // Interval to check if broadcasting is needed - DEVICE_REBOOT_INTERVAL = 6 * time.Hour // Interval to reboot Meshtastic device - STARTUP_DELAY = 60 * time.Second // Delay before first broadcast - BROADCAST_PREPARATION_DELAY = 30 * time.Second // Delay before executing broadcast command - ARTICLE_FRESHNESS_WINDOW = 24 * time.Hour // Time window for considering articles fresh -) - -// Message constants -const ( - MAX_MESSAGE_LENGTH = 200 // Maximum length of broadcast messages in characters - MAX_LOG_ENTRIES = 1000 // Maximum number of log entries to keep in memory -) - -// ANSI color codes for colorized logging -const ( - colorReset = "\033[0m" - colorRed = "\033[31m" - colorGreen = "\033[32m" - colorYellow = "\033[33m" - colorBlue = "\033[34m" - colorPurple = "\033[35m" - colorCyan = "\033[36m" - colorGray = "\033[37m" - colorWhite = "\033[97m" - bold = "\033[1m" -) - // Map of source names to their abbreviations var sourceAbbreviations = map[string]string{ "BBC": "BBC",