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

Add POST endpoints for excerpt and title generation #501

Closed
1 task done
dkotter opened this issue Jun 20, 2023 · 0 comments · Fixed by #525
Closed
1 task done

Add POST endpoints for excerpt and title generation #501

dkotter opened this issue Jun 20, 2023 · 0 comments · Fixed by #525
Assignees
Labels
help wanted Extra attention is needed needs:engineering This requires engineering to resolve. type:enhancement New feature or request.
Milestone

Comments

@dkotter
Copy link
Collaborator

dkotter commented Jun 20, 2023

Is your enhancement related to a problem? Please describe.

For both our excerpt and title generation features, we added custom REST endpoints that are used when those features are requested (when the Generate excerpt or Generate titles buttons are clicked, for instance). These endpoints are set up as GET endpoints and we pass in the current post ID. We then pull the content from that matches that post ID and send that along to ChatGPT.

While this works, the problem here is if you try to use one of these features on an item using the Block Editor that hasn't been saved yet, the content that we send to ChatGPT will be whatever was previously saved (if any). This means if you're working on a post that hasn't been saved yet, no content will be sent. Or if you've made a bunch of edits but haven't saved them yet, the old content will be sent.

I think it's fine to leave these GET endpoints alone but we should investigate adding POST endpoints as well and changing our functionality to pass in the full content of a post instead of just a post ID. This will require a POST endpoint as we'll probably run into content length issues if we try and use a GET endpoint for this (as it sets all the content in the URL instead of the body).

So at an overview, here's what I'd see needs to be done:

  1. Add new POST endpoints for both excerpt and title generation
  2. This endpoint will accept a content param in the body, or maybe two params, one for post content and one for post title
  3. Update our JS handler for both of these to pull content from the block editor and send it along to this new endpoint, instead of sending the post ID to the GET endpoint
  4. Ideally the callback our new endpoint uses will be the same as the existing one, but will probably need some tweaks to support passing in the content instead of an ID

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 Jun 20, 2023
@dkotter dkotter added this to the 2.3.0 milestone Jun 20, 2023
@jeffpaul jeffpaul added help wanted Extra attention is needed needs:engineering This requires engineering to resolve. labels Jun 28, 2023
@phpbits phpbits self-assigned this Jul 6, 2023
@jeffpaul jeffpaul modified the milestones: 2.3.0, 2.2.3 Jul 6, 2023
@dkotter dkotter modified the milestones: 2.2.3, 2.3.0 Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed needs:engineering This requires engineering to resolve. type:enhancement New feature or request.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants