Overview
Trying to follow the logic of \Drupal\canvas_ai\Controller\CanvasBuilder::render() it is not clear why this particular set of tools is special cased
$map = [
EditComponentJs::class => ['js_structure', 'props_metadata'],
CreateComponent::class => ['component_structure'],
CreateFieldContent:: class => ['created_content'],
EditFieldContent:: class => ['refined_text'],
AddMetadata::class => ['metadata'],
SetAIGeneratedComponentStructure::class => ['operations'],
];
if (!empty($tools)) {
foreach ($tools as $tool) {
foreach ($map as $class => $keys) {
In #3537422: XB AI: Validate AI generated Components before adding to XB we already had to put this comment in all of the classes listed above
// \Drupal\xb_ai\Controller\XbBuilder::render() expects a YAML parsable
// string.
// @see \Drupal\xb_ai\Controller\XbBuilder::render()
But inside CanvasBuilder::render() it is not clear what these classes are for and what strings that will be set to $keys are.
Looking through the classes it seems the $keys will but sub-set of the tools output if the tool does not have any errors
We should make this clearer by making an interface and not having to hardcode these class names
Proposed resolution
- Create an new
BuilderResponseFunctionCallInterfacewith getSuccessResponseData - Have all the classes currently hardcoded implement this interface
The names can be updated. Need feedback by those that know why this particular classes are hardcoded
User interface changes
Issue fork canvas-3555464
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 #3
tedbowComment #4
narendrarThe changes look good to me. My only suggestion to help simplify the remaining tools is to use
setOutputinstead ofgetReadableOutput.Also instead of doing this can we use functionality added in https://www.drupal.org/project/ai/issues/3529313
Comment #5
tedbowComment #6
narendrarChanges looks good to me.
Some small changes to do and may be we could update the Proposed resolution in IS.
Comment #7
akhil babuVerified page builder functionality manually with these changes and did not find any issues. +1 RTBC
Comment #8
narendrarChanges looks good to me. Follow-up needs to be created for removing
field_name. This can also be done as part of #3555407: AI Canvas, dead code, nits fixesComment #10
tedbowsee https://git.drupalcode.org/project/canvas/-/merge_requests/286#note_620997
Comment #11
narendrarFollow up created #3557075: Canvas AI: Remove field_name from agents