{"id":28318416,"url":"https://github.com/iu2frl/telegram_geminiai_rag_bot","last_synced_at":"2026-04-14T07:05:16.093Z","repository":{"id":267523831,"uuid":"901519740","full_name":"iu2frl/Telegram_GeminiAI_RAG_Bot","owner":"iu2frl","description":"A small Telegram bot powered by Gemini AI to retrieve informations from a custom set of documents","archived":false,"fork":false,"pushed_at":"2026-01-15T19:51:31.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T21:55:56.453Z","etag":null,"topics":["ai","gemini","gemini-ai","gemini-api","rag","telegram","telegram-ai","telegram-ai-bot","telegram-ai-chat-bot","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iu2frl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-10T20:07:48.000Z","updated_at":"2026-01-15T19:51:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"9957efbb-afba-43be-8b50-a94987e804bb","html_url":"https://github.com/iu2frl/Telegram_GeminiAI_RAG_Bot","commit_stats":null,"previous_names":["iu2frl/telegram_geminiai_rag_bot"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/iu2frl/Telegram_GeminiAI_RAG_Bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2FTelegram_GeminiAI_RAG_Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2FTelegram_GeminiAI_RAG_Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2FTelegram_GeminiAI_RAG_Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2FTelegram_GeminiAI_RAG_Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iu2frl","download_url":"https://codeload.github.com/iu2frl/Telegram_GeminiAI_RAG_Bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2FTelegram_GeminiAI_RAG_Bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31785682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","gemini","gemini-ai","gemini-api","rag","telegram","telegram-ai","telegram-ai-bot","telegram-ai-chat-bot","telegram-bot","telegram-bot-api"],"created_at":"2025-05-25T07:12:36.808Z","updated_at":"2026-04-14T07:05:16.087Z","avatar_url":"https://github.com/iu2frl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Assistant Telegram Bot\n\nThis bot is an AI-powered assistant that uses Google's Gemini AI to process user queries and provide responses based on uploaded documents. It integrates with Telegram for user interaction.\n\n## Features\n\n- Responds to user queries about specific documents or topics.\n- Utilizes Google Gemini AI for natural language understanding and document-based querying.\n- Handles Telegram messages and commands.\n- Supports MarkdownV2 formatting for responses.\n- Supports dynamic loading of documents from a specified GitHub repository.\n- Supports rate limit handling for Gemini API models when using free-tier accounts (only if `GOOGLE_API_MODEL` is set to `auto`).\n\n\u003e [!WARNING]\n\u003e If the `GOOGLE_API_MODEL` environment variable is set to a specific model name (e.g., `gemini-2.0-flash`), the bot will not monitor rate limits automatically. This may lead to unexpected costs or rate limiting issues.\n\n\u003e [!WARNING]\n\u003e The list of supported free-tier Gemini models may change over time. Please refer to the [official documentation](https://ai.google.dev/gemini-api/docs/deprecations) for the most up-to-date information. If a model expires, it can no longer be used by the bot until the code in `modules/state.py` is updated.\n\n## Prerequisites\n\n### Python environment\n\n1. Python 3.8 or higher.\n2. Required Python packages (install using `pip install -r requirements.txt`)\n\n### Gemini API key\n\n1. Generate a Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey?hl=it)\n\n### Telegram API key\n\n1. Use [@BotFather](https://t.me/BotFather) to generate a bot\n2. Get the API key from the generate bot\n\n## Setup\n\n1. Clone the Repository\n\n```bash\ngit clone \u003crepository-url\u003e\ncd \u003crepository-folder\u003e\n```\n\n1. Create a `.env` File\n\nCreate a `.env` file in the project root directory with the following variables:\n\n```env\nTELEGRAM_API_KEY=your-telegram-bot-token\nTELEGRAM_BOT_NAME=@your-bot-username\nGOOGLE_API_KEY=your-google-api-key\nGOOGLE_API_MODEL=gemini-2.0-flash\nGOOGLE_API_MAX_ATTEMPTS=2\nREPO_URL=https://github.com/octocat/hello-world\nTELEGRAM_RESTART_DELAY_SECONDS=15\n```\n\nPlease note: creating the `.env` file is optional, if the variables are set in the current environment, the bot will retrieve them from there (or from the Docker environment variables)\n\n1. Prepare the sources\n\nThe bot pulls documents from the repository defined by `REPO_URL` and stores them in `./sources`. You can also place your documents directly inside the `sources` folder if you want to manage them locally.\n\n## Running the Bot\n\n1. Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n1. Start the Bot using:\n\n```bash\npython main.py\n```\n\n## Usage\n\n### Commands\n\n- **`/start`**: Initiates interaction with the bot and provides an introductory message.\n\n### Messaging\n\n- Send a text message with your query to the bot, and it will respond based on the information in the uploaded documents.\n\n## Logs\n\nThe bot logs all activity to the console. Logs are categorized into:\n\n- **INFO**: General information about the bot's operation.\n- **DEBUG**: Detailed logs for troubleshooting.\n- **WARNING**: Potential issues that do not stop the bot.\n- **ERROR**: Issues that prevent successful operation.\n\nYou can adjust the log level in the `configure_logging()` function.\n\n## Troubleshooting\n\n- **Missing API keys**: Ensure the `.env` file is correctly configured.\n- **Google Gemini AI errors**: Check your API key and ensure the uploaded files meet the requirements.\n- **Telegram bot issues**: Verify the bot token and bot username.\n\nFor detailed error messages, check the logs.\n\n## Usage with Docker\n\n1. Clone the repo\n1. Build the container with `docker build -t notebook-lm-bot:latest .`\n1. Create the `docker-compose.yml` file containing the text below\n1. Start the container with `docker compose up`\n\n```yaml\nservices:\n    bot:\n        container_name: notebook-lm-bot\n        environment:\n          - TELEGRAM_API_KEY=your-telegram-bot-token\n          - TELEGRAM_BOT_NAME=@your-bot-username\n          - GOOGLE_API_KEY=your-google-api-key\n          - GOOGLE_API_MODEL=gemini-2.0-flash\n          - GOOGLE_API_MAX_ATTEMPTS=2\n          - REPO_URL=https://github.com/octocat/hello-world\n          - TELEGRAM_RESTART_DELAY_SECONDS=15\n        restart: unless-stopped\n        image: notebook-lm-bot:latest\n        deploy:\n          resources:\n            limits:\n              cpus: '1'\n              memory: 256M\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiu2frl%2Ftelegram_geminiai_rag_bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiu2frl%2Ftelegram_geminiai_rag_bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiu2frl%2Ftelegram_geminiai_rag_bot/lists"}