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

feat/488: Ability to resize post content using OpenAI's ChatGPT #532

Merged
merged 53 commits into from
Sep 1, 2023

Conversation

Sidsector9
Copy link
Member

@Sidsector9 Sidsector9 commented Jul 12, 2023

Description of the Change

The feature adds the ability to "grow" and "shrink" the paragraph block content. (Watch video below for demo)

  • The feature is implemented so as to be consistent with title generation feature using the same service.
  • Instead of repeating calls to the API to re-generate the content until it is desirable by the editor, the editor can set the number of suggestions in a single call, and then choose the most desirable suggestion from the modal window, thus providing granular control.
  • The modal window shows some additional stats regarding the increase/decrease in word and character count to help the editor make a more informed decision while selecting from the list of suggestions.
  • The name and icons for the 2 menu options are not final and is open for suggestions.

Limitations

  • Currently, this feature only works with the paragraph block.
  • At a time, it resizes content for a single block at a time. We can iteratively improve this to handle the situation where a a non-paragraph block is between 2 paragraphs.

What is next?

The next improvement can be resizing content when multiple, consecutive paragraph blocks are selected.

Closes #488

Screenshot

1. Resizing content settings:

Screenshot 2023-07-12 at 9 53 21 PM

2. Grow content

Grow.24fps.mov

3. Shrink content

Shrink.24fps.mov

How to test the Change

  1. Enable the feature under /wp-admin/tools.php?page=classifai&tab=language_processing&provider=openai_chatgpt
  2. Go to a post with content

Changelog Entry

Added - Ability to resize post content using OpenAI's ChatGPT
Changed - Bump WordPress minimum from 5.7 to 5.8

Credits

Props @jeffpaul, @Sidsector9, @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@Sidsector9 Sidsector9 requested review from a team, dkotter and jeffpaul as code owners July 12, 2023 16:40
@Sidsector9 Sidsector9 self-assigned this Jul 12, 2023
@jeffpaul
Copy link
Member

@Sidsector9 I chatted with Jake on this today and agreed the best option would be to add a new block toolbar option using either https://github.com/10up/classifai/blob/develop/assets/img/icon.svg or https://github.com/10up/classifai/blob/develop/assets/img/menu-icon.svg for the toolbar icon and then nesting the expand/reduce options in a dropdown there.

@jeffpaul jeffpaul added this to the 2.3.0 milestone Jul 13, 2023
@jeffpaul
Copy link
Member

Also, let's remove Subscriber from one of the default enabled roles for this (and maybe Contributor as well?) so that we don't get normal site visitors using up a sites OpenAI budget without an admin explicitly enabling that.

includes/Classifai/Services/LanguageProcessing.php Outdated Show resolved Hide resolved
includes/Classifai/Services/LanguageProcessing.php Outdated Show resolved Hide resolved
src/js/gutenberg-plugins/content-resizing-plugin.js Outdated Show resolved Hide resolved
includes/Classifai/Services/LanguageProcessing.php Outdated Show resolved Hide resolved
@Sidsector9 Sidsector9 force-pushed the feat/488 branch 2 times, most recently from 3022689 to 12c6411 Compare July 27, 2023 16:02
@dkotter
Copy link
Collaborator

dkotter commented Aug 24, 2023

Left a few suggestions but also saw a couple other things:

  1. Getting a deprecation error in the console: Using custom components as toolbar controls is deprecated since version 5.6. Please use ToolbarItem, ToolbarButton or ToolbarDropdownMenu components instead. See: https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols
  2. E2E test is failing Fixed now 141ea55
  3. The animation we show when loading results has issues when we select a short paragraph. It expands outside of it's container into the content below. Not a huge deal but would be nice to solve:

screenshot

@Sidsector9
Copy link
Member Author

Sidsector9 commented Aug 25, 2023

@dkotter this feature is not working well on WP 6.3 due to major changes in the Block editor. It works fine in WP 6.2. A trick to make this feature work in WP 6.3 is to enable Custom Fields under Preferences > Panels.

The animation works on a single line content as well:

Screen.Recording.2023-08-26.at.12.25.54.AM.mov

I couldn't find a way to fix this, I'm still investigating.

@jeffpaul
Copy link
Member

@Sidsector9 since this isn't a functional issue with the loading animation, perhaps remove that for now and open that in a separate PR to continue iterating on and can land in a 2.3.x minor release. Also, I confirmed and the existing "Expand this text" and "Condense this text" copy is good for us to ship.

@dkotter
Copy link
Collaborator

dkotter commented Aug 31, 2023

@Sidsector9 @jeffpaul Reviewing this again today in hopes of getting this merged and ran into one thing. Right now our E2E test is failing on WordPress 5.7 (our minimum) because we're using the ToolbarDropdownMenu component which wasn't added to core until 5.8.

I can see two paths forward:

  1. Find a different approach for that dropdown menu that will work in 5.7+
  2. Bump our minimum supported WordPress version to at least 5.8

Not sure how hard the first will be. I'm totally on board to bump our minimums but open to thoughts there.

@Sidsector9
Copy link
Member Author

@dkotter I've bumped minimum WordPress version from 5.7 to 5.8

@dkotter dkotter merged commit d4711b3 into develop Sep 1, 2023
13 checks passed
@dkotter dkotter deleted the feat/488 branch September 1, 2023 15:00
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

Successfully merging this pull request may close these issues.

Expand text and Reduce text post content functions
4 participants