Skip to content
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

feat: Adding DALLE image generator #8448

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

feat: Adding DALLE image generator #8448

wants to merge 11 commits into from

Conversation

sjrl
Copy link
Contributor

@sjrl sjrl commented Oct 9, 2024

Related Issues

  • fixes #issue-number

Proposed Changes:

Adds DALLEImageGenerator which calls OpenAI's image generation endpoint to generate images based on a prompt.

How did you test it?

Added unit tests, more to come.

Notes for the reviewer

Checklist

@github-actions github-actions bot added topic:tests type:documentation Improvements on the docs labels Oct 9, 2024
@coveralls
Copy link
Collaborator

coveralls commented Oct 10, 2024

Pull Request Test Coverage Report for Build 11404564212

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 90.332%

Totals Coverage Status
Change from base Build 11400399865: 0.02%
Covered Lines: 7512
Relevant Lines: 8316

💛 - Coveralls

@sjrl sjrl marked this pull request as ready for review October 18, 2024 11:31
@sjrl sjrl requested review from a team as code owners October 18, 2024 11:31
@sjrl sjrl requested review from dfokina, Amnah199 and silvanocerza and removed request for a team October 18, 2024 11:31
Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
Comment on lines +79 to +90
def warm_up(self) -> None:
"""
Warm up the OpenAI client.
"""
if self.client is None:
self.client = OpenAI(
api_key=self.api_key.resolve_value(),
organization=self.organization,
base_url=self.api_base_url,
timeout=self.timeout,
max_retries=self.max_retries,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we initialize the client in __init__? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to, I think it's better not to have to resolve the API key at init time. And only expect it at warm_up/run time.

If we put it in in the init it makes it hard to validate pipelines since we have to 1) make sure an api key is present and 2) when initializing the client I believe it complains if it is given an incorrect API key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, we should probably create an issue to do the same for other Components.

Copy link
Contributor

@silvanocerza silvanocerza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, though I'm wondering if it would be better to return a list of ByteStreams that contain the images. 🤔

@sjrl
Copy link
Contributor Author

sjrl commented Oct 18, 2024

It looks good, though I'm wondering if it would be better to return a list of ByteStreams that contain the images. 🤔

Hmm interesting point, I'd rather wait on that when we have the conversation about how Haystack could generally support passing around images.

For now this is just outputting directly the format from OpenAI.

@sjrl
Copy link
Contributor Author

sjrl commented Oct 18, 2024

Also passing it back as a url or base64 it allows for embedding in markdown to view the image right away :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants