feat: add complete multi-agent AI system with Telegram bot
Initial implementation of MultiAgentsAI featuring: - Dynamic agent configuration via environment variables - SQLite database and JSON daily context storage - OpenRouter API integration for multiple AI models - Telegram bot with commands for control, history, and interaction - Autonomous conversation loop with pause/resume and agent silencing - Model testing and statistics commands
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# Gerado por IA
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def _parse_agents() -> list[dict]:
|
||||
agents = []
|
||||
idx = 1
|
||||
while True:
|
||||
name = os.getenv(f"AGENT_NAME_{idx}")
|
||||
model = os.getenv(f"AGENT_MODEL_{idx}")
|
||||
if not name or not model:
|
||||
break
|
||||
agents.append({"name": name, "model": model, "index": idx})
|
||||
idx += 1
|
||||
return agents
|
||||
|
||||
|
||||
class Settings:
|
||||
# Telegram
|
||||
TELEGRAM_BOT_TOKEN: str = os.getenv("TELEGRAM_BOT_TOKEN", "")
|
||||
TELEGRAM_CHAT_ID: str = os.getenv("TELEGRAM_CHAT_ID", "")
|
||||
|
||||
# OpenRouter
|
||||
OPENROUTER_API_KEY: str = os.getenv("OPENROUTER_API_KEY", "")
|
||||
OPENROUTER_BASE_URL: str = os.getenv("OPENROUTER_BASE_URL", "https://openrouter.ai/api/v1")
|
||||
|
||||
# Sistema
|
||||
CONVERSATION_DELAY: int = int(os.getenv("CONVERSATION_DELAY_SEGUNDOS", "30"))
|
||||
MAX_CONTEXT_MESSAGES: int = int(os.getenv("MAX_CONTEXT_MESSAGES", "50"))
|
||||
MAX_TOKENS: int = int(os.getenv("MAX_TOKENS", "0"))
|
||||
DB_PATH: str = os.getenv("DB_PATH", "agents.db")
|
||||
CONTEXTS_DIR: str = os.getenv("CONTEXTS_DIR", "Contexts")
|
||||
CONVERSATION_LANGUAGE: str = os.getenv("CONVERSATION_LANGUAGE", "pt_BR")
|
||||
|
||||
# Agentes
|
||||
AGENTS: list[dict] = _parse_agents()
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
# Agentes silenciados (não participam do loop automático)
|
||||
_silenced_agents: set[str] = set()
|
||||
Reference in New Issue
Block a user