GPT Telegram Worker
v1.6
英语| 简体中文| 繁体中文| 日本语| Español| Français| n德意志
欢迎来到Telegram GPT工人!这是在打字稿中开发的有效电报机器人。它支持多种语言和AI模型,该模型部署在CloudFlare工人上,为用户提供快速可扩展的服务体验。
在开始之前,请确保您有以下内容:
有关详细的部署步骤,请参阅下面的教程。
/start - 启动机器人/language - 切换语言/switchmodel切换AI模型/new开始新对话/history - 获取对话历史摘要/help - 获取帮助信息/img生成图像(dall -e)/flux - 生成图像(Cloudflare Flux) /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
安装牧马人CLI:
npm install -g @cloudflare/wrangler登录到您的CloudFlare帐户:
wrangler login创建一个新的工人项目:
wrangler init telegram-bot将dist/index.js文件复制到您的项目中。
编辑wrangler.toml文件以配置您的项目:
name = " telegram-bot "
type = " javascript "
account_id = " your_account_id "
workers_dev = true部署到Cloudflare工人:
wrangler publishdist/index.js的内容复制并粘贴到编辑器中,然后保存文件。使用电报机器人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基础网址 | 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 |
| 白色列表_users | 允许使用机器人的用户ID列表 | - | 12345678,87654321 |
| system_init_message | 系统初始化消息 | 您是一个有益的助手。 | 您是一个有益的助手。 |
| system_init_message_role | 系统初始化消息角色 | 系统 | 系统 |
| Default_Model | 要使用的默认AI模型 | - | GPT-3.5-Turbo |
| UPSTASH_REDIS_REST_URL | Upstash redis休息URL | - | https://your-redis-url.upstash.io |
| UPSTASH_REDIS_REST_TOKEN | Upstash redis休息令牌 | - | 您的redis token |
| dall_e_model | DALL-E模型版本 | dall-e-3 | dall-e-3 |
| Cloudflare_api_token | Cloudflare API令牌 | - | 您的cloudflare-api-token |
| Cloudflare_account_id | Cloudflare帐户ID | - | 您的cloudflare-Account-id |
| flux_steps | 通量生成步骤的数量 | 4 | 4-8,最大步骤为8 |
| 提示_optimization | 启用及时的优化 | 错误的 | 真的 |
| external_api_base | 外部API基础URL | - | https://external-api.com |
| external_model | 外部型号名称 | - | 外部模型名称 |
| 外部_api_key | 外部API键 | - | 外部 - 钥匙 |
| Google_model_key | Google AI模型API密钥 | - | 您的google-api-key |
| Google_model_baseurl | Google AI模型API基础URL | https://generativelanguage.googleapis.com/v1beta | https://your-custom-google-endpoint.com |
| Google__models | 可用的Google AI模型列表 | - | 双子座 - 双子座,双子座式视觉 |
| GROQ_API_KEY | GROQ API键 | - | 您的groq-api-key |
| Anthropic_api_key | 拟人API键 | - | 您的人类广播 |
| Anthropic_base_url | 拟人API碱基URL | https://api.anthropic.com | https://your-custom-anththropic-endpoint.com |
| OpenAi_compatible_key | OpenAI兼容API键 | - | sk-abcdefghijklmnopqrstuvwxyz123456 |
| OpenAi_compatible_url | OpenAI兼容API基础URL | - | https://your-custom-endpoint.com/v1 |
注意:某些变量需要手动配置,并且没有默认值。
允许用户上传图像并接收AI分析结果。这是使用它的方法:
注意:确保您使用的AI模型支持图像分析。如果当前模型不支持它,则该机器人将提示您切换到多模式支撑模型。
当提示_Optimization环境变量设置为trui时,Flux Image生成功能使用外部API来优化提示。此功能通过以下步骤工作:
此功能可以帮助生成更精确的图像,以更好地与通量模型特性保持一致。要使用此功能,请确保正确配置了所有相关环境变量。
该项目已根据MIT许可获得许可。
版权(C)2024 [蛇]