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

Command icon 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

davidiio created an issue. See original summary.

murrayw’s picture

Assigned: Unassigned » eleonel
Category: Bug report » Support request

Augmentors 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.

hyperlinked made their first commit to this issue’s fork.

hyperlinked’s picture

Status: Active » Needs review
Issue tags: +augmentor, +once, +jQuery

I 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.

naveenvalecha’s picture

Assigned: eleonel » naveenvalecha
Category: Support request » Bug report

I am going to create a patch for it.

naveenvalecha’s picture

Assigned: naveenvalecha » eleonel
eleonel’s picture

Status: Needs review » Reviewed & tested by the community

Looking good.

@hyperlinked it's working fine for you too?

eleonel’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.