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:-
- Lengthen/shorten title's content
- Fix grammar for title
Proposed resolution
User interface changes
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | Title generation.mp4 | 669.84 KB | utkarsh_33 |
Issue fork experience_builder-3532207
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
Comment #4
utkarsh_33 commentedComment #5
tim.plunkettComment #6
utkarsh_33 commentedSo here's what the current state looks like:-
I'll keep trying to fix the issue that's coming while editing the title and will post any update soon.
Comment #7
lauriii@utkarsh_33 what are the prompts you are using for testing this?
Comment #8
utkarsh_33 commentedSo here's the update on how am i testing it along with the results:-
Editing flow:-
Content creation flow:-
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.
Comment #9
utkarsh_33 commentedThere 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.
Comment #10
utkarsh_33 commentedHandled 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.
Comment #12
utkarsh_33 commentedComment #13
utkarsh_33 commentedHere is the video demonstrating how the title is generated based on the content present on the page.
Comment #14
narendrarTried 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.
Comment #15
utkarsh_33 commentedI have tested to best of my knowledge and everything seems to be working fine.Marking it NR.
Comment #16
narendrarManually tested it with @utkarsh_33 and functionality is working as expected. Moving it to RTBC.
Comment #17
narendrarComment #18
utkarsh_33 commentedI have rebased it with the changes from HEAD.
Comment #19
akhil babu#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?
Comment #20
utkarsh_33 commentedThis 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.
Comment #21
akhil babuThanks 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
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_metadatawhich accepts 3 argumentsand 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.
Comment #22
akhil babuCreated a followup issue #3534707: XB AI: Simplify metadata generation for #21
Comment #23
utkarsh_33 commentedMerging the latest changes from 0.x.
Comment #24
tim.plunkettComment #26
tim.plunkettMerged, thanks all!