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
populate context window and maximum output tokens properly
Forhad Hosaind878dd537612
diff --git a/packages/app/src/react/features/vault/components/create-user-custom-model-modal.tsx b/packages/app/src/react/features/vault/components/create-user-custom-model-modal.tsxindex 45810b01..2381d28f 100644--- a/packages/app/src/react/features/vault/components/create-user-custom-model-modal.tsx+++ b/packages/app/src/react/features/vault/components/create-user-custom-model-modal.tsx@@ -119,12 +119,31 @@ export function CreateUserCustomModelModal({}));};+ /**+ * Handles numeric input changes for context window and max output tokens+ * @param field - The field name to update+ * @param value - The string value from the input+ */const handleNumericInputChange = (field: string, value: string) => {- const numValue = value === '' ? undefined : parseInt(value, 10);- setFormData((prev) => ({- ...prev,- [field]: numValue,- }));+ // If empty string, set to undefined+ if (value === '') {+ setFormData((prev) => ({+ ...prev,+ [field]: undefined,+ }));+ return;+ }++ // Parse the number+ const numValue = parseInt(value, 10);++ // Only update if it's a valid number (not NaN)+ if (!isNaN(numValue)) {+ setFormData((prev) => ({+ ...prev,+ [field]: numValue,+ }));+ }};/**@@ -256,7 +275,7 @@ export function CreateUserCustomModelModal({min="2048"max="2000000"step="4"- value={formData.contextWindow || ''}+ value={formData.contextWindow !== undefined ? String(formData.contextWindow) : ''}onChange={(e) => handleNumericInputChange('contextWindow', e.target.value)}placeholder="128000"fullWidth@@ -277,7 +296,7 @@ export function CreateUserCustomModelModal({min="256"max="200000"step="4"- value={formData.maxOutputTokens || ''}+ value={formData.maxOutputTokens !== undefined ? String(formData.maxOutputTokens) : ''}onChange={(e) => handleNumericInputChange('maxOutputTokens', e.target.value)}placeholder="4096"fullWidthdiff --git a/packages/app/src/react/features/vault/vault-business-logic.ts b/packages/app/src/react/features/vault/vault-business-logic.tsindex 9a8157e0..d49e889a 100644--- a/packages/app/src/react/features/vault/vault-business-logic.ts+++ b/packages/app/src/react/features/vault/vault-business-logic.ts@@ -673,14 +673,16 @@ export const userCustomModelService = {}// Convert the user custom LLM data to our UserCustomModel format+ // Handle both new field names (contextWindow, maxOutputTokens) and old ones (tokens, completionTokens)const models = Object.entries(result.data || {}).map(([id, value]: [string, any]) => ({id: value.id || id,name: value.name,modelId: value.modelId,baseURL: value.baseURL,provider: value.provider,- contextWindow: value.contextWindow,- maxOutputTokens: value.maxOutputTokens,+ // Check for new field name first, then fall back to old field name+ contextWindow: value.contextWindow !== undefined ? value.contextWindow : value.tokens,+ maxOutputTokens: value.maxOutputTokens !== undefined ? value.maxOutputTokens : value.completionTokens,fallbackLLM: value.fallbackLLM || '', // Provide default empty string for backward compatibility with cached datafeatures: value.features,}));