Canvas AI: Create a common service for validations
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3543744. --> Reported by: [akhil babu](https://www.drupal.org/user/3632866) Related to !14 !1494 >>> <h3 id="overview">Overview</h3> <p><span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/experience_builder/issues/3537422" title="Status: Closed (fixed)">#3537422: XB AI: Validate AI generated Components before adding to XB</a></span> added validations for checking the AI response before placing components in the canvas. Currently, these validations are directly added in the tool plugin itself.<br> Moving them to a separate AiResponseValidator service would make it easier to reuse them in other tools as well. (Eg: <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3533079" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3533079</a></span>)</p> <p>--- AI TRACKER METADATA ---<br> <strong>Update Summary: </strong>This makes it much less likely AI will give a band response and fail.<br> <strong>Check-in Date: </strong>MM/DD/YYYY (US format) [When we should see progress/get an update]<br> <strong>Due Date:</strong> MM/DD/YYYY (US format) [When the issue should be fully completed]<br> <strong>Blocked by:</strong> [#XXXXXX] (New issues on new lines)<br> <strong>Additional Collaborators:</strong> @username1, @username2<br> AI Tracker found here: <a href="https://www.drupalstarforge.ai/" title="AI Tracker">https://www.drupalstarforge.ai/</a><br> --- END METADATA ---</p> <h3 id="proposed-resolution">Proposed resolution</h3> <ul> <li>Create a common service AiResponseValidator in the xb_ai submodule.</li> <li>Move the validations there.</li> <li>Update the existing code accordingly.</li> </ul> <h3 id="ui-changes">User interface changes</h3> > Related issue: [Issue #3533079](https://www.drupal.org/node/3533079) > Related issue: [Issue #3530701](https://www.drupal.org/node/3530701)
issue