Developer YAML-API

Inline text generation when creating the content element

As a developer, you can think of countless use cases for automatically generated texts in inline-editable text properties

Let's start with a "Page summary" content element that automatically fills with a summary of the current page - streamed directly into the user interface with NEOSidekick.

Full size video

The NEOSidekick YAML API

You only need a few lines of additional code for this:

'Vendor.Site:Content.PageSummary':
superTypes:
'Neos.Neos:Content': true
ui:
label: page summary
icon: align-left
properties:
text:
type: string
ui:
inlineEditable: true
options:
sidekick:
onCreate: true
module: 'page_conclusion_writer'

 

In the property options, you can use sidekick.onCreate to define a module that should be used. Here we take page_conclusion_writer. The module is automatically sent the current content of the page. For other modules you have various configuration options, here are a few more examples.

 

Creation Dialog

Let's use content from the Creation dialog to automatically generate texts. To do this, we define a title and another text property that is prefilled with text based on the title.

Full size video

The NEOSidekick YAML API

You can realize this with a YAML NodeType like this:

'Vendor.Site:Content.Text':
superTypes:
'Neos.Neos:Content': true
ui:
label: Magic Text
icon: align-left
properties:
title:
type: string
ui:
label: Title
showInCreationDialog: true
inlineEditable: true
text:
type: string
ui:
inlineEditable: true
options:
sidekick:
onCreate: true
module: paragraph_generation
arguments:
topic: 'SidekickClientEval: node.properties.title'

 

For the arguments, you can use ClientEval to always use the current title property value. You can also use SidekickClientEval, which extends ClientEval and also supports documentTitle, documentContent and an AssetUri function. The paragraph_generation has an argument topic, and here we use the title of the content element.

 

Your own prompts

You are not limited to our ready-made modules. Let's create a TLDR content element with its own prompt.

Full size video

The NEOSidekick YAML API

With these few lines you can implement your own prompt to create any text:

'NEOSidekick.Site:Content.TLDR':
superTypes:
'Neos.Neos:Content': true
ui:
label: TLDR
icon: list
properties:
text:
type: string
ui:
inlineEditable: true
options:
sidekick:
onCreate: true
module: free_conversation
arguments:
content: 'Generate a TDLR with 5 bulletpoint for this page, in HTML without a code block. Keep the sentences short. Make it engaging, so that visitors want to read the whole page.'
writingStyle: 'tech_advocate'

 

A lot happens here in just a few lines. The NEOSidekick module free_conversation is called and receives the content of the current page and its own prompt. In this prompt we describe what we want "Generate a TDLR with 5 bulletpoint for this page", in which format "in HTML without a code block" and with which writing style "Keep the sentences short. Make it engaging, so that visitors want to read the whole page."

We can also specify one of the predefined writing styles.

The NEOSidekick YAML API

And here is another example where we use a node property:

'NEOSidekick.Site:Document.BlogPost':
superTypes:
'Neos.Neos:Document': true
ui:
label: BlogPost
properties:
transcript:
type: string
ui:
label: 'YouTube Transcript'
showInCreationDialog: true
text:
type: string
ui:
inlineEditable: true
options:
sidekick:
onCreate: true
module: free_conversation
arguments:
content: >-
SidekickClientEval: `
You are the worlds best journalist. You write in an informal style aimed at engaging and educating the reader. The tone is friendly and approachable, using direct address ("I") to create a sense of dialog. The article breaks down complex topics into understandable segments, using relatable examples and personal anecdotes to clarify points. You often include rhetorical questions to provoke thought and keep the reader engaged. The structure is well-organized, with clear headings and bullet points that make the content easy to follow.

YouTube transcript:
"""
${node.properties.transcript}
"""

Please re-write the transcript as a blog post in Markdown. Skip the title, start with an introduction and then start with the headline level 2.
`

 

In this example, we use SidekickClientEval to access node properties. And we use JavaScript template strings to be able to write the long prompt nicely in YAML.

The NEOSidekick YAML API

Do you need an API key?

Since GPT-4 is associated with considerable costs, we cannot publish the interface unprotected on the Internet. You can buy a 14-day trial version via our store or contact us via support@neosidekick.com, then we can create an API key for testing and demos.

What else is in the API?

Modules for Inspector property text generation:

  • free_conversation
    Arguments: content (string, required)
    Describe in a separate prompt which content should be created.
  • page_conclusion_writer
    Arguments: call_to_action (string, optional)
    Generate a page conclusion and define an optional call-to-action which should appear in the conclusion.
  • paragraph_generation
    Arguments: content (string, required)
    Generate a paragraph about the topic from content.

Available writing styles:

  • academically_complex
  • concise_descriptions
  • extreme_motivation
  • literary_masterpiece
  • marketing_genius
  • storytelling_genius
  • tech_advocate
  • visionary_marketing

You can also create generate buttons in the Neos Inspector.

Let your creativity run wild! Design and configure your own buttons, we are excited to see what use cases you find.

Please give us feedback!

Is the naming consistent and clear? Do you understand the use cases? What would you like to develop with it?

Or on Slack #neos-general and mention @rolandschuetz