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

Show error message if title or excerpt generation fails in Classic Editor #688

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Feb 4, 2024

Description of the Change

If using either Excerpt Generation or Title Generation and you're on a site that uses the Classic Editor, if either of those features fails (for instance, if API limits are reached) the error message doesn't show. If using the Block Editor, the error messages will show.

This PR fixes that by add a catch statement to our API requests to ensure we output the error message when needed for both of those features.

Closes #686

How to test the Change

  1. Enable both Title Generation and Excerpt Generation under Tools > ClassifAI > Language Processing
  2. Install and activate the Classic Editor plugin
  3. To easily trigger an error state, edit the generate_excerpt and generate_titles methods in the includes/ClassifAI/Providers/OpenAI/ChatGPT.php file, adding $post = null to the top of both of those
  4. Edit a piece of content that supports both titles and excerpts (like a Post)
  5. Click the Generate Titles button and ensure an error message is shown
  6. Click the Generate Excerpt button and ensure an error message is shown
  7. Remove the test changes made above and try the buttons again, ensuring a proper response is no shown

Changelog Entry

Added - Show error message if generating excerpts or titles fails in the Classic Editor

Credits

Props @dkotter, @faisal-alvi

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.

@dkotter dkotter added this to the 3.0.0 milestone Feb 4, 2024
@dkotter dkotter self-assigned this Feb 4, 2024
@dkotter dkotter requested review from jeffpaul and a team as code owners February 4, 2024 23:11
@dkotter dkotter requested review from faisal-alvi and removed request for a team and jeffpaul February 4, 2024 23:11
Copy link
Member

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkotter thank you for the quick fix!

LGTM, working as expected!

image

@dkotter dkotter merged commit fe6dc25 into develop Feb 6, 2024
13 checks passed
@dkotter dkotter deleted the fix/686 branch February 6, 2024 15:29
@github-actions github-actions bot added the needs:code-review This requires code review. label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image Processing: No user friendly notice displayed when error occurs
2 participants