From c3ea7d5797d250fdc3898b548b8ac140952a3daf Mon Sep 17 00:00:00 2001 From: Keller18306 Date: Sun, 3 Dec 2023 16:36:52 +0300 Subject: [PATCH] split proxy --- README.md | 4 +++- bot/main.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c1479b2f..435499d2 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,9 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di | `ENABLE_IMAGE_GENERATION` | Whether to enable image generation via the `/image` command | `true` | | `ENABLE_TRANSCRIPTION` | Whether to enable transcriptions of audio and video messages | `true` | | `ENABLE_TTS_GENERATION` | Whether to enable text to speech generation via the `/tts` | `true` | -| `PROXY` | Proxy to be used for OpenAI and Telegram bot (e.g. `http://localhost:8080`) | - | +| `PROXY` | Proxy to be used for OpenAI and Telegram bot (e.g. `http://localhost:8080`) | - | +| `OPENAI_PROXY` | Proxy to be used only for OpenAI (e.g. `http://localhost:8080`) | - | +| `TELEGRAM_PROXY` | Proxy to be used only for Telegram bot (e.g. `http://localhost:8080`) | - | | `OPENAI_MODEL` | The OpenAI model to use for generating responses. You can find all available models [here](https://platform.openai.com/docs/models/) | `gpt-3.5-turbo` | | `OPENAI_BASE_URL` | Endpoint URL for unofficial OpenAI-compatible APIs (e.g., LocalAI or text-generation-webui) | Default OpenAI API URL | | `ASSISTANT_PROMPT` | A system message that sets the tone and controls the behavior of the assistant | `You are a helpful assistant.` | diff --git a/bot/main.py b/bot/main.py index 2511234e..ed6c901d 100644 --- a/bot/main.py +++ b/bot/main.py @@ -34,7 +34,7 @@ def main(): 'api_key': os.environ['OPENAI_API_KEY'], 'show_usage': os.environ.get('SHOW_USAGE', 'false').lower() == 'true', 'stream': os.environ.get('STREAM', 'true').lower() == 'true', - 'proxy': os.environ.get('PROXY', None), + 'proxy': os.environ.get('PROXY', None) or os.environ.get('OPENAI_PROXY', None), 'max_history_size': int(os.environ.get('MAX_HISTORY_SIZE', 15)), 'max_conversation_age_minutes': int(os.environ.get('MAX_CONVERSATION_AGE_MINUTES', 180)), 'assistant_prompt': os.environ.get('ASSISTANT_PROMPT', 'You are a helpful assistant.'), @@ -80,7 +80,7 @@ def main(): 'user_budgets': os.environ.get('USER_BUDGETS', os.environ.get('MONTHLY_USER_BUDGETS', '*')), 'guest_budget': float(os.environ.get('GUEST_BUDGET', os.environ.get('MONTHLY_GUEST_BUDGET', '100.0'))), 'stream': os.environ.get('STREAM', 'true').lower() == 'true', - 'proxy': os.environ.get('PROXY', None), + 'proxy': os.environ.get('PROXY', None) or os.environ.get('TELEGRAM_PROXY', None), 'voice_reply_transcript': os.environ.get('VOICE_REPLY_WITH_TRANSCRIPT_ONLY', 'false').lower() == 'true', 'voice_reply_prompts': os.environ.get('VOICE_REPLY_PROMPTS', '').split(';'), 'ignore_group_transcriptions': os.environ.get('IGNORE_GROUP_TRANSCRIPTIONS', 'true').lower() == 'true',