From 7fb99ecf21dca91ca6ed8d897244f30931a0ce52 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Wed, 26 Mar 2025 10:00:41 +0000 Subject: [PATCH] chore(ui): Reuse FormFieldDefinition on other parts of AgentForm --- .../AdvancedSettingsSection.jsx | 138 +++++++++--------- .../agent-form-sections/BasicInfoSection.jsx | 124 ++++++++-------- .../agent-form-sections/MCPServersSection.jsx | 51 ++++--- .../MemorySettingsSection.jsx | 109 +++++++------- .../ModelSettingsSection.jsx | 130 ++++++++--------- .../PromptsGoalsSection.jsx | 119 ++++++++------- .../src/components/common/FormField.jsx | 1 + .../components/common/FormFieldDefinition.jsx | 25 ++-- 8 files changed, 357 insertions(+), 340 deletions(-) diff --git a/webui/react-ui/src/components/agent-form-sections/AdvancedSettingsSection.jsx b/webui/react-ui/src/components/agent-form-sections/AdvancedSettingsSection.jsx index 517c9a5..b5072be 100644 --- a/webui/react-ui/src/components/agent-form-sections/AdvancedSettingsSection.jsx +++ b/webui/react-ui/src/components/agent-form-sections/AdvancedSettingsSection.jsx @@ -1,82 +1,82 @@ import React from 'react'; +import FormFieldDefinition from '../common/FormFieldDefinition'; /** * Advanced Settings section of the agent form */ const AdvancedSettingsSection = ({ formData, handleInputChange }) => { + // Define field definitions for Advanced Settings section + const fields = [ + { + name: 'max_steps', + label: 'Max Steps', + type: 'number', + defaultValue: 10, + helpText: 'Maximum number of steps the agent can take', + required: true, + }, + { + name: 'max_iterations', + label: 'Max Iterations', + type: 'number', + defaultValue: 5, + helpText: 'Maximum number of iterations for each step', + required: true, + }, + { + name: 'autonomous', + label: 'Autonomous Mode', + type: 'checkbox', + defaultValue: false, + helpText: 'Allow the agent to operate autonomously', + }, + { + name: 'verbose', + label: 'Verbose Mode', + type: 'checkbox', + defaultValue: false, + helpText: 'Enable detailed logging', + }, + { + name: 'allow_code_execution', + label: 'Allow Code Execution', + type: 'checkbox', + defaultValue: false, + helpText: 'Allow the agent to execute code (use with caution)', + }, + ]; + + // Handle field value changes + const handleFieldChange = (name, value) => { + // For checkboxes, convert string 'true'/'false' to boolean + if (['autonomous', 'verbose', 'allow_code_execution'].includes(name)) { + handleInputChange({ + target: { + name, + type: 'checkbox', + checked: value === 'true' + } + }); + } else { + handleInputChange({ + target: { + name, + value + } + }); + } + }; + return (

Advanced Settings

-
- - - Maximum number of steps the agent can take -
- -
- - - Maximum number of iterations for each step -
- -
- - Allow the agent to operate autonomously -
- -
- - Enable detailed logging -
- -
- - Allow the agent to execute code (use with caution) -
+
); }; diff --git a/webui/react-ui/src/components/agent-form-sections/BasicInfoSection.jsx b/webui/react-ui/src/components/agent-form-sections/BasicInfoSection.jsx index fd0f6e1..7d74ecc 100644 --- a/webui/react-ui/src/components/agent-form-sections/BasicInfoSection.jsx +++ b/webui/react-ui/src/components/agent-form-sections/BasicInfoSection.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import FormFieldDefinition from '../common/FormFieldDefinition'; /** * Basic Information section of the agent form @@ -9,69 +10,74 @@ const BasicInfoSection = ({ formData, handleInputChange, isEdit, isGroupForm }) return null; } + // Define field definitions for Basic Information section + const fields = [ + { + name: 'name', + label: 'Name', + type: 'text', + defaultValue: '', + required: true, + helpText: isEdit ? 'Agent name cannot be changed after creation' : '', + disabled: isEdit, // This will be handled in the component + }, + { + name: 'description', + label: 'Description', + type: 'textarea', + defaultValue: '', + }, + { + name: 'identity_guidance', + label: 'Identity Guidance', + type: 'textarea', + defaultValue: '', + }, + { + name: 'random_identity', + label: 'Random Identity', + type: 'checkbox', + defaultValue: false, + }, + { + name: 'hud', + label: 'HUD', + type: 'checkbox', + defaultValue: false, + } + ]; + + // Handle field value changes + const handleFieldChange = (name, value) => { + // For checkboxes, convert string 'true'/'false' to boolean + if (name === 'random_identity' || name === 'hud') { + handleInputChange({ + target: { + name, + type: 'checkbox', + checked: value === 'true' + } + }); + } else { + handleInputChange({ + target: { + name, + value + } + }); + } + }; + return (

Basic Information

-
- - - {isEdit && Agent name cannot be changed after creation} -
- -
- -