diff --git a/.env.example b/.env.example index d6eb078..c0caaa3 100644 --- a/.env.example +++ b/.env.example @@ -34,6 +34,9 @@ ALLOWED_TELEGRAM_USER_IDS=USER_ID_1,USER_ID_2 # TEMPERATURE=1.0 # PRESENCE_PENALTY=0.0 # FREQUENCY_PENALTY=0.0 +# IMAGE_MODEL=dall-e-3 +# IMAGE_QUALITY=hd +# IMAGE_STYLE=natural # IMAGE_SIZE=512x512 # GROUP_TRIGGER_KEYWORD="" # IGNORE_GROUP_TRANSCRIPTIONS=true diff --git a/README.md b/README.md index 34e23b3..b896c59 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,10 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di | `TEMPERATURE` | Number between 0 and 2. Higher values will make the output more random | `1.0` | | `PRESENCE_PENALTY` | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far | `0.0` | | `FREQUENCY_PENALTY` | Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far | `0.0` | -| `IMAGE_SIZE` | The DALL·E generated image size. Allowed values: `256x256`, `512x512` or `1024x1024` | `512x512` | +| `IMAGE_MODEL` | The DALL·E model to be used. Available models: `dall-e-2` and `dall-e-3`, find current available models [here](https://platform.openai.com/docs/models/dall-e) | `dall-e-2` | +| `IMAGE_QUALITY` | Quality of DALL·E images, only available for `dall-e-3`-model. Possible options: `standard` or `hd`, beware of [pricing differences](https://openai.com/pricing#image-models). | `standard` | +| `IMAGE_STYLE` | Style for DALL·E image generation, only available for `dall-e-3`-model. Possible options: `vivid` or `natural`. Check availbe styles [here](https://platform.openai.com/docs/api-reference/images/create). | `vivid` | +| `IMAGE_SIZE` | The DALL·E generated image size. Must be `256x256`, `512x512`, or `1024x1024` for dall-e-2. Must be `1024x1024`, `1792x1024`, or `1024x1792` for dall-e-3 models. | `512x512` | | `GROUP_TRIGGER_KEYWORD` | If set, the bot in group chats will only respond to messages that start with this keyword | - | | `IGNORE_GROUP_TRANSCRIPTIONS` | If set to true, the bot will not process transcriptions in group chats | `true` | | `BOT_LANGUAGE` | Language of general bot messages. Currently available: `en`, `de`, `ru`, `tr`, `it`, `fi`, `es`, `id`, `nl`, `zh-cn`, `zh-tw`, `vi`, `fa`, `pt-br`, `uk`, `ms`. [Contribute with additional translations](https://github.com/n3d1117/chatgpt-telegram-bot/discussions/219) | `en` | diff --git a/bot/main.py b/bot/main.py index d7605fd..3fe43af 100644 --- a/bot/main.py +++ b/bot/main.py @@ -41,6 +41,9 @@ def main(): 'max_tokens': int(os.environ.get('MAX_TOKENS', max_tokens_default)), 'n_choices': int(os.environ.get('N_CHOICES', 1)), 'temperature': float(os.environ.get('TEMPERATURE', 1.0)), + 'image_model': os.environ.get('IMAGE_MODEL', 'dall-e-2'), + 'image_quality': os.environ.get('IMAGE_QUALITY', 'standard'), + 'image_style': os.environ.get('IMAGE_STYLE', 'vivid'), 'image_size': os.environ.get('IMAGE_SIZE', '512x512'), 'model': model, 'enable_functions': os.environ.get('ENABLE_FUNCTIONS', str(functions_available)).lower() == 'true', diff --git a/bot/openai_helper.py b/bot/openai_helper.py index b24687d..40e6b4b 100644 --- a/bot/openai_helper.py +++ b/bot/openai_helper.py @@ -324,6 +324,9 @@ class OpenAIHelper: response = await openai.Image.acreate( prompt=prompt, n=1, + model=self.config['image_model'], + quality=self.config['image_quality'], + style=self.config['image_style'], size=self.config['image_size'] )