Skip to content

formentor-studio/magnolia-ai-contents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magnolia AI Contents

Module of Magnolia CMS that adds the following features to create contents using Large language models like GPT from Open AI.

Features

  • Integration with OpenAI and Azure OpenAI
  • Field textFieldAI to create and edit text contents using AI.
  • Prompt generator to create prompts from existing contents.
  • UI field imageAI to create images using AI.

Usage

Field textFieldAI

Text field whose content can be created from existing contents using AI.

textFieldAI

Definition of field textFieldAI

textFieldUsingAI:
  $type: textFieldAI
  strategy: completion
  model: gpt-3.5-turbo
  words: 300
  promptGenerator:
    template: ai.prompt.template.hotels-app.description
    properties:
      title:
        name: title
      category:
        targetWorkspace: category
        targetPropertyName: displayName
      rooms:
        name: rooms
      country:
        name: country
      city:
        name: city

Field properties

Field-specific properties

PropertyDescription
strategy Required

Specifies the completion strategy to create the text.

  • completion to write the text from a given prompt.
  • edit to edit the current text from instructions -e.g. "Translate the following from slang to a business letter" -.
model Optional

AI model used to create text, it can be a general purpose model like gpt-3.5-turbo or a fine-tuned model trained with contentes from Magnolia.

words Optional

Number of words of the generated text.

The value of words is used to build the prompt. See promptGenerator to know how to make it.

promptGenerator Optional

Prompt template and fields of the form that will be used to build the prompt used by AI to generate the text.

properties

List of fields in the form whose value will appear in the prompt. In case of link fields, specify the target workspace and property name (prompt generator will take the value of this property)

NOTE

In case of composite fields, you will prefix the property name with the path of the child node -e.g. /location/address/number means child node "/location/address" and property name "number"

template

Name of the copy that contains the template of the prompt.

The copy can include the following tokens:

  • Value of fields specified by promptGenerator.properties
  • Current language
  • Number of words specified by words

Example of prompt template

Write a product description based on the information provided in the technical specifications delimited by triple backticks.\n\nUse {1} as language.\n\nUse at most {2} words.\n\nTechnical specifications: {0}

Common text field properties

This field extends Text field and it is possible to specify any property from this field.

Setup

  1. Add maven dependency to your bundle of Magnolia
<dependencies>
    <dependency>
        <groupId>org.formentor</groupId>
        <artifactId>magnolia-ai-contents</artifactId>
        <version>0.0.1</version>
    </dependency>
</dependencies>
  1. Activate and configure Open AI or Azure OpenAI

OpenAI

  • Specify the host of the API of OpenAI in the configuration of the module.

config:/magnolia-ai-contents/openAI

open-ai-magnolia

  • Specify the API key of OpenAI in the secret named openai/api-key of Password Manager.

openai-api-key

Azure OpenAI

  • Specify apiVersion, deployment, host and resource in configuration of the module.

config:/magnolia-ai-contents/azure

azure-open-ai-magnolia

azure-openai-api-key

  1. Specify the models available to create texts. It can be general purpose models - see https://platform.openai.com/docs/models - or fine-tuned models.

ai-models

Field imageAI

Creates image content from a given prompt.

imageAI

Definition of field imageAI

imageAI:
  $type: imageAI

Example

subApps:
  detail:
    label: Blog
    form:
      properties:
        imageAI:
          $type: compositeField
          label: Image AI
          itemProvider:
            $type: jcrChildNodeProvider
            nodeName: jcr:content
            nodeType: mgnl:resource
          properties:
            image:
              label: ""
              $type: imageAI

About

Generation of contents in Magnolia CMS using AI

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages