Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 798 forks source link

AI: Add block transforms #29311

Closed artpi closed 1 year ago

artpi commented 1 year ago

Jetpack AI needs to provide block transforms to implement a following UI: blocks

How?

  1. Once https://github.com/Automattic/jetpack/issues/29310 is implemented
  2. When you choose something, for example "Rewrite in a professional tone", than the current block will be replaced (as a actual Gutenberg block transform) with the interface from https://github.com/Automattic/jetpack/issues/29310 with the prompt pre-written.
  3. Then it can be submitted once again
artpi commented 1 year ago

@annacmc is going to help us with this task by researching prompt templates that are going to be useful in this context. Some ideas not on this screenshot include:

Whoever implements this in Team Gold, be prepared to have these prompt templates to evolve, so we should be able to iterate on this list

annacmc commented 1 year ago

Heya! 👋 I've spent some time investigating what a handful of other AI writing tools are doing right now, and have come up with some prompt ideas and template suggestions to add to this. Looking at what others are doing, around about 5 tones/styles seems to be a good number. I imagine too many choices might lead to choice overload.

Some of these ideas are based upon what others are doing, but with a bit of a different spin to shake things up a little :)

Additionally, I think condensing, expanding, and summarising are important.

A good template format to follow to ensure we get the most consistent & reliable results is likely to be something along these lines:

[Original text]: {text}
[Desired tone/style]: {tone}
[Text length]: {length of provided text}  
[Additional instructions/guidelines]:  {eg. condense text to be shorter, or expand text to be longer preserving original STYLE, TONE and MEANING}

I think this kind of template would be easy to implement into a function which would make iteration and evolution of this list fairly straight forward for future changes/additions/adaptations.

Some examples with full instructions/guidelines

Shorter & Longer

note: I'm on the fence about whether shorter & longer/expanded text should be decreased/increased by percentage, or to a fixed size. But testing with percentage does lead to nice results

[Original text]: {text}
[Desired tone/style]: preserve STYLE, TONE and MEANING
[Text length]: expand length of text by 50%
[Original text]: {text}
[Desired tone/style]: preserve STYLE, TONE and MEANING
[Text length]: reduce length of text by 50%

Tone Adjustment

More Inspirational

[Original text]: {text}
[Desired tone/style]: Inspirational, uplifting, and empowering
[Text length]: preserve existing text length
[Additional instructions/guidelines]:  Rewrite the text in a way that is uplifting and motivating, aimed at inspiring readers to take action or make positive changes in their lives. It often includes personal anecdotes or stories of triumph over adversity.

More Academic

[Original text]: {text}
[Desired tone/style]: Academic, professional, analytical
[Text length]: preserve existing text length
[Additional instructions/guidelines]:  Rewrite the text in a way that would be suitable for publication in an academic journal. Use technical language. Ensure the rewritten text is well-organized and properly structured, with a clear introduction, body, and conclusion.

More Personal

[Original text]: {text}
[Desired tone/style]: Personal, reflective
[Text length]: preserve existing text length
[Additional instructions/guidelines]:  Rewrite the text in a way that is intimate and reflective, sharing personal experiences and emotions with readers. It can be used to build connections with readers and create a sense of community around a shared experience or interest.

More Thought Provoking

[Original text]: {text}
[Desired tone/style]: thought-provoking, challenging, provocative
[Text length]: preserve existing text length
[Additional instructions/guidelines]: Rewrite the text in a tone that challenges readers to think deeply about a topic or issue. It may pose difficult questions or present controversial ideas, encouraging readers to engage in meaningful discussions.

More Blogger Style

[Original text]: {text}
[Desired tone/style]: conversational and informative
[Text length]: preserve existing text length
[Additional instructions/guidelines]: Rewrite the text in a conversational and approachable tone that engages readers and makes them feel as though they are having a conversation with the blogger.

Implementation

Perhaps this could be used somewhat like this:

function generateAIPrompt(originalText, tone, textLength, additionalInstructions) {
  const template = '[Original text]: {text}\n[Desired tone/style]: {tone}\n[Text length]: {length of provided text}\n[Additional instructions/guidelines]: {additional instructions}';

  const filledTemplate = template
    .replace('{text}', originalText)
    .replace('{tone}', tone)
    .replace('{length of provided text}', textLength)
    .replace('{additional instructions}', additionalInstructions);

  return filledTemplate;
}
artpi commented 1 year ago

This seems done