### Docker Compose Up Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Command to start the application using Docker Compose. Requires manual modification of the docker-compose.yml file to specify configuration file paths. ```bash docker-compose up # edit the docker-compose.yml to change the config file path ``` -------------------------------- ### Local Run Commands Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Commands to install dependencies and start the application locally. Supports running directly or after building the project for distribution. ```shell pnpm install pnpm run start:local ``` ```shell pnpm install pnpm run build:local CONFIG_PATH=./config.json TOML_PATH=./wrangler.toml pnpm run start:dist ``` -------------------------------- ### Telegram Bot Setup via BotFather Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/DEPLOY.md Steps to create a new Telegram bot and obtain its unique API token using Telegram's BotFather. ```bash /start /newbot # Follow prompts to name your bot and set a username ending in _bot # Copy the generated API Token ``` -------------------------------- ### Command Line Deployment with Wrangler Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/DEPLOY.md Instructions for deploying the Cloudflare Worker using the Wrangler CLI. This includes preparing configuration files, installing dependencies, and executing the deployment command. ```bash pnpm install cp wrangler-example.toml wrangler.toml # Modify wrangler.toml with your configuration pnpm run deploy:dist ``` -------------------------------- ### Pull and Run Docker Hub Image Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Instructions to pull the latest image from Docker Hub and run it as a detached container, mapping ports and volumes for configuration. ```bash docker pull ghcr.io/tbxark/chatgpt-telegram-workers:latest docker run -d -p 8787:8787 -v $(pwd)/config.json:/app/config.json:ro -v $(pwd)/wrangler.toml:/app/config.toml:ro ghcr.io/tbxark/chatgpt-telegram-workers:latest ``` -------------------------------- ### OpenAI API Key Generation Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/DEPLOY.md Steps to register an OpenAI account and generate a new API key for accessing OpenAI services. ```APIDOC OpenAI Account and API Key: 1. Register an account at [OpenAI](https://platform.openai.com). 2. Navigate to personal settings via the avatar in the upper right corner. 3. Go to API Keys and click to create a new API Key. 4. Copy the generated API Key. ``` -------------------------------- ### Docker Image Build Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Commands to build the Docker image for the ChatGPT Telegram Workers application. Provides options for standard build or a faster build using local results. ```bash docker build -t chatgpt-telegram-workers:latest . ``` ```bash pnpm run build:docker # Faster (directly use the locally built results to create the image) ``` -------------------------------- ### Docker Container Run Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Command to run the application in a Docker container, mapping ports and volumes for configuration files. Assumes the image has already been built. ```bash docker run -d -p 8787:8787 -v $(pwd)/config.json:/app/config.json:ro -v $(pwd)/wrangler.toml:/app/config.toml:ro chatgpt-telegram-workers:latest ``` -------------------------------- ### Telegram Bot Commands Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md List of supported commands for interacting with the Telegram bot, including their purpose and usage examples. ```APIDOC /help: Description: Get command help. Example: /help /new: Description: Start a new conversation. Example: /new /start: Description: Get your ID and start a new conversation. Example: /start /img: Description: Generate an image based on a description. Example: /img A cat wearing a hat /version: Description: Get the current version number and check for updates. Example: /version /setenv: Description: Set user configuration. See 'User Configuration' for details. Example: /setenv KEY=VALUE /setenvs: Description: Set user configurations in bulk. See 'User Configuration' for details. Example: /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"} /delenv: Description: Delete user configuration. Example: /delenv KEY /system: Description: View current system information. Example: /system /redo: Description: Modify the previous query or get a different answer. Example: /redo Modified content or /redo /models: Description: Switch the conversation model. Select from the built-in menu. Example: /models /echo: Description: Echo message (available in development mode only). Example: /echo ``` -------------------------------- ### Manual Vercel Deployment Commands Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/VERCEL.md This snippet details the commands required for manual deployment to Vercel. It includes installing project dependencies and initiating the Vercel deployment process. Post-deployment steps like environment variable synchronization are also mentioned in the surrounding text. ```shell pnpm install pnpm deploy:vercel ``` -------------------------------- ### Local Deployment Configuration (JSON5) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/LOCAL.md Defines the server and database configuration for local deployment. Includes settings for database type and path, server hostname, port, base URL, proxy, and operating mode (webhook or polling). ```json5 { "database": { "type": "local", // memory, local, sqlite, redis "path": "/app/data.json" // your database path }, "server": { // server configuration for webhook mode "hostname": "0.0.0.0", "port": 3000, // must 8787 when using docker "baseURL": "https://example.com" }, "proxy": "http://127.0.0.1:7890", // proxy for telegram api "mode": "webhook" // webhook, polling } ``` -------------------------------- ### Cloudflare Workers Deployment Steps Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/DEPLOY.md Steps for manually deploying the worker code to Cloudflare. This involves creating a service, pasting the worker code, and configuring environment variables and KV namespaces. ```APIDOC Cloudflare Workers Deployment: 1. Create a new service in Cloudflare Workers. 2. Select 'Quick Edit' and paste the worker code from `../dist/index.js`. 3. Save the worker code. 4. Configure Environment Variables: - Navigate to Settings -> Variables. - Set `TELEGRAM_AVAILABLE_TOKENS` with your Telegram Bot Token. - Set `OPENAI_API_KEY` with your OpenAI API Key. - Refer to `CONFIG.md` for additional variables. 5. Bind KV Namespace: - Create a KV Namespace named `DATABASE`. - In Worker Settings -> Variables -> KV Namespace Bindings, add a variable named `DATABASE` and select the created namespace. 6. Initialization: - Access the initialization URL: `https://..workers.dev/init` to bind the Telegram webhook and set commands. ``` -------------------------------- ### Troubleshooting Bot Unresponsiveness in Group Chats Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Addresses issues where the Telegram bot fails to respond in group chats. It outlines necessary configuration settings and bot permissions required for proper functionality. ```configuration 1. Ensure `GROUP_CHAT_BOT_ENABLE` is set to `true`. 2. In BotFather, set the bot's privacy status to `DISABLED`. 3. For public groups or supergroups with over 2000 members, add the bot as an administrator. 4. Verify that `TELEGRAM_BOT_NAME` and `TELEGRAM_AVAILABLE_TOKENS` are correctly configured and ordered. Example: - Bot A: Name `A_bot`, Token `1000:aaaaaaa` - Bot B: Name `B_bot`, Token `2000:bbbbbbb` - `TELEGRAM_AVAILABLE_TOKENS` should be `1000:aaaaaaa,2000:bbbbbbb` - `TELEGRAM_BOT_NAME` should be `A_bot,B_bot` ``` -------------------------------- ### Telegram Bot Commands Reference Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/CONFIG.md A reference guide for commands available within the Telegram bot. Each command serves a specific function, from initiating conversations and managing settings to generating content and retrieving information. ```APIDOC Command Reference: /help Description: Get command help. Example: /help /new Description: Initiate a new conversation. Example: /new /start Description: Get your ID and start a new conversation. Example: /start /img Description: Generate an image. Example: /img Image Description /version Description: Get the current version number and determine if an update is needed. Example: /version /setenv Description: Set user configuration. See `User Configuration` for details. Example: /setenv KEY=VALUE /setenvs Description: Batch setting user configuration. See `User Configuration` for details. Example: /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"} /delenv Description: Delete user configuration. Example: /delenv KEY /system Description: View some current system information. Example: /system /redo Description: Edit the previous question or provide a different answer. Example: /redo Modified content. or /redo /models Description: Switch chat model. After executing, select the model through the built-in menu. Example: /models /echo Description: Echo message, only available in development mode. Example: /echo ``` -------------------------------- ### Plugin Request Template Interfaces (TypeScript) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/PLUGINS.md Defines the structure for plugin requests, including input/output types, request methods, headers, query parameters, body content, and response handling. These interfaces guide the creation of plugin definitions. ```typescript /** * TemplateInputType: The type of input data, converting the data input from Telegram into the corresponding data type * json: JSON format * space-separated: Space-separated string * comma-separated: Comma-separated string * text: Text, not split (default value) */ export type TemplateInputType = 'json' | 'space-separated' | 'comma-separated' | 'text'; /** * TemplateBodyType: The type of the request body * json: JSON format, at this time the value of the content field should be an object, where the key is a fixed value, and the value supports interpolation * form: Form format, at this time the value of the content field should be an object, where the key is a fixed value, and the value supports interpolation * text: Text format, at this time the content field should be a string, supporting interpolation */ export type TemplateBodyType = 'json' | 'form' | 'text'; /** * TemplateResponseType: The type of response body * json: JSON format, at this time the response body will be parsed into JSON format and passed to the next template for rendering * text: Text format, at this time the response body will be parsed into text format and passed to the next template for rendering * blob: Binary format, at this time, the response body will be returned directly */ export type TemplateResponseType = 'json' | 'text'; /** * TemplateOutputType: The type of output data * text: Text format, sends the rendering result as plain text to Telegram * image: Image format, sends the rendering result as an image URL to Telegram * html: HTML format, sends the rendering result in HTML format to Telegram * markdown: Markdown format, sends the rendering result in Markdown format to Telegram */ export type TemplateOutputType = 'text' | 'image' | 'html' | 'markdown'; export interface RequestTemplate { url: string; // Required, supports interpolation method: string; // Required, fixed value headers: { [key: string]: string }; // Optional, Key is a fixed value, Value supports interpolation. input: { type: TemplateInputType; required: boolean; }; query: { [key: string]: string }; // Optional, Key is a fixed value, Value supports interpolation. body: { type: TemplateBodyType; content: { [key: string]: string } | string; // When content is an object, Key is a fixed value, and Value supports interpolation. When content is a string, it supports interpolation. }; response: { content: { // Required, handling when the request is successful. input_type: TemplateResponseType; output_type: TemplateOutputType; output: string; }; error: { // Required, handling when the request fails. input_type: TemplateResponseType; output_type: TemplateOutputType; output: string; }; }; } ``` -------------------------------- ### Custom Command Help Descriptions (TOML) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md This TOML configuration demonstrates how to associate descriptive text with custom commands. These descriptions are displayed when users request help, making custom commands more discoverable and understandable. ```toml COMMAND_DESCRIPTION_azure = '切换AI提供商为Azure' COMMAND_DESCRIPTION_workers = '切换AI提供商为Workers' COMMAND_DESCRIPTION_gpt3 = '切换AI提供商为OpenAI GPT-3.5 Turbo' COMMAND_DESCRIPTION_gpt4 = '切换AI提供商为OpenAI GPT-4' COMMAND_DESCRIPTION_cn2en = '将对话内容翻译成英文' ``` -------------------------------- ### OpenAI API Error: Model Overloaded Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Explains the 'That model is currently overloaded with other requests' error, indicating temporary instability or high demand for a specific OpenAI model. ```APIDOC OpenAI API Error: Model Overloaded Error Message: "That model is currently overloaded with other requests." Description: This message suggests that the specific OpenAI model you are trying to use is experiencing high demand and is temporarily overloaded. It points to instability on OpenAI's server-side. Resolution: Try again after a short delay. If the problem persists, consider using a different, less loaded model if available, or wait for OpenAI to resolve the issue. ``` -------------------------------- ### OpenAI API Error: Rate Limit Reached Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Addresses the 'Rate limit reached for default-gpt-3.5-turbo' error, which occurs when the API call frequency exceeds OpenAI's allowed limits. ```APIDOC OpenAI API Error: Rate Limit Reached Error Message: "Rate limit reached for default-gpt-3.5-turbo ..." Description: This error signifies that your account or IP address has made too many API requests within a given time frame, exceeding OpenAI's rate limits. This is a temporary restriction. Resolution: Slow down your API request frequency. Implement exponential backoff for retries. Consider upgrading your OpenAI plan if you consistently hit rate limits. ``` -------------------------------- ### Custom Command Help Descriptions (Environment Variables) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Help information for custom commands can be provided by setting environment variables prefixed with `COMMAND_DESCRIPTION_`. This allows users to see descriptions for custom commands when using a help command. ```APIDOC COMMAND_DESCRIPTION_XXX = 'Description for the command' ``` -------------------------------- ### Plugin Configuration Environment Variables (TOML) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/PLUGINS.md Illustrates how to configure plugins using environment variables. This includes mapping plugin commands to JSON definitions (URLs or files), providing descriptions, and setting the scope for plugin activation in Telegram chats. ```toml PLUGIN_COMMAND_dns = "https://raw.githubusercontent.com/TBXark/ChatGPT-Telegram-Workers/dev/plugins/dns.json" PLUGIN_DESCRIPTION_dns = "DNS query /dns " # Optional: Set the scope for the plugin # PLUGIN_SCOPE_dns = "all_private_chats,all_group_chats,all_chat_administrators" ``` -------------------------------- ### Addressing Slow Bot Replies Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Explains potential reasons for slow response times from the bot. These can include high demand on ChatGPT APIs, rate limiting on free accounts, or network latency. ```configuration Potential causes for slow replies: - High traffic on ChatGPT APIs leading to reduced response efficiency. - Rate limiting applied to free OpenAI accounts. - Network latency between Telegram and CloudFlare callbacks. ``` -------------------------------- ### OpenAI API Error: Too Many Requests Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Covers the 'Too many requests. Please slow down.' error, commonly associated with free tier limitations or high traffic impacting server stability. ```APIDOC OpenAI API Error: Too Many Requests Error Message: "Too many requests. Please slow down." Description: This error typically occurs with free tier accounts or when server load is extremely high, indicating that your request rate is too high for the current capacity. Resolution: Reduce the frequency of your requests. For free accounts, this might be a persistent limitation. Consider upgrading to a paid plan for higher rate limits and better stability. ``` -------------------------------- ### Configure and Deploy Next.js Worker Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/packages/apps/workers-next/README.md Instructions for deploying the experimental ChatGPT-Telegram-Workers-Next version. This involves updating the `wrangler.toml` file to point to the correct entry script and enabling Node.js compatibility, then executing the deployment command. ```toml main = "./src/entry/next/gen-vercel-env.ts" compatibility_flags = [ "nodejs_compat_v2" ] ``` ```bash wrangler deploy ``` -------------------------------- ### General Configuration Options Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Defines common configuration parameters applicable across different AI providers. These settings control the core AI provider selection, image provider, and system messages. ```APIDOC General Configuration: AI_PROVIDER Name: AI Provider Default: `auto` Description: Specifies the AI provider to use. Supported values: `auto`, `openai`, `azure`, `workers`, `gemini`, `mistral`, `cohere`, `anthropic`. AI_IMAGE_PROVIDER Name: AI Image Provider Default: `auto` Description: Specifies the AI image generation provider. Supported values: `auto`, `openai`, `azure`, `workers`. SYSTEM_INIT_MESSAGE Name: Global Default Initialization Message Default: `null` Description: Sets a global default initialization message for AI conversations. The default value is automatically selected based on the bound language. ~~SYSTEM_INIT_MESSAGE_ROLE~~ Name: Global Default Initialization Message Role Default: `system` Description: Deprecated. ``` -------------------------------- ### Model List Configuration for AI Providers Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md This section details how model lists can be configured for various AI providers. Models can be fetched from a URL or directly from a JSON array. Specific environment variables are used for each provider to specify the model list source. ```APIDOC AI Provider | Model List Configuration Item ----------------|------------------------------- openai | OPENAI_CHAT_MODELS_LIST workers | WORKERS_CHAT_MODELS_LIST mistral | MISTRAL_CHAT_MODELS_LIST cohere | COHERE_CHAT_MODELS_LIST azure | AZURE_CHAT_MODELS_LIST gemini | GOOGLE_COMPLETIONS_MODELS_LIST anthropic | ANTHROPIC_CHAT_MODELS_LIST ``` -------------------------------- ### OpenAI API Error: Internal Server Error Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Explains the 'Internal server error' message, which usually signifies issues on OpenAI's end, such as their API servers being overloaded or temporarily unavailable. ```APIDOC OpenAI API Error: Internal Server Error Error Message: "Internal server error" Description: This error typically means that OpenAI's API servers are experiencing high load or temporary outages. It is an issue on the provider's side. Resolution: Wait for a period and try again later. If the issue persists, check OpenAI's status page for any reported incidents. ``` -------------------------------- ### Interpolation Template Syntax Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/PLUGINS.md Demonstrates the core syntax for the interpolation template, including variable access, array traversal with aliases, conditional logic, and nested structures. It highlights the importance of correct syntax for parsing. ```html {{title}} {{#each item in items}} {{#each:item i in item}} {{i.value}} {{#if i.enable}} {{#if:sub i.subEnable}} sub enable {{#else:sub}} sub disable {{/if:sub}} {{#else}} disable {{/if}} {{/each:item}} {{/each}} ``` -------------------------------- ### Handling 4096 Token Context Length Limit Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Provides solutions for the 'This model's maximum context length is 4096 tokens' error. It involves enabling automatic history trimming and adjusting the maximum history length. ```configuration 1. Enable automatic trimming by setting `AUTO_TRIM_HISTORY` to `true`. 2. Adjust `MAX_HISTORY_LENGTH`. The default is 20. It is recommended not to set this value below 4. ``` -------------------------------- ### XAi Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the XAi model, including API key, base URL, and default chat model. ```APIDOC XAI_API_KEY: Description: XAi API Key Default: null XAI_API_BASE: Description: XAi API Base URL Default: https://api.x.ai XAI_CHAT_MODEL: Description: Default XAi API Chat Model Default: grok-2-latest XAI_CHAT_MODELS_LIST: Description: List of XAi chat models (comma-separated) Default: '' ``` -------------------------------- ### OpenAI API Error: Quota Exceeded Source: https://github.com/tbxark/chatgpt-telegram-workers/wiki/FAQ Details the 'You exceeded your current quota, please check your plan and billing details' error. This typically occurs when the usage limit for an OpenAI account with a linked credit card is reached. ```APIDOC OpenAI API Error: Quota Exceeded Error Message: "You exceeded your current quota, please check your plan and billing details." Description: This error indicates that your OpenAI account, which has a credit card linked, has reached its usage limit. This can happen due to high call frequency or exceeding allocated usage. Resolution: Navigate to your OpenAI account management portal to review your plan and billing details. Adjust your usage limits or upgrade your plan if necessary. ``` -------------------------------- ### Groq AI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the Groq AI model, including API key, base URL, and default chat model. ```APIDOC GROQ_API_KEY: Description: Groq API Key Default: null GROQ_API_BASE: Description: Groq API Base URL Default: https://api.groq.com/openai/v1 GROQ_CHAT_MODEL: Description: Default Groq API Chat Model Default: groq-chat GROQ_CHAT_MODELS_LIST: Description: List of Groq chat models (comma-separated) Default: '' ``` -------------------------------- ### Custom Commands Configuration (TOML) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md This snippet shows how to configure custom commands using TOML files. Each entry maps a custom command name (e.g., `CUSTOM_COMMAND_azure`) to its corresponding action, often involving setting environment variables for AI provider or model selection. ```toml CUSTOM_COMMAND_azure= '/setenvs {"AI_PROVIDER": "azure"}' CUSTOM_COMMAND_workers = '/setenvs {"AI_PROVIDER": "workers"}' CUSTOM_COMMAND_gpt3 = '/setenvs {"AI_PROVIDER": "openai", "OPENAI_CHAT_MODEL": "gpt-3.5-turbo"}' CUSTOM_COMMAND_gpt4 = '/setenvs {"AI_PROVIDER": "openai", "OPENAI_CHAT_MODEL": "gpt-4"}' CUSTOM_COMMAND_cn2en = '/setenvs {"SYSTEM_INIT_MESSAGE": "你是一个翻译下面将我说的话都翻译成英文"}' ``` -------------------------------- ### Gemini Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Configuration options for the Google Gemini AI provider, including API keys, model names, and base API URLs. ```APIDOC Gemini Configuration: GOOGLE_API_KEY Name: Google Gemini API Key Default: `null` Description: Your Google Gemini API key. GOOGLE_CHAT_MODEL Name: Google Gemini Model Default: `gemini-pro` Description: The default Gemini model to use for chat completions. GOOGLE_API_BASE Name: Gemini API Base (OpenAI Format) Default: `https://generativelanguage.googleapis.com/v1beta` Description: The base URL for Gemini API requests that support the OpenAI API format. GOOGLE_CHAT_MODELS_LIST Name: Google Chat Models List Default: `''` Description: A comma-separated list of Google Gemini chat models available for use. Note: Cloudflare Workers do not currently support access to Gemini. Deprecated Keys: ~~GOOGLE_COMPLETIONS_API~~ ~~GOOGLE_COMPLETIONS_MODEL~~ ``` -------------------------------- ### Azure OpenAI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Configuration parameters for integrating with Azure OpenAI services, including API keys, resource names, and model deployments. ```APIDOC Azure OpenAI Configuration: AZURE_API_KEY Name: Azure API Key Default: `null` Description: The API key for accessing Azure OpenAI services. AZURE_RESOURCE_NAME Name: Azure Resource Name Default: `null` Description: The name of the Azure OpenAI resource. AZURE_CHAT_MODEL Name: Azure Chat Model Default: `null` Description: The name of the Azure OpenAI deployment for chat completions. AZURE_IMAGE_MODEL Name: Azure Image Model Default: `null` Description: The name of the Azure OpenAI deployment for image generation. AZURE_API_VERSION Name: Azure API Version Default: `2024-06-01` Description: The API version to use for Azure OpenAI requests. AZURE_CHAT_MODELS_LIST Name: Azure Chat Models List Default: `''` Description: A comma-separated list of Azure chat models available for use. API Endpoints: AZURE_COMPLETIONS_API: `https://RESOURCE_NAME.openai.azure.com/openai/deployments/MODEL_NAME/chat/completions?api-version=VERSION_NAME` AZURE_DALLE_API: `https://RESOURCE_NAME.openai.azure.com/openai/deployments/MODEL_NAME/images/generations?api-version=VERSION_NAME` Deprecated Keys: ~~AZURE_COMPLETIONS_API~~ ~~AZURE_DALLE_API~~ ``` -------------------------------- ### Add Custom Command Descriptions (TOML) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/CONFIG.md This snippet shows how to associate descriptive help text with custom commands using TOML configuration. Environment variables prefixed with COMMAND_DESCRIPTION_XXX provide a human-readable explanation for each custom command, which can be accessed via a `/help` command. ```toml COMMAND_DESCRIPTION_azure = 'Switch AI provider to Azure.' COMMAND_DESCRIPTION_workers = 'Switch AI provider to Workers' COMMAND_DESCRIPTION_gpt3 = 'Switch AI provider to OpenAI GPT-3.5 Turbo.' COMMAND_DESCRIPTION_gpt4 = 'Switch AI provider to OpenAI GPT-4.' COMMAND_DESCRIPTION_cn2en = 'Translate the conversation content into English.' ``` -------------------------------- ### Mistral AI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the Mistral AI model, including API key, base URL, and default chat model. ```APIDOC MISTRAL_API_KEY: Description: Mistral API Key Default: null MISTRAL_API_BASE: Description: Mistral API Base URL Default: https://api.mistral.ai/v1 MISTRAL_CHAT_MODEL: Description: Default Mistral API Chat Model Default: mistral-tiny MISTRAL_CHAT_MODELS_LIST: Description: List of Mistral chat models (comma-separated) Default: '' ``` -------------------------------- ### DeepSeek AI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the DeepSeek AI model, including API key, base URL, and default chat model. ```APIDOC DEEPSEEK_API_KEY: Description: DeepSeek API Key Default: null DEEPSEEK_API_BASE: Description: DeepSeek API Base URL Default: https://api.deepseek.com DEEPSEEK_CHAT_MODEL: Description: Default DeepSeek API Chat Model Default: deepseek-chat DEEPSEEK_CHAT_MODELS_LIST: Description: List of DeepSeek chat models (comma-separated) Default: '' ``` -------------------------------- ### Cohere AI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the Cohere AI model, including API key, base URL, and default chat model. ```APIDOC COHERE_API_KEY: Description: Cohere API Key Default: null COHERE_API_BASE: Description: Cohere API Base URL Default: https://api.cohere.com/v1 COHERE_CHAT_MODEL: Description: Default Cohere API Chat Model Default: command-r-plus COHERE_CHAT_MODELS_LIST: Description: List of Cohere chat models (comma-separated) Default: '' ``` -------------------------------- ### Dall-e Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Settings for configuring the Dall-E image generation models, including model selection, image size, quality, and style. ```APIDOC Dall-e Configuration: DALL_E_MODEL Name: DALL-E Model Name Default: `dall-e-3` Description: The Dall-E model to use for image generation. DALL_E_IMAGE_SIZE Name: DALL-E Image Size Default: `1024x1024` Description: The desired resolution for generated images. DALL_E_IMAGE_QUALITY Name: DALL-E Image Quality Default: `standard` Description: The quality setting for generated images (e.g., `standard`, `hd`). DALL_E_IMAGE_STYLE Name: DALL-E Image Style Default: `vivid` Description: The artistic style for generated images (e.g., `vivid`, `natural`). DALL_E_MODELS_LIST Name: DALL-E Model List Default: `''` Description: A comma-separated list of Dall-E models available for use. ``` -------------------------------- ### Anthropic AI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Environment variables for configuring the Anthropic AI model, including API key, base URL, and default chat model. ```APIDOC ANTHROPIC_API_KEY: Description: Anthropic API Key Default: null ANTHROPIC_API_BASE: Description: Anthropic API Base URL Default: https://api.anthropic.com/v1 ANTHROPIC_CHAT_MODEL: Description: Default Anthropic API Chat Model Default: claude-3-haiku-20240307 ANTHROPIC_CHAT_MODELS_LIST: Description: List of Anthropic chat models (comma-separated) Default: '' ``` -------------------------------- ### OpenAI Configuration Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/cn/CONFIG.md Configuration settings specific to the OpenAI provider, including API keys, model names, and custom API parameters. ```APIDOC OpenAI Configuration: OPENAI_API_KEY Name: OpenAI API Key Default: `''` (array string) Description: The API key(s) for accessing OpenAI services. OPENAI_CHAT_MODEL Name: OpenAI Model Name Default: `gpt-4o-mini` Description: The default OpenAI model to use for chat completions. OPENAI_API_BASE Name: OpenAI API BASE Default: `https://api.openai.com/v1` Description: The base URL for the OpenAI API endpoint. OPENAI_API_EXTRA_PARAMS Name: OpenAI API Extra Params Default: `{}` Description: Additional parameters to pass to the OpenAI API requests. OPENAI_CHAT_MODELS_LIST Name: OpenAI Model List Default: `''` Description: A comma-separated list of OpenAI models available for use. ``` -------------------------------- ### General Configuration Parameters Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/CONFIG.md Core configuration settings that define the AI provider, image provider, and initial system messages. These settings dictate the primary AI services and default behavior. ```APIDOC General Configuration: AI_PROVIDER: Name: AI provider Default: `auto` Options: `auto, openai, azure, workers, gemini, mistral, cohere, anthropic` Description: Specifies the AI provider to use. AI_IMAGE_PROVIDER: Name: AI image provider Default: `auto` Options: `auto, openai, azure, workers` Description: Specifies the AI image generation provider to use. SYSTEM_INIT_MESSAGE: Name: Default initialization message. Default: `null` Description: Sets the default initialization message. Automatically selects values based on the bound language. SYSTEM_INIT_MESSAGE_ROLE: Name: Default initialization message role. Default: `system` Description: Deprecated. ``` -------------------------------- ### Define Custom Commands (TOML) Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/CONFIG.md This snippet demonstrates how to define custom shortcut commands using TOML configuration. Environment variables prefixed with CUSTOM_COMMAND_XXX map a short command to a longer command string, typically used for setting environment variables like AI provider or model. ```toml CUSTOM_COMMAND_azure= '/setenvs {"AI_PROVIDER": "azure"}' CUSTOM_COMMAND_workers = '/setenvs {"AI_PROVIDER": "workers"}' CUSTOM_COMMAND_gpt3 = '/setenvs {"AI_PROVIDER": "openai", "OPENAI_CHAT_MODEL": "gpt-3.5-turbo"}' CUSTOM_COMMAND_gpt4 = '/setenvs {"AI_PROVIDER": "openai", "OPENAI_CHAT_MODEL": "gpt-4"}' CUSTOM_COMMAND_cn2en = '/setenvs {"SYSTEM_INIT_MESSAGE": "You are a translator. Please translate everything I say below into English."}' ``` -------------------------------- ### LLM Provider Environment Variables Source: https://github.com/tbxark/chatgpt-telegram-workers/blob/master/doc/en/CONFIG.md Configuration settings for integrating with various Large Language Model providers. These environment variables define API keys, base URLs, and default models for each service, enabling the bot to connect and utilize their capabilities. ```APIDOC Cohere Configuration: COHERE_API_KEY: Cohere API Key (null by default) COHERE_API_BASE: Cohere API Base URL (https://api.cohere.com/v1 by default) COHERE_CHAT_MODEL: Cohere API Model (command-r-plus by default) COHERE_CHAT_MODELS_LIST: List of Cohere Chat Models (empty string by default) Anthropic Configuration: ANTHROPIC_API_KEY: Anthropic API Key (null by default) ANTHROPIC_API_BASE: Anthropic API Base URL (https://api.anthropic.com/v1 by default) ANTHROPIC_CHAT_MODEL: Anthropic API Model (null by default) ANTHROPIC_CHAT_MODELS_LIST: List of Anthropic Chat Models (empty string by default) Groq Configuration: GROQ_API_KEY: Groq API Key (null by default) GROQ_API_BASE: Groq API Base URL (https://api.groq.com/openai/v1 by default) GROQ_CHAT_MODEL: Groq API Model (groq-chat by default) GROQ_CHAT_MODELS_LIST: List of Groq Chat Models (empty string by default) DeepSeek Configuration: DEEPSEEK_API_KEY: DeepSeek API Key (null by default) DEEPSEEK_API_BASE: DeepSeek API Base URL (https://api.deepseek.com by default) DEEPSEEK_CHAT_MODEL: DeepSeek API Model (deepseek-chat by default) DEEPSEEK_CHAT_MODELS_LIST: List of DeepSeek Chat Models (empty string by default) XAi Configuration: XAI_API_KEY: XAi API Key (null by default) XAI_API_BASE: XAi API Base URL (https://api.x.ai by default) XAI_CHAT_MODEL: XAi API Model (grok-2-latest by default) XAI_CHAT_MODELS_LIST: XAi Chat Model List (empty string by default) ```