-
Notifications
You must be signed in to change notification settings - Fork 68
Add Provider : Leonardo #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
"prompt": text, | ||
"width": int(size[0]), | ||
"height": int(size[1]), | ||
"modelId": get_model_id_image.get(model, model), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just didn't really understand this ? :
get_model_id_image.get(model, model)
you want to keep the model as a name is case of the model not in the dictionary ?
url = f"{self.base_url}/generations" | ||
|
||
response_dict = LeonardoApi.__get_response(self, url, payload) | ||
image_url = [image.get('url') for image in response_dict.get('generations_by_pk', {}).get('generated_images', [])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have used the function I showed once, that retrieve data inside a dictionary while handling the None or Key not found errors
"width": int(size[0]), | ||
"height": int(size[1]), | ||
"modelId": get_model_id_image.get(model, model), | ||
"num_images": num_images, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this comment is relevant, as we should already limit in the back the number of images that a user can retrieve, but I think it would be good if we limit here also in case of
url = f"{self.base_url}/generations" | ||
|
||
response_dict = LeonardoApi.__get_response(self, url, payload) | ||
image_url = [image.get('url') for image in response_dict.get('generations_by_pk', {}).get('generated_images', [])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
self, url: str, payload: dict | ||
) -> Union[Generator, dict]: | ||
# Launch job | ||
launch_job_response = requests.post(url, headers=self.headers, json=payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can here also add a try catch like for the previous one, to catch unexpected errors like timeout errors
No description provided.