Skip to content

ImgGen Component #4

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

Open
jchris opened this issue May 3, 2025 · 0 comments
Open

ImgGen Component #4

jchris opened this issue May 3, 2025 · 0 comments
Assignees

Comments

@jchris
Copy link
Contributor

jchris commented May 3, 2025

Details: https://chatgpt.com/share/68162ad3-ae98-8003-b65e-50fb09084b21

🖼️ ImgGen Component: Progressive Streaming + On-Demand Download

Why

We want to create a React component <ImgGen /> to simplify working with callAI's imageGen function and provide a better user experience. The goals are:

  • Progressive loading: Stream and display the generated images progressively if a URL is available (like in ChatGPT), for faster visual feedback.
  • Conditional generation: Only trigger image generation if the onData callback is present, avoiding unnecessary API calls.
  • Reactive updates: Automatically regenerate the image if prompt or options props change.
  • Placeholder handling: Show a properly sized placeholder while the image is loading to prevent layout shifts.
  • Data capture: Allow consuming apps to receive the raw ImageResponse via onData for caching or post-processing.

How

Usage Example

<ImgGen prompt="a cat peeling a banana" options={optionsObject} onData={handleData} />

Proposed Features

  • Accept prompt (required), options (optional), and onData (optional).
  • Do not trigger generation unless onData is provided.
  • When triggered, call imageGen using prompt and options.
  • If response includes url, show the progressive image via <img src="url" />.
  • If response includes b64_json only, fallback to data:image/png;base64,....
  • Use size option to determine placeholder dimensions.
  • When the image is fully loaded, optionally allow download (future enhancement).
  • Call onData with the full ImageResponse once available.
  • Regenerate the image on prompt or options change (reactive design).
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

No branches or pull requests

1 participant