OpenAI GPT as writing assistant in Magnolia CMS

Joaquín Alfaro
3 min readJan 4, 2023

--

OpenAI GPT provides AI services related with language understanding and generation, which allows the generation of text from a given prompt.

This article will show the integration of Magnolia CMS with OpenAI GPT to create and edit text contents.

How it works

Text fields provide the buttons “Ask AI to write” and “Ask AI to edit” to create and edit the text using OpenAI GPT

  1. Click the button “Ask AI to write” and specify the Prompt to be used to generate the text. Magnolia will suggest a Prompt built using a template and existing contents.

2. Click the button Execute and wait until OpenAI GPT generates the text.

3. Once the text is generated, adjust the text by clicking on “Ask AI to edit” and specify the instructions of edition

4. Click the button Execute and wait until OpenAI GPT edit the text with the specified instructions.

5. Repeat the previous step until you feel confortable with the generated text.

Setup in Magnolia CMS

Magnolia CMS includes the type textFieldAI to empower text fields with the functionalities “Ask AI to write” and “Ask AI to edit

  1. Define a field in a content app and specify the type textFieldAI
roomDescription:
$type: textFieldAI
strategy: completion
words: 180
performance: high
promptGenerator:
template: tours-app.ai.prompt.template.tour-description
properties:
name:
name: title
description:
name: location
tourTypes:
targetWorkspace: category
targetPropertyName: displayName

2. Specify the value of properties strategycompletion, edit and fixwords and performance.

  • strategy indicates the allowed actions — completion allows to create and edit text using AI —
  • words specifies the default value for the number of words of the generated text.
  • performance indicates the default value for accuracy of the generated text. Allowed values are: best, high, medium and low. These values are mapped with models of OpenAI GPT
  • promptGenerator specifies the template and properties of current content that will be used to generate the prompt.

Insights

GitHub repository

https://github.com/formentor-studio/magnolia-ai-contents

--

--