-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 11478683480Details
💛 - Coveralls |
Co-authored-by: Silvano Cerza <[email protected]>
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, | ||
) |
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.
Can't we initialize the client in __init__
? 🤔
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'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.
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.
Good point, we should probably create an issue to do the same for other Components.
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.
It looks good, though I'm wondering if it would be better to return a list of ByteStream
s 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. |
Also passing it back as a url or base64 it allows for embedding in markdown to view the image right away :) |
Related Issues
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
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.