Update OpenAI configuration with ImageModel and related changes
Previously, there was no option to specify the model for image generation in the OpenAI configuration. This commit adds a new option called "ImageModel" where you can specify the desired model. The default value for this option is "dall-e-2". In the `GPTBot` class, the OpenAI object is now initialized with the `ImageModel` option if it is provided in the configuration. This allows the bot to use the specified image generation model in addition to the chat model. Furthermore, in the `OpenAI` class, the `image_api` attribute has been renamed to `image_model` to reflect its purpose more accurately. The default value has also been updated to "dall-e-2" to align with the new configuration option. This commit ensures that the OpenAI configuration is up-to-date and allows users to specify the desired image generation model.
This commit is contained in:
parent
d2c6682faa
commit
5a1a3733c5
3 changed files with 9 additions and 3 deletions
|
@ -67,6 +67,10 @@ LogLevel = info
|
|||
#
|
||||
# Model = gpt-3.5-turbo
|
||||
|
||||
# The Image Generation model you want to use.
|
||||
#
|
||||
# ImageModel = dall-e-2
|
||||
|
||||
# Your OpenAI API key
|
||||
#
|
||||
# Find this in your OpenAI account:
|
||||
|
|
|
@ -138,7 +138,8 @@ class GPTBot:
|
|||
bot.allowed_users = json.loads(config["GPTBot"]["AllowedUsers"])
|
||||
|
||||
bot.chat_api = bot.image_api = bot.classification_api = OpenAI(
|
||||
config["OpenAI"]["APIKey"], config["OpenAI"].get("Model"), bot.logger
|
||||
config["OpenAI"]["APIKey"], config["OpenAI"].get("Model"),
|
||||
config["OpenAI"].get("ImageModel"), bot.logger
|
||||
)
|
||||
bot.max_tokens = config["OpenAI"].getint("MaxTokens", bot.max_tokens)
|
||||
bot.max_messages = config["OpenAI"].getint("MaxMessages", bot.max_messages)
|
||||
|
|
|
@ -21,11 +21,11 @@ class OpenAI:
|
|||
return self.chat_model
|
||||
|
||||
classification_api = chat_api
|
||||
image_api: str = "dalle"
|
||||
image_model: str = "dall-e-2"
|
||||
|
||||
operator: str = "OpenAI ([https://openai.com](https://openai.com))"
|
||||
|
||||
def __init__(self, api_key, chat_model=None, logger=None):
|
||||
def __init__(self, api_key, chat_model=None, image_model=None, logger=None):
|
||||
self.api_key = api_key
|
||||
self.chat_model = chat_model or self.chat_model
|
||||
self.logger = logger or Logger()
|
||||
|
@ -146,6 +146,7 @@ Only the event_types mentioned above are allowed, you must not respond in any ot
|
|||
|
||||
image_partial = partial(
|
||||
openai.Image.acreate,
|
||||
model=self.image_model,
|
||||
prompt=prompt,
|
||||
n=1,
|
||||
api_key=self.api_key,
|
||||
|
|
Loading…
Reference in a new issue