1818from yandex_cloud_ml_sdk ._types .misc import UNDEFINED , UndefinedOr
1919from yandex_cloud_ml_sdk ._types .model import ModelAsyncMixin , OperationTypeT
2020from yandex_cloud_ml_sdk ._types .operation import AsyncOperation , Operation
21+ from yandex_cloud_ml_sdk ._utils .doc import doc_from
2122from yandex_cloud_ml_sdk ._utils .sync import run_sync
2223
2324from .config import ImageGenerationModelConfig
2829class BaseImageGenerationModel (
2930 ModelAsyncMixin [ImageGenerationModelConfig , ImageGenerationModelResult , OperationTypeT ],
3031):
32+ """A class of the one, concrete model. This model encapsulates the URI and configuration."""
3133 _config_type = ImageGenerationModelConfig
3234 _result_type = ImageGenerationModelResult
3335 _operation_type : type [OperationTypeT ]
@@ -41,6 +43,16 @@ def configure( # type: ignore[override]
4143 height_ratio : UndefinedOr [int ] = UNDEFINED ,
4244 mime_type : UndefinedOr [str ] = UNDEFINED ,
4345 ) -> Self :
46+ """
47+ Configures the image generation model with specified parameters and
48+ returns the configured instance of the model.
49+
50+ :param seed: a random seed for generation.
51+ :param width_ratio: the width ratio for the generated image.
52+ :param height_ratio: the height ratio for the generated image.
53+ :param mime_type: the MIME type of the generated image.
54+ Read more on what MIME types exist in `the documentation <https://yandex.cloud/docs/foundation-models/image-generation/api-ref/ImageGenerationAsync/generate>`_.
55+ """
4456 return super ().configure (
4557 seed = seed ,
4658 width_ratio = width_ratio ,
@@ -83,6 +95,7 @@ async def _run_deferred(
8395 )
8496
8597
98+ @doc_from (BaseImageGenerationModel )
8699class AsyncImageGenerationModel (BaseImageGenerationModel [AsyncOperation [ImageGenerationModelResult ]]):
87100 _operation_type = AsyncOperation [ImageGenerationModelResult ]
88101
@@ -92,6 +105,13 @@ async def run_deferred(
92105 * ,
93106 timeout : float = 60 ,
94107 ) -> AsyncOperation [ImageGenerationModelResult ]:
108+ """Executes the image generation operation asynchronously
109+ and returns an operation representing the ongoing image generation process.
110+
111+ :param messages: the input messages for image generation.
112+ :param timeout: the timeout, or the maximum time to wait for the request to complete in seconds.
113+ Defaults to 60 seconds.
114+ """
95115 return await self ._run_deferred (
96116 messages = messages ,
97117 timeout = timeout
@@ -102,14 +122,22 @@ async def attach_deferred(
102122 operation_id : str ,
103123 timeout : float = 60 ,
104124 ) -> AsyncOperation [ImageGenerationModelResult ]:
125+ """Attaches to an ongoing image generation operation.
126+
127+ :param operation_id: the ID of the operation to attach to.
128+ :param timeout: the timeout, or the maximum time to wait for the request to complete in seconds.
129+ Defaults to 60 seconds.
130+ """
105131 return await self ._attach_deferred (operation_id = operation_id , timeout = timeout )
106132
107133
134+ @doc_from (BaseImageGenerationModel )
108135class ImageGenerationModel (BaseImageGenerationModel [Operation [ImageGenerationModelResult ]]):
109136 _operation_type = Operation [ImageGenerationModelResult ]
110137 __run_deferred = run_sync (BaseImageGenerationModel [Operation [ImageGenerationModelResult ]]._run_deferred )
111138 __attach_deferred = run_sync (BaseImageGenerationModel [Operation [ImageGenerationModelResult ]]._attach_deferred )
112139
140+ @doc_from (AsyncImageGenerationModel .run_deferred )
113141 def run_deferred (
114142 self ,
115143 messages : ImageMessageInputType ,
@@ -122,6 +150,7 @@ def run_deferred(
122150 timeout = timeout
123151 )
124152
153+ @doc_from (AsyncImageGenerationModel .attach_deferred )
125154 def attach_deferred (self , operation_id : str , timeout : float = 60 ) -> Operation [ImageGenerationModelResult ]:
126155 return cast (
127156 Operation [ImageGenerationModelResult ],
0 commit comments