Skip to content

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

Merged
merged 4 commits into from
Dec 3, 2024
Merged

Conversation

AlexandrePrivat
Copy link
Contributor

No description provided.

"prompt": text,
"width": int(size[0]),
"height": int(size[1]),
"modelId": get_model_id_image.get(model, model),
Copy link
Contributor

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', [])]
Copy link
Contributor

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,
Copy link
Contributor

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', [])]
Copy link
Contributor

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)
Copy link
Contributor

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

@DninoAdnane DninoAdnane merged commit 37fa0a2 into edenai:master Dec 3, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants