From c238da9b9950c4ecd6eef4dc5408c219c2480680 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 11 Nov 2023 09:51:28 +0100 Subject: [PATCH] openai: Fix image_model assignment, add method to check if the used chat model supports images messages --- src/gptbot/classes/openai.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gptbot/classes/openai.py b/src/gptbot/classes/openai.py index 7732373..97741d3 100644 --- a/src/gptbot/classes/openai.py +++ b/src/gptbot/classes/openai.py @@ -28,9 +28,13 @@ class OpenAI: 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.image_model = image_model or self.image_model self.logger = logger or Logger() self.base_url = openai.api_base + def supports_chat_images(self): + return "vision" in self.chat_model + async def _request_with_retries(self, request: partial, attempts: int = 5, retry_interval: int = 2) -> AsyncGenerator[Any | list | Dict, None]: """Retry a request a set number of times if it fails.