SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
support verbosity and reasoning effort for GenAI LLM
Forhad Hosainab38e1992962
diff --git a/packages/app/src/builder-ui/components/GenAILLM.class.ts b/packages/app/src/builder-ui/components/GenAILLM.class.tsindex 187ef669..b281a03b 100644--- a/packages/app/src/builder-ui/components/GenAILLM.class.ts+++ b/packages/app/src/builder-ui/components/GenAILLM.class.ts@@ -1,5 +1,6 @@// TODO: Refactor this file (specially setting fields for different providers)import { LLMRegistry } from '../../shared/services/LLMRegistry.service';+import { REASONING_EFFORTS } from '../constants';import { LLMFormController } from '../helpers/LLMFormController.helper';import llmParams from '../params/LLM.params.json';import { createBadge } from '../ui/badges';@@ -30,7 +31,7 @@ export class GenAILLM extends Component {private openaiReasoningModels: string[];private groqReasoningModels: string[];private searchModels: string[];- private verbositySupportedModels: string[];+ private gpt5ReasoningModels: string[];protected async prepare() {const modelOptions = LLMFormController.prepareModelSelectOptionsByFeatures([@@ -58,8 +59,8 @@ export class GenAILLM extends Component {);this.searchModels = LLMRegistry.getModelsByFeatures('search').map((m) => m.entryId);- // Initialize verbosity supported models by checking for GPT-5/o3 models- this.verbositySupportedModels = LLMRegistry.getVerbositySupportedModels();+ // Why getGpt5ReasoningModels instead of gptReasoningModels, some field like reasoning effort, verbosity etc only supported by gpt 5 models right now.+ this.gpt5ReasoningModels = LLMRegistry.getGpt5ReasoningModels();modelOptions.unshift('Echo');const model = this.data.model || this.defaultModel;@@ -390,10 +391,35 @@ export class GenAILLM extends Component {if (useReasoningElm) {this.toggleReasoningNestedFields(useReasoningElm, form);}+ // #endregion- // Update reasoning effort options for Groq models- if (this.groqReasoningModels.includes(currentElement.value)) {- this.updateReasoningEffortOptions(currentElement.value);+ // #region Update reasoningEffort visibility based on model type+ const reasoningEffortField = form?.querySelector(+ '[data-field-name="reasoningEffort"]',+ ) as HTMLElement;++ if (this.gpt5ReasoningModels.includes(currentElement.value)) {+ // For GPT-5 models, always show reasoningEffort regardless of useReasoning state+ if (reasoningEffortField) {+ reasoningEffortField.classList.remove('hidden');+ // Update reasoning effort options for the new model+ this.updateReasoningEffortOptions(currentElement.value);+ }+ } else if (this.groqReasoningModels.includes(currentElement.value)) {+ // For Groq reasoning models, only show when useReasoning is checked+ if (reasoningEffortField) {+ if (useReasoningElm && useReasoningElm.checked) {+ reasoningEffortField.classList.remove('hidden');+ this.updateReasoningEffortOptions(currentElement.value);+ } else {+ reasoningEffortField.classList.add('hidden');+ }+ }+ } else {+ // For other models, hide reasoningEffort+ if (reasoningEffortField) {+ reasoningEffortField.classList.add('hidden');+ }}// #endregion@@ -672,7 +698,7 @@ export class GenAILLM extends Component {{ text: 'High', value: 'high' },],attributes: {- 'data-supported-models': this.verbositySupportedModels.join(','),+ 'data-supported-models': this.gpt5ReasoningModels.join(','),},help: "Controls the verbosity of the model's response. Lower values result in more concise responses, while higher values result in more verbose responses. Currently supported by GPT-5 models.",tooltipClasses: 'w-56 ',@@ -794,10 +820,21 @@ export class GenAILLM extends Component {reasoningEffort: {type: 'select',label: 'Reasoning Effort',- value: 'default',+ value: this.getDefaultReasoningEffortForModel(+ this.data.model || this.defaultModel,+ this.getReasoningEffortOptions(this.data.model || this.defaultModel),+ ),options: this.getReasoningEffortOptions(this.data.model || this.defaultModel),attributes: {- 'data-supported-models': this.groqReasoningModels.join(','),+ 'data-show-when': [+ {+ models: this.groqReasoningModels,+ field: { useReasoning: true },+ },+ {+ models: this.gpt5ReasoningModels,+ },+ ],},help: 'Controls the level of effort the model will put into reasoning. GPT-OSS models support low/medium/high levels, while Qwen models support none/default.',tooltipClasses: 'w-56 ',@@ -819,7 +856,7 @@ export class GenAILLM extends Component {const verbosityField = form.querySelector('[data-field-name="verbosity"]') as HTMLElement;if (!verbosityField) return;- if (LLMRegistry.isVerbositySupportedModel(modelId)) {+ if (LLMRegistry.isGpt5ReasoningModels(modelId)) {verbosityField.classList.remove('hidden');} else {verbosityField.classList.add('hidden');@@ -1351,54 +1388,61 @@ export class GenAILLM extends Component {fieldsToShow.push('maxThinkingTokens');}- // Only show Groq reasoning fields for Groq models- if (this.groqReasoningModels.includes(currentModel)) {- fieldsToShow.push('reasoningEffort');-- // Update reasoning effort options when fields are shown for Groq models- if (parentField.checked) {+ // Handle reasoning effort field visibility+ const reasoningEffortField = form?.querySelector(+ '[data-field-name="reasoningEffort"]',+ ) as HTMLElement;+ const reasoningOptions = this.getReasoningEffortOptions(currentModel);++ if (reasoningOptions.length > 0) {+ if (this.gpt5ReasoningModels.includes(currentModel)) {+ // For GPT-5 models: Always show reasoningEffort regardless of useReasoning state+ if (reasoningEffortField) {+ reasoningEffortField.classList.remove('hidden');+ }+ // Update reasoning effort optionsthis.updateReasoningEffortOptions(currentModel);+ } else if (this.groqReasoningModels.includes(currentModel)) {+ // For Groq reasoning models: Only show when useReasoning is checked+ if (reasoningEffortField) {+ if (parentField.checked) {+ reasoningEffortField.classList.remove('hidden');+ // Update reasoning effort options when shown+ this.updateReasoningEffortOptions(currentModel);+ } else {+ reasoningEffortField.classList.add('hidden');+ }+ }+ }+ } else {+ // If no reasoning options available, hide the field+ if (reasoningEffortField) {+ reasoningEffortField.classList.add('hidden');}}+ // Handle other nested fields (maxThinkingTokens) with the standard toggle logicthis.toggleNestedFields(parentField, form, fieldsToShow);}/*** Get reasoning effort options based on the current model- * GPT-OSS models: low, medium, high- * Qwen models: none, default+ * Returns empty array for unsupported models to hide the field*/private getReasoningEffortOptions(model: string): { text: string; value: string }[] {- // GPT-OSS models support low, medium, high- if (model.includes('gpt-oss')) {- return [- { text: 'Low', value: 'low' },- { text: 'Medium', value: 'medium' },- { text: 'High', value: 'high' },- ];- }+ if (!model) return [];- // Qwen models support none, default- if (model.includes('qwen')) {- return [- { text: 'None (disabled)', value: 'none' },- { text: 'Default', value: 'default' },- ];- }+ const modelLower = model.toLowerCase();- // Fallback for other Groq models - show all options- return [- { text: 'None (disabled)', value: 'none' },- { text: 'Default', value: 'default' },- { text: 'Low', value: 'low' },- { text: 'Medium', value: 'medium' },- { text: 'High', value: 'high' },- ];+ // Find matching model configuration+ const modelConfig = REASONING_EFFORTS.find((config) => config.pattern.test(modelLower));++ return modelConfig?.options || [];}/*** Update reasoning effort field options based on the selected model+ * Only updates options, visibility is handled by toggleReasoningNestedFields*/private updateReasoningEffortOptions(model: string): void {const field = document.getElementById('reasoningEffort') as HTMLSelectElement;@@ -1408,7 +1452,11 @@ export class GenAILLM extends Component {if (!selectElem) return;const options = this.getReasoningEffortOptions(model);- const currentValue = field.value || 'default';++ // Don't update if no options available - field should be hidden by toggleReasoningNestedFields+ if (options.length === 0) return;++ const currentValue = field.value || 'medium';// Remove all existing optionsif (selectElem.elem?.options) {@@ -1417,16 +1465,46 @@ export class GenAILLM extends Component {// Add new optionsoptions.forEach((option) => {- const isSelected = currentValue === option.value;- selectElem.addOption(option.value, option.text, isSelected);+ selectElem.addOption(option.value, option.text, false); // Don't auto-select during addition});- // If current value is not available in new options, set to first option+ // Determine the best default value for the model type+ const defaultValue = this.getDefaultReasoningEffortForModel(model, options);const availableValues = options.map((opt) => opt.value);- if (!availableValues.includes(currentValue)) {- selectElem.val(options[0].value);++ // Set the appropriate value: current if valid, otherwise default+ const valueToSet = availableValues.includes(currentValue) ? currentValue : defaultValue;+ selectElem.val(valueToSet);+ }++ /**+ * Get the appropriate default reasoning effort value for a given model+ */+ private getDefaultReasoningEffortForModel(+ model: string,+ options: { text: string; value: string }[],+ ): string {+ if (options.length === 0) return '';++ const modelLower = model.toLowerCase();++ // Default values for different model types+ if (+ modelLower.includes('gpt') ||+ modelLower.includes('openai') ||+ modelLower.includes('smythos/gpt')+ ) {+ // For GPT models, prefer 'medium' as a balanced default+ return options.find((opt) => opt.value === 'medium')?.value || options[0].value;+ } else if (modelLower.includes('qwen')) {+ // For Qwen models, prefer 'default' over 'none'+ return options.find((opt) => opt.value === 'default')?.value || options[0].value;}++ // For any other models, use the first available option+ return options[0].value;}+private toggleCountryFieldBasedOnDataSources(form: HTMLFormElement) {const dataSourcesCheckboxes = form?.querySelectorAll('[data-field-name="searchDataSources"] input[type="checkbox"]',diff --git a/packages/app/src/builder-ui/constants.ts b/packages/app/src/builder-ui/constants.tsindex 1b6209fc..e662a9dc 100644--- a/packages/app/src/builder-ui/constants.ts+++ b/packages/app/src/builder-ui/constants.ts@@ -21,3 +21,27 @@ export enum LLM_PROVIDERS {}export const COMPONENT_STATE_KEY = 'component:state';++export const REASONING_EFFORTS = [+ {+ pattern: /^(gpt|smythos\/gpt)/i,+ options: [+ { text: 'Minimal', value: 'minimal' },+ { text: 'Low', value: 'low' },+ { text: 'Medium', value: 'medium' },+ { text: 'High', value: 'high' },+ ],+ },+ {+ pattern: /^openai/i,+ options: [+ { text: 'Low', value: 'low' },+ { text: 'Medium', value: 'medium' },+ { text: 'High', value: 'high' },+ ],+ },+ {+ pattern: /^qwen/i,+ options: [{ text: 'Default', value: 'default' }],+ },+];diff --git a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts b/packages/app/src/builder-ui/helpers/LLMFormController.helper.tsindex 5adde80e..fdd8e6da 100644--- a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts+++ b/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts@@ -50,6 +50,109 @@ export class LLMFormController {}}}++ // Handle conditional requirements after basic model support check+ this.handleConditionalRequirements(modelField);+ }++ /**+ * Handles data-show-when attribute to show/hide fields based on conditional logic.+ * Supports model-based conditions and field value-based conditions.+ *+ * @param modelField - The model select element+ */+ public static handleConditionalRequirements(modelField: HTMLSelectElement) {+ const formGroupElms = modelField+ .closest('.form')+ .querySelectorAll('.form-group, .form-group-div');+ const selectedModel = modelField.value;+ const formElm = modelField.closest('.form');++ if (!formGroupElms || formGroupElms.length === 0 || !formElm) return;++ for (const formGroupElm of formGroupElms) {+ const fieldElm = formGroupElm.querySelector('[data-show-when]');++ if (!fieldElm) continue;++ const conditionAttr = fieldElm.getAttribute('data-show-when');+ if (!conditionAttr) continue;++ let shouldShow = true;++ try {+ // Parse the condition - format: "model:gpt-4,claude-3" or "field:fieldId:true" or combined "model:gpt-4;field:enableFeature:true"+ const conditions = conditionAttr.split(';').map((cond) => cond.trim());++ for (const condition of conditions) {+ const [type, ...params] = condition.split(':');++ if (type === 'model') {+ // Model-based condition: check if current model is in the list+ const requiredModels =+ params[0]?.split(',').map((model) => model.trim().toLowerCase()) || [];+ if (+ requiredModels.length > 0 &&+ !requiredModels.includes(selectedModel?.toLowerCase())+ ) {+ shouldShow = false;+ break;+ }+ } else if (type === 'field') {+ // Field-based condition: check field value+ const [fieldId, expectedValue] = params;+ if (fieldId && expectedValue !== undefined) {+ const targetFieldElm = formElm.querySelector(`#${fieldId}`) as HTMLInputElement;++ if (targetFieldElm) {+ let actualValue: string | boolean;++ // Handle different input types+ if (targetFieldElm.type === 'checkbox') {+ actualValue = targetFieldElm.checked;+ } else if (targetFieldElm.type === 'radio') {+ const radioGroup = formElm.querySelectorAll(+ `input[name="${targetFieldElm.name}"]:checked`,+ );+ actualValue =+ radioGroup.length > 0 ? (radioGroup[0] as HTMLInputElement).value : '';+ } else {+ actualValue = targetFieldElm.value;+ }++ // Convert expected value to proper type for comparison+ let convertedExpectedValue: string | boolean = expectedValue;+ if (expectedValue.toLowerCase() === 'true') {+ convertedExpectedValue = true;+ } else if (expectedValue.toLowerCase() === 'false') {+ convertedExpectedValue = false;+ }++ if (actualValue !== convertedExpectedValue) {+ shouldShow = false;+ break;+ }+ } else {+ // If target field doesn't exist, hide the conditional field+ shouldShow = false;+ break;+ }+ }+ }+ }+ } catch (error) {+ console.warn('Error parsing data-show-when:', conditionAttr, error);+ // On error, default to showing the field to avoid breaking the form+ shouldShow = true;+ }++ // Apply visibility+ if (shouldShow) {+ formGroupElm.classList.remove('hidden');+ } else {+ formGroupElm.classList.add('hidden');+ }+ }}public static updateFieldsInfo(modelField: HTMLSelectElement) {diff --git a/packages/app/src/shared/services/LLMRegistry.service.ts b/packages/app/src/shared/services/LLMRegistry.service.tsindex fbaa65c0..f1a3ec11 100644--- a/packages/app/src/shared/services/LLMRegistry.service.ts+++ b/packages/app/src/shared/services/LLMRegistry.service.ts@@ -24,8 +24,8 @@ export class LLMRegistry {'others',];- // Single source of truth for determining verbosity support- private static readonly VERBOSITY_SUPPORTED_MODEL_PATTERN = /gpt-5/i;+ // Single source of truth for determining GPT5 models (verbosity + reasoning effort support)+ private static readonly GPT5_MODEL_PATTERN = /gpt-5/i;public static getModels(): Record<string, LLMModel> {const models = llmModelsStore.getState()?.models || {};@@ -220,23 +220,27 @@ export class LLMRegistry {}/**- * Get all models that support verbosity parameter+ * Get all GPT5 models that support both verbosity and reasoning effort parameters*- * @returns Array of model IDs that support verbosity+ * @returns Array of model IDs that are GPT5 models*/- public static getVerbositySupportedModels(): string[] {+ public static getGpt5ReasoningModels(): string[] {const models = this.getModels();- return Object.keys(models).filter((modelId) => this.isVerbositySupportedModel(modelId));+ return Object.keys(models).filter((modelId) => this.isGpt5ReasoningModels(modelId));}/**- * Check if a model supports verbosity parameter.- * Delegates to getVerbositySupportedModels for a single source of truth.+ * Check if a model is a GPT5 model (supports both verbosity and reasoning effort).** @param modelId - The model ID to check- * @returns True if the model supports verbosity parameter+ * @returns True if the model is a GPT5 model*/- public static isVerbositySupportedModel(modelId: string): boolean {- return Boolean(modelId && this.VERBOSITY_SUPPORTED_MODEL_PATTERN.test(modelId));+ public static isGpt5ReasoningModels(modelId: string): boolean {+ const models = this.getModels();+ return Boolean(+ modelId &&+ this.GPT5_MODEL_PATTERN.test(modelId) &&+ models?.[modelId]?.features?.includes('reasoning'),+ );}}