# Base client
from ....base import OpenAI_Image_Client

# Mixin
from ....mixins import Image_Context_Manager_Mixin

# Typing
from ....enums.image_response_formats import IMAGE_RESPONSE_FORMAT

# Example concrete image clients using overrides
class URL_Image_Client(OpenAI_Image_Client, Image_Context_Manager_Mixin):
    """ Generate images from a prompt and return a URL to the image """

    def run_prompt(self, prompt:str, number_of_images:int=None, size=None):
        """ Sends a prompt to OpenAPI to be generated by DALLE. You can specify the 
            number of images to generate and the dimensions of the image.
             
            If more than one image should be generated, this method will return a list of URLs 
            or b64 JSON for each image. 
        """

        # Allow the number_of_images to generate and image size to be specified per call, 
        # but fall back on defaults
        number_of_images = number_of_images or self._number_of_images
        size = self.check_size(size or self._size)

        result = self._api.create(prompt=self.get_prompt_with_context(prompt), n=number_of_images, size=size, response_format=self._response_format)

        return self.process_response(number_of_images, result)


# Example concrete image clients using overrides
class B64_JSON_Image_Client(URL_Image_Client):
    """ Generate images from a prompt and return the image in b64 JSON"""

    _response_format = IMAGE_RESPONSE_FORMAT.B64_JSON.value