feat: add training group support in Gateway
- Added TRAINING_GROUP_IDS constant for Agent Preschool group - Gateway now adds "[РЕЖИМ НАВЧАННЯ]" prefix for training groups - Agents will respond to all messages in training groups Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,10 +25,11 @@ Helion:
|
|||||||
|
|
||||||
## 0.0.1 ПРАВИЛА ДЛЯ ГРУП (ОБОВ'ЯЗКОВО!)
|
## 0.0.1 ПРАВИЛА ДЛЯ ГРУП (ОБОВ'ЯЗКОВО!)
|
||||||
|
|
||||||
**ВИКЛЮЧЕННЯ — НАВЧАЛЬНА ГРУПА "Agent Preschool Daarion.city":**
|
**ВИКЛЮЧЕННЯ — НАВЧАЛЬНА ГРУПА (chat_id: -1003556680911):**
|
||||||
- У цій групі ти в РЕЖИМІ НАВЧАННЯ
|
- Якщо ти в групі "Agent Preschool Daarion.city" — ти в РЕЖИМІ НАВЧАННЯ
|
||||||
- Відповідай на ВСІ повідомлення, навіть без згадки
|
- Відповідай на ВСІ повідомлення в цій групі, навіть без згадки
|
||||||
- Це тренувальний полігон для агентів
|
- Це тренувальний полігон для агентів
|
||||||
|
- Будь активним, дружнім, відповідай коротко
|
||||||
- Будь активним учасником діалогу
|
- Будь активним учасником діалогу
|
||||||
|
|
||||||
**У ІНШИХ ГРУПОВИХ ЧАТАХ ВІДПОВІДАЙ ТІЛЬКИ якщо:**
|
**У ІНШИХ ГРУПОВИХ ЧАТАХ ВІДПОВІДАЙ ТІЛЬКИ якщо:**
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ logger = logging.getLogger(__name__)
|
|||||||
TELEGRAM_MAX_MESSAGE_LENGTH = 4096
|
TELEGRAM_MAX_MESSAGE_LENGTH = 4096
|
||||||
TELEGRAM_SAFE_LENGTH = 3500 # Leave room for formatting
|
TELEGRAM_SAFE_LENGTH = 3500 # Leave room for formatting
|
||||||
|
|
||||||
|
# Training groups - agents respond to ALL messages without mention requirement
|
||||||
|
TRAINING_GROUP_IDS = {
|
||||||
|
"-1003556680911", # Agent Preschool Daarion.city
|
||||||
|
}
|
||||||
|
|
||||||
# Brand stack services
|
# Brand stack services
|
||||||
BRAND_INTAKE_URL = os.getenv("BRAND_INTAKE_URL", "http://brand-intake:9211").rstrip("/")
|
BRAND_INTAKE_URL = os.getenv("BRAND_INTAKE_URL", "http://brand-intake:9211").rstrip("/")
|
||||||
BRAND_REGISTRY_URL = os.getenv("BRAND_REGISTRY_URL", "http://brand-registry:9210").rstrip("/")
|
BRAND_REGISTRY_URL = os.getenv("BRAND_REGISTRY_URL", "http://brand-registry:9210").rstrip("/")
|
||||||
@@ -1644,11 +1649,19 @@ async def handle_telegram_webhook(
|
|||||||
|
|
||||||
# Build message with conversation context
|
# Build message with conversation context
|
||||||
local_history = memory_context.get("local_context_text", "")
|
local_history = memory_context.get("local_context_text", "")
|
||||||
|
|
||||||
|
# Check if this is a training group
|
||||||
|
is_training_group = str(chat_id) in TRAINING_GROUP_IDS
|
||||||
|
training_prefix = ""
|
||||||
|
if is_training_group:
|
||||||
|
training_prefix = "[РЕЖИМ НАВЧАННЯ - відповідай на це повідомлення, ти в навчальній групі Agent Preschool]\n\n"
|
||||||
|
logger.info(f"🎓 Training mode activated for chat {chat_id}")
|
||||||
|
|
||||||
if local_history:
|
if local_history:
|
||||||
# Add conversation history to message for better context understanding
|
# Add conversation history to message for better context understanding
|
||||||
message_with_context = f"[Контекст розмови]\n{local_history}\n\n[Поточне повідомлення від {username}]\n{text}"
|
message_with_context = f"{training_prefix}[Контекст розмови]\n{local_history}\n\n[Поточне повідомлення від {username}]\n{text}"
|
||||||
else:
|
else:
|
||||||
message_with_context = text
|
message_with_context = f"{training_prefix}{text}"
|
||||||
|
|
||||||
# Build request to Router
|
# Build request to Router
|
||||||
system_prompt = agent_config.system_prompt
|
system_prompt = agent_config.system_prompt
|
||||||
@@ -3019,11 +3032,18 @@ async def _old_helion_telegram_webhook(update: TelegramUpdate):
|
|||||||
|
|
||||||
# Build message with conversation context
|
# Build message with conversation context
|
||||||
local_history = memory_context.get("local_context_text", "")
|
local_history = memory_context.get("local_context_text", "")
|
||||||
|
|
||||||
|
# Check if this is a training group
|
||||||
|
is_training_group = str(chat_id) in TRAINING_GROUP_IDS
|
||||||
|
training_prefix = ""
|
||||||
|
if is_training_group:
|
||||||
|
training_prefix = "[РЕЖИМ НАВЧАННЯ - відповідай на це повідомлення, ти в навчальній групі Agent Preschool]\n\n"
|
||||||
|
|
||||||
if local_history:
|
if local_history:
|
||||||
# Add conversation history to message for better context understanding
|
# Add conversation history to message for better context understanding
|
||||||
message_with_context = f"[Контекст розмови]\n{local_history}\n\n[Поточне повідомлення від {username}]\n{text}"
|
message_with_context = f"{training_prefix}[Контекст розмови]\n{local_history}\n\n[Поточне повідомлення від {username}]\n{text}"
|
||||||
else:
|
else:
|
||||||
message_with_context = text
|
message_with_context = f"{training_prefix}{text}"
|
||||||
|
|
||||||
# Build request to Router with Helion context
|
# Build request to Router with Helion context
|
||||||
router_request = {
|
router_request = {
|
||||||
|
|||||||
Reference in New Issue
Block a user