ภาษาอังกฤษ | 简体中文 | 繁體中文 | 日本語 | Español | Français | руский | Deutsch
ยินดีต้อนรับสู่ Telegram GPT Worker! นี่คือบอทโทรเลขที่มีประสิทธิภาพที่พัฒนาขึ้นใน typeScript รองรับหลายภาษาและโมเดล AI ปรับใช้กับคนงาน CloudFlare ให้ผู้ใช้ได้รับประสบการณ์การบริการที่รวดเร็วและปรับขนาดได้
ก่อนเริ่มต้นใช้งานโปรดตรวจสอบให้แน่ใจว่าคุณมีสิ่งต่อไปนี้:
สำหรับขั้นตอนการปรับใช้โดยละเอียดโปรดดูบทช่วยสอนด้านล่าง
/start - เริ่มต้นบอท/language - เปลี่ยนภาษา/switchmodel - สลับโมเดล 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/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 ลงในตัวแก้ไขจากนั้นบันทึกไฟล์ใช้ 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ตั้งค่าตัวแปรสภาพแวดล้อม
Compile Typescript:
npm run buildเริ่มต้นบอท:
npm start| ชื่อตัวแปร | คำอธิบาย | ค่าเริ่มต้น | ตัวอย่าง |
|---|---|---|---|
| openai_api_key | คีย์ Openai API | - | SK-ABCDEFGHIJKLMNOPQRSTUVWXYZ123456 |
| openai_base_url | 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 | โทเค็น Bot Telegram | - | 123456: ABC-DEF1234GHIKL-ZYX57W2V1U123EW11 |
| whitelisted_users | รายการรหัสผู้ใช้ที่ได้รับอนุญาตให้ใช้บอท | - | 12345678,87654321 |
| system_init_message | ข้อความเริ่มต้นระบบ | คุณเป็นผู้ช่วยที่มีประโยชน์ | คุณเป็นผู้ช่วยที่มีประโยชน์ |
| system_init_message_role | บทบาทข้อความเริ่มต้นระบบ | ระบบ | ระบบ |
| default_model | รุ่น AI เริ่มต้นที่จะใช้ | - | GPT-3.5-turbo |
| upstash_redis_rest_url | Upstash redis rest url | - | https://your-redis-url.upstash.io |
| upstash_redis_rest_token | Upstash Redis Rest Token | - | คุณ-รีดทาวน์ |
| dall_e_model | รุ่น Dall-E รุ่น | Dall-e-3 | Dall-e-3 |
| Cloudflare_api_token | โทเค็น API Cloudflare | - | Cloudflare-Api-Token ของคุณ |
| Cloudflare_account_id | รหัสบัญชี CloudFlare | - | คลอดฟลัส-บัญชีของคุณ |
| ฟลักซ์ _steps | จำนวนขั้นตอนการสร้างฟลักซ์ | 4 | 4-8 ขั้นตอนสูงสุดคือ 8 |
| prompt_optimization | เปิดใช้งานการเพิ่มประสิทธิภาพที่รวดเร็ว | เท็จ | จริง |
| external_api_base | URL ฐาน API ภายนอก | - | https://external-api.com |
| external_model | ชื่อรุ่นภายนอก | - | ชื่อภายนอก |
| external_api_key | คีย์ API ภายนอก | - | ภายนอก |
| google_model_key | คีย์ API ของ Google AI Model | - | GOOGLE-API-KEY ของคุณ |
| google_model_baseurl | URL พื้นฐานของ Google AI API | 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 มานุษยวิทยา | - | ของคุณ-api-api-key |
| anthropic_base_url | URL ฐาน API มานุษยวิทยา | https://api.anthropic.com | https://your-custom-anthropic-endpoint.com |
| openai_compatible_key | คีย์ API ที่เข้ากันได้ของ OpenAI | - | SK-ABCDEFGHIJKLMNOPQRSTUVWXYZ123456 |
| openai_compatible_url | URL ฐาน API ที่เข้ากันได้ของ OpenAI | - | https://your-custom-endpoint.com/v1 |
หมายเหตุ: ตัวแปรบางตัวต้องได้รับการกำหนดค่าด้วยตนเองและไม่มีค่าเริ่มต้น
อนุญาตให้ผู้ใช้อัปโหลดรูปภาพและรับผลการวิเคราะห์ AI นี่คือวิธีการใช้งาน:
หมายเหตุ: ตรวจสอบให้แน่ใจว่าโมเดล AI ที่คุณใช้การวิเคราะห์ภาพรองรับ หากโมเดลปัจจุบันไม่รองรับบอทจะแจ้งให้คุณเปลี่ยนไปใช้โมเดลที่สนับสนุนหลายรูปแบบ
เมื่อตัวแปรสภาพแวดล้อม prompt_optimization ถูกตั้งค่าเป็นจริงคุณสมบัติการสร้างภาพฟลักซ์ใช้ API ภายนอกเพื่อเพิ่มประสิทธิภาพพรอมต์ คุณสมบัตินี้ทำงานผ่านขั้นตอนต่อไปนี้:
คุณลักษณะนี้สามารถช่วยสร้างภาพที่แม่นยำยิ่งขึ้นซึ่งสอดคล้องกับคุณสมบัติของโมเดลฟลักซ์ ในการใช้คุณสมบัตินี้ตรวจสอบให้แน่ใจว่าตัวแปรสภาพแวดล้อมที่เกี่ยวข้องทั้งหมดได้รับการกำหนดค่าอย่างถูกต้อง
โครงการนี้ได้รับใบอนุญาตภายใต้ใบอนุญาต MIT
ลิขสิทธิ์ (c) 2024 [งู]