I am trying to create a "Summarize" button so clients can click that button to get a summary of thier post to populate a field.
I have created a augmentor field using OpenAI GPT3 Augmentor configured to generate only one completion for the propt and when we click the "Summarize" button we got multiple summary returned.
Looking at the augmentor_library.js file I see that it doesn't use "once" like it is explained in javascript api overview page on drupal.org (https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-overview)
When I edit the code to use once, i t works properly and return one summary. Is this absence of "once" intentional or not, is it a bug?
Issue fork augmentor-3357590
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
murrayw commentedAugmentors can return an array of options for a key, eg "default". This structure was decided on so that different options could be displayed to the user as a convenience. The UI will display the options if they are available. I do not believe it to be a bug.
I will hand over to Eleo who can provide more insight and expand on this answer.
Comment #4
hyperlinkedI do believe this warrants the use of the once method. I can't see any reason why this block of code has to be invoked numerous times. I've been testing this on a complex site and it was running more than five redundant API calls after the initial results were processed.
I've created an issue fork to address this. My fork adds core/jquery.once to the library depdendencies and uses .once to only cycle through the .augmentor-cta-link buttons on the edit form only once per attach operation.
Comment #5
naveenvalechaI am going to create a patch for it.
Comment #7
naveenvalechaComment #8
eleonelLooking good.
@hyperlinked it's working fine for you too?
Comment #10
eleonelThanks everyone.