Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/genshinminecraft/rust-cloudflare-workers-ai-telegram-bot
Rust 编写的 Telegram Cloudflare Workers AI Bot
https://github.com/genshinminecraft/rust-cloudflare-workers-ai-telegram-bot
Last synced: 4 days ago
JSON representation
Rust 编写的 Telegram Cloudflare Workers AI Bot
- Host: GitHub
- URL: https://github.com/genshinminecraft/rust-cloudflare-workers-ai-telegram-bot
- Owner: GenshinMinecraft
- License: wtfpl
- Created: 2024-06-10T13:19:08.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-28T12:19:46.000Z (5 months ago)
- Last Synced: 2024-11-09T01:36:10.178Z (12 days ago)
- Language: Rust
- Homepage:
- Size: 70.3 KB
- Stars: 43
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust-Cloudflare-Workers-AI-Telegram-Bot
[简体中文](https://github.com/GenshinMinecraft/Rust-Cloudflare-Workers-AI-Telegram-Bot/blob/main/README_cn.md) [English](https://github.com/GenshinMinecraft/Rust-Cloudflare-Workers-AI-Telegram-Bot/blob/main/README.md)
For the Python implementation, please refer to [Cloudflare-Workers-Ai-Telegram-Bot](https://github.com/GenshinMinecraft/Cloudflare-Workers-Ai-Telegram-Bot).
## Introduction
A Rust-built Cloudflare Workers AI Bot with support for **context preservation**.
Engages in conversations with users by invoking the Workers AI REST API.
Uses Workers KV to store context information for users.
## To Do List
- [x] Context Preservation Implemented
- [x] Proxy Support (leveraging environment variables supported by reqwest)
- [x] User/Group ID AuthenticationFor additional features, please submit an issue or a pull request.
## Running the Bot
### Telegram Setup
Create a new bot and obtain your bot ID along with user or group IDs. Detailed steps are not covered here.
### Cloudflare Setup
Acquire your Account ID and corresponding API Token (a Global API Token can be used for simplicity).
Set up a Workers KV namespace for key-value storage and note its Namespace ID.
Also, establish an AI Gateway and retain its name.
### Editing Configuration File
First, download the configuration template:
```bash
wget https://raw.githubusercontent.com/GenshinMinecraft/Rust-Cloudflare-Workers-Ai-Telegram-Bot/main/config.yaml.exp -O config.yaml
```Then, edit it with your preferred text editor. Below are explanations for each configuration item:
- `telegram`: Telegram-related configurations
- `bot_token`: **(Required)** Telegram Bot Token
- `admin_id`: (Optional) The admin of this Bot in Telegram
- `users_id`: (Optional) List of authorized users/groups; if specified, only these will have access, otherwise, it's open for all.- `cloudflare`: Cloudflare-related configurations
- `account_id`: **(Required)** Cloudflare Account ID, found in the Dashboard URL
- `api_token`: **(Required)** Cloudflare Account API Token; a Global API Token can be used for convenience- `kv`: Workers KV configurations
- `namespace_id`: **(Required)** Workers KV Namespace ID, located in its detail interface- `ai_gateway`: AI Gateway configurations
- `name`: **(Required)** Name of the Cloudflare AI Gateway, set during creation- `workers_ai`: Workers AI configurations
- `model`: (Optional) Model configuration; refer to Cloudflare Docs for all models
- `prompt`: (Optional) Initial prompt for all users## Acknowledgments
- [Cloudflare](https://cloudflare.com): Kudos to the big daddy.
- [Teloxide](https://github.com/teloxide/teloxide): The primary Bot framework.## LICENSE
This project is licensed under the **Do What the Fuck You Want to Public License** *(WTFPL)*.
So, you can do whatever the hell you want with this project *(Do What the Fuck You Want)*.