Browse Source

refac: num_predict renamed to max_tokens

Timothy J. Baek 11 months ago
parent
commit
bd6ccf8c15

+ 3 - 3
src/lib/components/chat/Chat.svelte

@@ -479,7 +479,8 @@
 						? $settings.params.stop.map((str) =>
 						? $settings.params.stop.map((str) =>
 								decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
 								decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
 						  )
 						  )
-						: undefined
+						: undefined,
+				num_predict: $settings?.params?.max_tokens ?? undefined
 			},
 			},
 			format: $settings.requestFormat ?? undefined,
 			format: $settings.requestFormat ?? undefined,
 			keep_alive: $settings.keepAlive ?? undefined,
 			keep_alive: $settings.keepAlive ?? undefined,
@@ -726,9 +727,8 @@
 							: undefined,
 							: undefined,
 					temperature: $settings?.params?.temperature ?? undefined,
 					temperature: $settings?.params?.temperature ?? undefined,
 					top_p: $settings?.params?.top_p ?? undefined,
 					top_p: $settings?.params?.top_p ?? undefined,
-					num_ctx: $settings?.params?.num_ctx ?? undefined,
 					frequency_penalty: $settings?.params?.repeat_penalty ?? undefined,
 					frequency_penalty: $settings?.params?.repeat_penalty ?? undefined,
-					max_tokens: $settings?.params?.num_predict ?? undefined,
+					max_tokens: $settings?.params?.max_tokens ?? undefined,
 					docs: docs.length > 0 ? docs : undefined,
 					docs: docs.length > 0 ? docs : undefined,
 					citations: docs.length > 0
 					citations: docs.length > 0
 				},
 				},

+ 2 - 2
src/lib/components/chat/Settings/Advanced.svelte

@@ -25,7 +25,7 @@
 		stop: '',
 		stop: '',
 		tfs_z: '',
 		tfs_z: '',
 		num_ctx: '',
 		num_ctx: '',
-		num_predict: ''
+		max_tokens: ''
 	};
 	};
 
 
 	const toggleRequestFormat = async () => {
 	const toggleRequestFormat = async () => {
@@ -141,7 +141,7 @@
 						top_p: params.top_p !== '' ? params.top_p : undefined,
 						top_p: params.top_p !== '' ? params.top_p : undefined,
 						tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
 						tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
 						num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
 						num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
-						num_predict: params.num_predict !== '' ? params.num_predict : undefined
+						max_tokens: params.max_tokens !== '' ? params.max_tokens : undefined
 					},
 					},
 					keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
 					keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
 				});
 				});

+ 7 - 7
src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte

@@ -19,7 +19,7 @@
 		top_p: '',
 		top_p: '',
 		tfs_z: '',
 		tfs_z: '',
 		num_ctx: '',
 		num_ctx: '',
-		num_predict: '',
+		max_tokens: '',
 		template: null
 		template: null
 	};
 	};
 
 
@@ -561,16 +561,16 @@
 	</div>
 	</div>
 	<div class=" py-0.5 w-full justify-between">
 	<div class=" py-0.5 w-full justify-between">
 		<div class="flex w-full justify-between">
 		<div class="flex w-full justify-between">
-			<div class=" self-center text-xs font-medium">{$i18n.t('Max Tokens')}</div>
+			<div class=" self-center text-xs font-medium">{$i18n.t('Max Tokens (num_predict)')}</div>
 
 
 			<button
 			<button
 				class="p-1 px-3 text-xs flex rounded transition"
 				class="p-1 px-3 text-xs flex rounded transition"
 				type="button"
 				type="button"
 				on:click={() => {
 				on:click={() => {
-					params.num_predict = (params?.num_predict ?? '') === '' ? 128 : '';
+					params.max_tokens = (params?.max_tokens ?? '') === '' ? 128 : '';
 				}}
 				}}
 			>
 			>
-				{#if (params?.num_predict ?? '') === ''}
+				{#if (params?.max_tokens ?? '') === ''}
 					<span class="ml-2 self-center">{$i18n.t('Default')}</span>
 					<span class="ml-2 self-center">{$i18n.t('Default')}</span>
 				{:else}
 				{:else}
 					<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
 					<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
@@ -578,7 +578,7 @@
 			</button>
 			</button>
 		</div>
 		</div>
 
 
-		{#if (params?.num_predict ?? '') !== ''}
+		{#if (params?.max_tokens ?? '') !== ''}
 			<div class="flex mt-0.5 space-x-2">
 			<div class="flex mt-0.5 space-x-2">
 				<div class=" flex-1">
 				<div class=" flex-1">
 					<input
 					<input
@@ -587,13 +587,13 @@
 						min="-2"
 						min="-2"
 						max="16000"
 						max="16000"
 						step="1"
 						step="1"
-						bind:value={params.num_predict}
+						bind:value={params.max_tokens}
 						class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
 						class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
 					/>
 					/>
 				</div>
 				</div>
 				<div class="">
 				<div class="">
 					<input
 					<input
-						bind:value={params.num_predict}
+						bind:value={params.max_tokens}
 						type="number"
 						type="number"
 						class=" bg-transparent text-center w-14"
 						class=" bg-transparent text-center w-14"
 						min="-2"
 						min="-2"

+ 2 - 2
src/lib/components/chat/Settings/General.svelte

@@ -55,7 +55,7 @@
 		stop: '',
 		stop: '',
 		tfs_z: '',
 		tfs_z: '',
 		num_ctx: '',
 		num_ctx: '',
-		num_predict: ''
+		max_tokens: ''
 	};
 	};
 
 
 	const toggleRequestFormat = async () => {
 	const toggleRequestFormat = async () => {
@@ -313,7 +313,7 @@
 						top_p: params.top_p !== '' ? params.top_p : undefined,
 						top_p: params.top_p !== '' ? params.top_p : undefined,
 						tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
 						tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
 						num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
 						num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
-						num_predict: params.num_predict !== '' ? params.num_predict : undefined
+						max_tokens: params.max_tokens !== '' ? params.max_tokens : undefined
 					},
 					},
 					keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
 					keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
 				});
 				});