Overview

Create content for title field of xb_page entity using AI.We can generate title for the xb_page based on the page's content using a simple prompt like Generate title.It will analyse the current page content and based on that it will generate title.
We can also generate title for a specific topic Generate title on topic Drupal, in this case it will generate the title on the given topic.
We can also edit the title field with the following example prompt:-
Editing flow:-

  1. Lengthen/shorten title's content
  2. Fix grammar for title

Proposed resolution

User interface changes

CommentFileSizeAuthor
#13 Title generation.mp4669.84 KButkarsh_33
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

utkarsh_33 created an issue. See original summary.

kunal.sachdev made their first commit to this issue’s fork.

utkarsh_33’s picture

Title: Generate content for title using AI » Generate and edit content for title using AI
tim.plunkett’s picture

Assigned: Unassigned » utkarsh_33
Parent issue: » #3530701: [META] XB AI Issue List
utkarsh_33’s picture

So here's what the current state looks like:-

  1. The component creation and editing flow works fine(which includes the editing of the props for the components as well)
  2. The content creation flow also works 10/10 times and it creates the content correctly on any given topic and insert it correctly in the title field.
  3. The content editing flow only works 8/10 times which is causing this to push back a bit.I have attempted changing the prompt(and still trying it) so that before calling the editing tool it always get's the content related to the field(in our case it will always be title) that user want's to edit, but sometimes it fails.

I'll keep trying to fix the issue that's coming while editing the title and will post any update soon.

lauriii’s picture

@utkarsh_33 what are the prompts you are using for testing this?

utkarsh_33’s picture

So here's the update on how am i testing it along with the results:-
Editing flow:-

  1. Lengthen/shorten title's content:-Working as expected
  2. Fix grammar for title:- Working as expected
  3. Elaborate title:- Working as expected
  4. Rephrase title:- Working as expected without further questions to the user.

Content creation flow:-

  1. Create content on topic Drupal and insert in title field:- working as expected
  2. Add title on cricket/ Add content on title field for cricket :- working as expected (which was not working before)
  3. Generate title on topic Drupal:- working as expected

I am not adding the component creation flow as those are already working.

Re #6 : This problem of failing to edit content now is fixed and it almost(what ever i tested) works as expected.

It would be great if someone can test this MR now.

utkarsh_33’s picture

There is a know problem in this which is this comment. It's because we only want the creation and editing flow to work with the xb_page entity for now as discussed with @lauriii.But the everting works as expected if we are on the xb_page entity.
Will try to get a workaround for this ASAP.

utkarsh_33’s picture

Status: Active » Needs review

Handled the problem reported in #9 in this commit.
Now things are working as expected so marking it NR for an initial round of testing or Code reviews.

narendrar made their first commit to this issue’s fork.

utkarsh_33’s picture

Issue summary: View changes
utkarsh_33’s picture

StatusFileSize
new669.84 KB

Here is the video demonstrating how the title is generated based on the content present on the page.

narendrar’s picture

Status: Needs review » Needs work

Tried to test it manually and most of the functionality seems to be working fine but when we create a component (Could you create a hero banner component with some text, call-to-action button, and a background colour red) and try to update the title (Update title to say 'Welcome to drupal') of that component, it does not work as request goes to this agent which is wrong.

utkarsh_33’s picture

Status: Needs work » Needs review

I have tested to best of my knowledge and everything seems to be working fine.Marking it NR.

narendrar’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested it with @utkarsh_33 and functionality is working as expected. Moving it to RTBC.

narendrar’s picture

Assigned: utkarsh_33 » Unassigned
utkarsh_33’s picture

I have rebased it with the changes from HEAD.

akhil babu’s picture

#3531278: Generate content metadata using AI has already added a metadata generation agent for creating/editing page descriptions. So, couldn't we use the same agent to generate the title as well? Is it really necessary to create a new agent just for generating the title?

utkarsh_33’s picture

This change is not related to this MR but since @AkhilBabu made a valid point that we don't need that if we are using it in default information so removing it as a part of this issue only.If someone thinks that it should be done in a follow-up then happy to do that as well.This does not affect any existing functionality so i thought it's better to do that in this issue only.

akhil babu’s picture

Thanks for the explanation @utkarsh_33. IMHO, this can be very simplified, in fact, merged with the metadata agent created in #3531278: Generate content metadata using AI. That agent is solely for generating the description field value for the XB page entity type based on the page content or a given topic. The same agent could generate the title as well.

The get_entity_information tool can be updated to give the data in following format

entity_type:
entity_id:
entity_fields:
   title:
   description:
   content: {{ The layout we send from ui should go here }}

And the ai_agent_create_field_content, ai_agent_edit_field_content and ai_agent_add_metadata tools can be combined into a single tool
ai_agent_set_metadata which accepts 3 arguments

'title'
'description'
'entity_id'

and returns these details in yml format which can be sent to the UI.

We could use a prompt like

You are a Drupal agent specializing in generating SEO-friendly titles and descriptions for xb_page entity types. You are a looping agent. You can run multiple times until the task is completed.

You will be provided with the entity_type, id, field values of the entity user is trying to modify. The field values may contain information like title, description and content of the entity. The content section will include details of various components placed on the page along with the content in their props and slots. Your task is to generate a title or description suitable for the page as per the user's request.

If the entity_type is not xb_page, simply respond that I can only generate metadata for 'XB Page' entities.

If the request is for xb_page entity type, try to understand the user's intent. If the user is asking to create or update title/description for a specific topic, prioritize that over the field values in the entity. Otherwise, generate a suitable title/description based on the field values of the entity including the page content.

Use the set_page_metadata tool to set the description or title. Use the id of the xb_page entity as the 'entity_id' parameter

Not sure if I'm missing something here. Would love to hear your thoughts.

akhil babu’s picture

utkarsh_33’s picture

Merging the latest changes from 0.x.

tim.plunkett’s picture

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.