英語| 简体中文| 繁體中文| 日本語| español|フランセ|陶芸|ドイツ
Telegram GPT Workerへようこそ!これは、TypeScriptで開発された効率的な電報ボットです。複数の言語とAIモデルをサポートし、CloudFlareワーカーに展開し、ユーザーに高速でスケーラブルなサービスエクスペリエンスを提供します。
始める前に、次のことを確認してください。
詳細な展開手順については、以下のチュートリアルを参照してください。
/start - ボットを開始します/language - 言語を切り替えます/switchmodel -Switch AIモデル/new新しい会話を開始します/history - 会話履歴の概要を取得します/help - ヘルプ情報を取得します/imgイメージを生成する(dall -e)/flux - イメージを生成する(cloudflareフラックス) /GPT-Telegram-Worker
│
├── /src
│ ├── /api
│ │ ├── azure.ts # Handle Azure API interactions
│ │ ├── claude.ts # Handle Claude API interactions
│ │ ├── flux-cf.ts # Handle Cloudflare AI drawing interface
│ │ ├── gemini.ts # Handle Google Gemini API interactions
│ │ ├── groq.ts # Handle Groq API interactions
│ │ ├── image_generation.ts # Handle DALL·E drawing interface
│ │ ├── model_api_interface.ts # Common interface defining model API standard structure
│ │ ├── openai_api.ts # Handle OpenAI API interactions
│ │ ├── openai_compatible.ts # Handles OpenAI compatible API interactions
│ │ └── telegram.ts # Handle Telegram bot logic
│ ├── /config # Configuration files
│ │ └── commands.ts # Telegram bot commands
│ ├── /utils
│ │ └── helpers.ts # Utility functions and tools
│ │ └── i18n.ts # Multilingual functions
│ │ └── redis.ts # Upstash Redis functions
│ │ └── image_analyze.ts # Image upload functions
│ ├── index.ts # Entry file, handling requests and responses
│ └── env.ts # Configure environment variables
├── /types # Type definition files
│ └── telegram.d.ts # Type definitions for Telegram API
├── wrangler.toml # Cloudflare Worker configuration file
├── tsconfig.json # TypeScript configuration file
├── package.json # Project dependency file
└── README.md # Project documentation
Wrangler CLIをインストール:
npm install -g @cloudflare/wranglerCloudFlareアカウントにログインします。
wrangler login新しい労働者プロジェクトを作成します:
wrangler init telegram-bot dist/index.jsファイルをプロジェクトにコピーします。
wrangler.tomlファイルを編集して、プロジェクトを構成します。
name = " telegram-bot "
type = " javascript "
account_id = " your_account_id "
workers_dev = trueCloudFlare労働者に展開:
wrangler publishdist/index.jsの内容をエディターにコピーして貼り付け、ファイルを保存します。Telegram Bot APIを使用して、Webhookをセットアップします。 URL例:
https://api.telegram.org/bot < YOUR_BOT_TOKEN > /setWebhook ? url=https://your-worker.your-subdomain.workers.dev/webhookhttps://api.telegram.org/bot123456789:abcdefghijklmn/setWebhook ? url=https://gpt-telegram-worker.abcdefg.workers.dev/webhookプロジェクトのクローン:
git clone https://github.com/snakeying/telegram-bot.git依存関係をインストールします:
npm install環境変数を設定します。
タイプスクリプトをコンパイルします:
npm run buildボットを開始します:
npm start| 変数名 | 説明 | デフォルト値 | 例 |
|---|---|---|---|
| openai_api_key | Openai APIキー | - | sk-abcdefghijklmnopqrstuvwxyz123456 |
| openai_base_url | Openai APIベースURL | https://api.openai.com/v1 | https://your-custom-endpoint.com/v1 |
| openai_models | 利用可能なOpenAIモデルのリスト | - | GPT-3.5-TURBO、GPT-4 |
| telegram_bot_token | 電報ボットトークン | - | 123456:ABC-DEF1234GHIKL-ZYX57W2V1U123EW11 |
| whitelisted_users | ボットを使用できるユーザーIDのリスト | - | 12345678,87654321 |
| System_init_message | システム初期化メッセージ | あなたは親切なアシスタントです。 | あなたは親切なアシスタントです。 |
| System_init_message_role | システム初期化メッセージロール | システム | システム |
| default_model | 使用するデフォルトのAIモデル | - | GPT-3.5-ターボ |
| upstash_redis_rest_url | Upstash Redis Rest URL | - | https://your-redis-url.upstash.io |
| upstash_redis_rest_token | Upstash Redis RESTトークン | - | あなたのレディストークン |
| dall_e_model | Dall-Eモデルバージョン | Dall-E-3 | Dall-E-3 |
| cloudflare_api_token | CloudFlare APIトークン | - | あなたのCloudflare-APIトークン |
| cloudflare_account_id | CloudFlareアカウントID | - | あなたのcloudflare-account-id |
| flux_steps | フラックス生成ステップの数 | 4 | 4-8、最大ステップは8です |
| PRONT_OPTIMIZINITION | 迅速な最適化を有効にします | 間違い | 真実 |
| external_api_base | 外部APIベースURL | - | https://external-api.com |
| external_model | 外部モデル名 | - | 外部モデル名 |
| external_api_key | 外部APIキー | - | 外部 - アピーキー |
| Google_model_key | Google AIモデルAPIキー | - | あなたのグーグル・アピ・キー |
| Google_model_baseurl | Google AIモデルAPIベースURL | https://generativelanguage.googleapis.com/v1beta | https://your-custom-google-endpoint.com |
| Google_models | 利用可能なGoogle AIモデルのリスト | - | Gemini-Pro、Gemini-Pro-Vision |
| GROQ_API_KEY | GROQ APIキー | - | あなたのgroq-api-key |
| Anthropic_api_key | 人類のAPIキー | - | あなたの人類の鍵 |
| Anthropic_base_url | 人類APIベースURL | https://api.anthropic.com | https://your-custom-anthropic-endpoint.com |
| openai_compatible_key | OpenAI互換APIキー | - | sk-abcdefghijklmnopqrstuvwxyz123456 |
| openai_compatible_url | OpenAI互換APIベースURL | - | https://your-custom-endpoint.com/v1 |
注:一部の変数は手動で構成する必要があり、デフォルト値はありません。
ユーザーが画像をアップロードし、AI分析結果を受信できるようにします。使用方法は次のとおりです。
注:使用しているAIモデルが画像分析をサポートしていることを確認してください。現在のモデルがサポートしていない場合、ボットはマルチモーダルサポートモデルに切り替えるように促します。
prospt_optimization環境変数がtrueに設定されている場合、フラックス画像生成機能は外部APIを使用してプロンプトを最適化します。この機能は、次の手順で機能します。
この機能は、フラックスモデルの特性とよりよく整合する、より正確な画像を生成するのに役立ちます。この機能を使用するには、すべての関連する環境変数が正しく構成されていることを確認してください。
このプロジェクトは、MITライセンスの下でライセンスされています。
著作権(c)2024 [蛇の]