OpenAI / ChatGPT module release with new features

By Kevin, March 28th, 2023

In just a few short weeks we have made a lot of progress adding features and fixing bugs in the OpenAI module for Drupal. We have just released an alpha7 preview of the module containing 3 notable changes:

  • Node forms now have a 'content tone adjuster' that can take body text and rewrite the content to fit different audiences.
  • Node forms now have a sentiment analysis feature that will scan your body content and tell you if it violates flags for hate speech, violence, or otherwise questionable content that may upset your audience(s)
  • A new submodule has been added that adds a content generator for Devel Generate using OpenAI GPT models. You can now use the same Devel Generate tool to generate content on the fly, only now you can get real generated text from GPT and ChatGPT models instead of lorem ipsum text. This is very useful if you want to fill out your site with realistic sounding content for client demonstration, layout, theming or QA in a way that is more "real world" than walls of gibberish/lorem ipsum randomized generation.

As GPT models mature and token counts increase, generating realistic content will outright replace randomized generation. We added a Drush command as well for developers and you can generate content with it like so:

drush devel-generate:content-gpt 5 --base-fields=body,field_foo,field_bar --system="I want to generate content about 
popular content management systems."

In plain words, this command says "You job is to generate content. I want to generate content about popular content management systems. Please generate 5 pages of content and fill in the body, field_foo, and field_bar fields with your responses."

For example, if I ran the top comment but asked to generate content about scary movies instead, I would get something like this:

Image
generated content from chatgpt

The page title and body field are generated from ChatGPT. When the page title is generated, it is then instructed to generate content for individual fields based on that title. It will generate content for any string or text based field. There is also a feature to "include HTML". When HTML is flagged on, GPT will wrap its responses with the proper HTML markup. This is useful for formatted fields that have a text editor, as shown in the image above. We are allowing for the explicit addition of fields that get GPT generated text so there is respect to API/token usage to help prevent running up costs accidentally.

This is pretty exciting progress! From here we are shifting our focus into the editor experience. Our desire is to shore up the popular CKEditor ChatGPT plugin in the openai_ckeditor submodule and take it further as well as expand on the content editing tools in the sidebar that were developed under the openai_content submodule.

You can get the new alpha7 release right now over on drupal.org on the OpenAI / ChatGPT project page.