diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..560a2a4 --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +# ─── Required ──────────────────────────────────────────────── +TELEGRAM_TOKEN=your_telegram_bot_token_here +GOOGLE_API_KEY=your_google_ai_studio_api_key_here +OWNER_ID=your_telegram_user_id_here + +# ─── Optional ──────────────────────────────────────────────── +# Gemini model to use (default: gemini-2.0-flash) +AI_MODEL=gemini-2.0-flash diff --git a/config.py b/config.py new file mode 100644 index 0000000..8a0a45d --- /dev/null +++ b/config.py @@ -0,0 +1,40 @@ +import os +from dotenv import load_dotenv + +load_dotenv() + +TELEGRAM_TOKEN: str = os.getenv("TELEGRAM_TOKEN", "") +GOOGLE_API_KEY: str = os.getenv("GOOGLE_API_KEY", "") +OWNER_ID: int = int(os.getenv("OWNER_ID", "0")) +OWNER_USERNAME: str = os.getenv("OWNER_USERNAME", "").lstrip("@") + +DEFAULT_MODEL: str = os.getenv("AI_MODEL", "gemini-2.5-flash-lite") +IMAGEN_MODEL: str = os.getenv("IMAGEN_MODEL", "imagen-4.0-fast-generate-001") +DEFAULT_OR_MODEL: str = "openai/gpt-4o-mini" + +GOOGLE_AI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/" +OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1" +OPENROUTER_API_KEY: str = os.getenv("OPENROUTER_API_KEY", "") + +MAX_TOKENS_DEFAULT: int = 300 +MAX_TOKENS_MIN: int = 50 +MAX_TOKENS_MAX: int = 4000 +MAX_HISTORY_MESSAGES: int = 20 # messages kept in memory +MAX_API_CONTEXT: int = 10 # messages sent to API (saves input tokens) +MAX_INPUT_TOKENS: int = 12000 # auto-reset chat history above this estimated input size + +IMAGE_DAILY_LIMIT: int = 10 + +AUTH_FILE = "authorized_users.json" +SETTINGS_FILE = "settings.json" +BOT_VERSION = "1.1.0" + +DEFAULT_SYSTEM_PROMPT = """You are Puppy (پاپی), a friendly and capable AI assistant on Telegram. + +LANGUAGE: Always reply in the same language as the user's message (Persian/Farsi or English). + +TOOLS: You have two tools available via the API: search_web (for real-time info: date, news, weather, prices, recent events) and image_search (when user wants to see images). NEVER output raw XML or JSON tool calls in your text — the API handles tool calls automatically. + +FORMATTING: Use Telegram markdown — **bold**, *italic*, `code`, ```code blocks```, ~~strikethrough~~, ||spoiler||. + +Be concise, warm, helpful, and occasionally playful with light dog references.""" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4969a9a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +python-telegram-bot>=21.0,<23.0 +openai>=1.68.0 +google-genai>=1.0.0 +ddgs>=0.1.0 +python-dotenv>=1.0.0