浏览代码

Set whether to stream responses for this model individually, overriding the global setting

kivvi 7 月之前
父节点
当前提交
40d7d7d6dd
共有 2 个文件被更改,包括 27 次插入2 次删除
  1. 2 2
      src/lib/components/chat/Chat.svelte
  2. 25 0
      src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte

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

@@ -912,7 +912,7 @@
 
 		await tick();
 
-		const stream = $settings?.streamResponse ?? true;
+		const stream = model?.info?.params?.stream_response ?? $settings?.streamResponse ?? true;
 		const [res, controller] = await generateChatCompletion(localStorage.token, {
 			stream: stream,
 			model: model.id,
@@ -1206,7 +1206,7 @@
 		await tick();
 
 		try {
-			const stream = $settings?.streamResponse ?? true;
+			const stream = model?.info?.params?.stream_response ?? $settings?.streamResponse ?? true;
 			const [res, controller] = await generateOpenAIChatCompletion(
 				localStorage.token,
 				{

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

@@ -10,6 +10,7 @@
 
 	export let params = {
 		// Advanced
+		stream_response: null,	// Set stream responses for this model individually
 		seed: null,
 		stop: null,
 		temperature: null,
@@ -42,6 +43,30 @@
 </script>
 
 <div class=" space-y-1 text-xs pb-safe-bottom">
+	<div>
+		<div class=" py-0.5 flex w-full justify-between">
+			<div class=" self-center text-xs">
+				{$i18n.t('Stream Chat Response')}
+			</div>
+
+			<button
+				class="p-1 px-3 text-xs flex rounded transition"
+				on:click={() => {
+				params.stream_response = (params?.stream_response ?? null) === null ? true : (params.stream_response ? false : null);
+			}}
+				type="button"
+			>
+				{#if params.stream_response === true}
+					<span class="ml-2 self-center">{$i18n.t('On')}</span>
+				{:else if params.stream_response === false}
+					<span class="ml-2 self-center">{$i18n.t('Off')}</span>
+				{:else}
+					<span class="ml-2 self-center">{$i18n.t('Default')}</span>
+				{/if}
+			</button>
+		</div>
+	</div>
+
 	<div class=" py-0.5 w-full justify-between">
 		<div class="flex w-full justify-between">
 			<div class=" self-center text-xs font-medium">{$i18n.t('Seed')}</div>