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

Look to delay image generation when using the Media Inserter #561

Closed
1 task done
dkotter opened this issue Aug 10, 2023 · 0 comments · Fixed by #569
Closed
1 task done

Look to delay image generation when using the Media Inserter #561

dkotter opened this issue Aug 10, 2023 · 0 comments · Fixed by #569
Assignees
Labels
type:enhancement New feature or request.
Milestone

Comments

@dkotter
Copy link
Collaborator

dkotter commented Aug 10, 2023

Is your enhancement related to a problem? Please describe.

In #535, we added an integration into the Media Inserter that allows you to generate and insert images straight from that inserter. At the moment, the code that added the ability to interact with this Media Inserter is only in the Gutenberg plugin (assuming this will end up in WordPress 6.4) and we only have the ability to define the fetch function.

What this means is that as someone types in their image prompt, Gutenberg itself will slightly debounce this request (currently at 250ms) before calling our custom fetch function. In reality, the debounce here is so small that as someone types in their image prompt, almost certainly we'll end up hitting the OpenAI API multiple times (and as such, be charged for each of those requests).

I had tried adding our own debouncing around this fetch function but I couldn't get it to work, I think because this function is already being debounced by Gutenberg itself. I see a few possibilities we could pursue here:

  1. Continue investigating if we can add our own debouncing here, setting that to something higher to increase the likelihood that we only send a request once a user is truly done typing
  2. Open an issue on the Gutenberg side to see if we could get an option added where you could choose between having search triggered on type or search triggered on a button submit, which the latter would solve our needs
  3. Open an issue on the Gutenberg side to see if we can make the current debounce value filterable so we can increase that. Won't definitively solve the problem but we can try increasing that value high enough that it should solve it for most

Not sure how receptive the Gutenberg team will be to changes with this component but I do think either option would be useful for anyone that wants to integrate a 3rd party service with this Media Inserter, so not something that just helps ClassifAI.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@dkotter dkotter added the type:enhancement New feature or request. label Aug 10, 2023
@dkotter dkotter added this to the Future Release milestone Aug 10, 2023
@Sidsector9 Sidsector9 self-assigned this Aug 18, 2023
@dkotter dkotter modified the milestones: Future Release, 2.3.0 Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants