forked from open-webui/open-webui
		
	Merge remote-tracking branch 'upstream/dev' into feat/add-i18n
This commit is contained in:
		
						commit
						f221e39c24
					
				
					 15 changed files with 526 additions and 207 deletions
				
			
		| 
						 | 
				
			
			@ -6,6 +6,7 @@
 | 
			
		|||
	import auto_render from 'katex/dist/contrib/auto-render.mjs';
 | 
			
		||||
	import 'katex/dist/katex.min.css';
 | 
			
		||||
 | 
			
		||||
	import { fade } from 'svelte/transition';
 | 
			
		||||
	import { createEventDispatcher } from 'svelte';
 | 
			
		||||
	import { onMount, tick, getContext } from 'svelte';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -278,13 +279,15 @@
 | 
			
		|||
 | 
			
		||||
	const generateImage = async (message) => {
 | 
			
		||||
		generatingImage = true;
 | 
			
		||||
		const res = await imageGenerations(localStorage.token, message.content);
 | 
			
		||||
		const res = await imageGenerations(localStorage.token, message.content).catch((error) => {
 | 
			
		||||
			toast.error(error);
 | 
			
		||||
		});
 | 
			
		||||
		console.log(res);
 | 
			
		||||
 | 
			
		||||
		if (res) {
 | 
			
		||||
			message.files = res.images.map((image) => ({
 | 
			
		||||
			message.files = res.map((image) => ({
 | 
			
		||||
				type: 'image',
 | 
			
		||||
				url: `data:image/png;base64,${image}`
 | 
			
		||||
				url: `${image.url}`
 | 
			
		||||
			}));
 | 
			
		||||
 | 
			
		||||
			dispatch('save', message);
 | 
			
		||||
| 
						 | 
				
			
			@ -479,7 +482,7 @@
 | 
			
		|||
													xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
													fill="none"
 | 
			
		||||
													viewBox="0 0 24 24"
 | 
			
		||||
													stroke-width="1.5"
 | 
			
		||||
													stroke-width="2"
 | 
			
		||||
													stroke="currentColor"
 | 
			
		||||
													class="w-4 h-4"
 | 
			
		||||
												>
 | 
			
		||||
| 
						 | 
				
			
			@ -505,7 +508,7 @@
 | 
			
		|||
													xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
													fill="none"
 | 
			
		||||
													viewBox="0 0 24 24"
 | 
			
		||||
													stroke-width="1.5"
 | 
			
		||||
													stroke-width="2"
 | 
			
		||||
													stroke="currentColor"
 | 
			
		||||
													class="w-4 h-4"
 | 
			
		||||
												>
 | 
			
		||||
| 
						 | 
				
			
			@ -624,7 +627,7 @@
 | 
			
		|||
														xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
														fill="none"
 | 
			
		||||
														viewBox="0 0 24 24"
 | 
			
		||||
														stroke-width="1.5"
 | 
			
		||||
														stroke-width="2"
 | 
			
		||||
														stroke="currentColor"
 | 
			
		||||
														class="w-4 h-4"
 | 
			
		||||
													>
 | 
			
		||||
| 
						 | 
				
			
			@ -639,7 +642,7 @@
 | 
			
		|||
														xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
														fill="none"
 | 
			
		||||
														viewBox="0 0 24 24"
 | 
			
		||||
														stroke-width="1.5"
 | 
			
		||||
														stroke-width="2"
 | 
			
		||||
														stroke="currentColor"
 | 
			
		||||
														class="w-4 h-4"
 | 
			
		||||
													>
 | 
			
		||||
| 
						 | 
				
			
			@ -705,7 +708,7 @@
 | 
			
		|||
															xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
															fill="none"
 | 
			
		||||
															viewBox="0 0 24 24"
 | 
			
		||||
															stroke-width="1.5"
 | 
			
		||||
															stroke-width="2"
 | 
			
		||||
															stroke="currentColor"
 | 
			
		||||
															class="w-4 h-4"
 | 
			
		||||
														>
 | 
			
		||||
| 
						 | 
				
			
			@ -735,7 +738,7 @@
 | 
			
		|||
														xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
														fill="none"
 | 
			
		||||
														viewBox="0 0 24 24"
 | 
			
		||||
														stroke-width="1.5"
 | 
			
		||||
														stroke-width="2"
 | 
			
		||||
														stroke="currentColor"
 | 
			
		||||
														class="w-4 h-4"
 | 
			
		||||
													>
 | 
			
		||||
| 
						 | 
				
			
			@ -764,7 +767,7 @@
 | 
			
		|||
														xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
														fill="none"
 | 
			
		||||
														viewBox="0 0 24 24"
 | 
			
		||||
														stroke-width="1.5"
 | 
			
		||||
														stroke-width="2"
 | 
			
		||||
														stroke="currentColor"
 | 
			
		||||
														class="w-4 h-4"
 | 
			
		||||
													>
 | 
			
		||||
| 
						 | 
				
			
			@ -794,7 +797,7 @@
 | 
			
		|||
														xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
														fill="none"
 | 
			
		||||
														viewBox="0 0 24 24"
 | 
			
		||||
														stroke-width="1.5"
 | 
			
		||||
														stroke-width="2"
 | 
			
		||||
														stroke="currentColor"
 | 
			
		||||
														class="w-4 h-4"
 | 
			
		||||
													>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -261,7 +261,7 @@
 | 
			
		|||
									xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
									fill="none"
 | 
			
		||||
									viewBox="0 0 24 24"
 | 
			
		||||
									stroke-width="1.5"
 | 
			
		||||
									stroke-width="2"
 | 
			
		||||
									stroke="currentColor"
 | 
			
		||||
									class="w-4 h-4"
 | 
			
		||||
								>
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +285,7 @@
 | 
			
		|||
									xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
									fill="none"
 | 
			
		||||
									viewBox="0 0 24 24"
 | 
			
		||||
									stroke-width="1.5"
 | 
			
		||||
									stroke-width="2"
 | 
			
		||||
									stroke="currentColor"
 | 
			
		||||
									class="w-4 h-4"
 | 
			
		||||
								>
 | 
			
		||||
| 
						 | 
				
			
			@ -310,7 +310,7 @@
 | 
			
		|||
										xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
										fill="none"
 | 
			
		||||
										viewBox="0 0 24 24"
 | 
			
		||||
										stroke-width="1.5"
 | 
			
		||||
										stroke-width="2"
 | 
			
		||||
										stroke="currentColor"
 | 
			
		||||
										class="w-4 h-4"
 | 
			
		||||
									>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -186,7 +186,7 @@
 | 
			
		|||
			<div class=" my-2.5 text-sm font-medium">{$i18n.t('System Prompt')}</div>
 | 
			
		||||
			<textarea
 | 
			
		||||
				bind:value={system}
 | 
			
		||||
				class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
 | 
			
		||||
				class="w-full rounded-lg p-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none resize-none"
 | 
			
		||||
				rows="4"
 | 
			
		||||
			/>
 | 
			
		||||
		</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,16 +5,18 @@
 | 
			
		|||
	import { config, user } from '$lib/stores';
 | 
			
		||||
	import {
 | 
			
		||||
		getAUTOMATIC1111Url,
 | 
			
		||||
		getDefaultDiffusionModel,
 | 
			
		||||
		getDiffusionModels,
 | 
			
		||||
		getImageGenerationEnabledStatus,
 | 
			
		||||
		getImageGenerationModels,
 | 
			
		||||
		getDefaultImageGenerationModel,
 | 
			
		||||
		updateDefaultImageGenerationModel,
 | 
			
		||||
		getImageSize,
 | 
			
		||||
		toggleImageGenerationEnabledStatus,
 | 
			
		||||
		getImageGenerationConfig,
 | 
			
		||||
		updateImageGenerationConfig,
 | 
			
		||||
		updateAUTOMATIC1111Url,
 | 
			
		||||
		updateDefaultDiffusionModel,
 | 
			
		||||
		updateImageSize,
 | 
			
		||||
		getImageSteps,
 | 
			
		||||
		updateImageSteps
 | 
			
		||||
		updateImageSteps,
 | 
			
		||||
		getOpenAIKey,
 | 
			
		||||
		updateOpenAIKey
 | 
			
		||||
	} from '$lib/apis/images';
 | 
			
		||||
	import { getBackendConfig } from '$lib/apis';
 | 
			
		||||
	const dispatch = createEventDispatcher();
 | 
			
		||||
| 
						 | 
				
			
			@ -25,8 +27,11 @@
 | 
			
		|||
 | 
			
		||||
	let loading = false;
 | 
			
		||||
 | 
			
		||||
	let imageGenerationEngine = '';
 | 
			
		||||
	let enableImageGeneration = false;
 | 
			
		||||
 | 
			
		||||
	let AUTOMATIC1111_BASE_URL = '';
 | 
			
		||||
	let OPENAI_API_KEY = '';
 | 
			
		||||
 | 
			
		||||
	let selectedModel = '';
 | 
			
		||||
	let models = null;
 | 
			
		||||
| 
						 | 
				
			
			@ -35,11 +40,11 @@
 | 
			
		|||
	let steps = 50;
 | 
			
		||||
 | 
			
		||||
	const getModels = async () => {
 | 
			
		||||
		models = await getDiffusionModels(localStorage.token).catch((error) => {
 | 
			
		||||
		models = await getImageGenerationModels(localStorage.token).catch((error) => {
 | 
			
		||||
			toast.error(error);
 | 
			
		||||
			return null;
 | 
			
		||||
		});
 | 
			
		||||
		selectedModel = await getDefaultDiffusionModel(localStorage.token).catch((error) => {
 | 
			
		||||
		selectedModel = await getDefaultImageGenerationModel(localStorage.token).catch((error) => {
 | 
			
		||||
			return '';
 | 
			
		||||
		});
 | 
			
		||||
	};
 | 
			
		||||
| 
						 | 
				
			
			@ -64,33 +69,45 @@
 | 
			
		|||
			AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
	const toggleImageGeneration = async () => {
 | 
			
		||||
		if (AUTOMATIC1111_BASE_URL) {
 | 
			
		||||
			enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token).catch(
 | 
			
		||||
				(error) => {
 | 
			
		||||
					toast.error(error);
 | 
			
		||||
					return false;
 | 
			
		||||
				}
 | 
			
		||||
			);
 | 
			
		||||
	const updateImageGeneration = async () => {
 | 
			
		||||
		const res = await updateImageGenerationConfig(
 | 
			
		||||
			localStorage.token,
 | 
			
		||||
			imageGenerationEngine,
 | 
			
		||||
			enableImageGeneration
 | 
			
		||||
		).catch((error) => {
 | 
			
		||||
			toast.error(error);
 | 
			
		||||
			return null;
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
			if (enableImageGeneration) {
 | 
			
		||||
				config.set(await getBackendConfig(localStorage.token));
 | 
			
		||||
				getModels();
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			enableImageGeneration = false;
 | 
			
		||||
			toast.error($i18n.t('{{item}} not provided', { item: 'AUTOMATIC1111_BASE_URL' }));
 | 
			
		||||
		if (res) {
 | 
			
		||||
			imageGenerationEngine = res.engine;
 | 
			
		||||
			enableImageGeneration = res.enabled;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (enableImageGeneration) {
 | 
			
		||||
			config.set(await getBackendConfig(localStorage.token));
 | 
			
		||||
			getModels();
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	onMount(async () => {
 | 
			
		||||
		if ($user.role === 'admin') {
 | 
			
		||||
			enableImageGeneration = await getImageGenerationEnabledStatus(localStorage.token);
 | 
			
		||||
			AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
 | 
			
		||||
			const res = await getImageGenerationConfig(localStorage.token).catch((error) => {
 | 
			
		||||
				toast.error(error);
 | 
			
		||||
				return null;
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
			if (enableImageGeneration && AUTOMATIC1111_BASE_URL) {
 | 
			
		||||
				imageSize = await getImageSize(localStorage.token);
 | 
			
		||||
				steps = await getImageSteps(localStorage.token);
 | 
			
		||||
			if (res) {
 | 
			
		||||
				imageGenerationEngine = res.engine;
 | 
			
		||||
				enableImageGeneration = res.enabled;
 | 
			
		||||
			}
 | 
			
		||||
			AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
 | 
			
		||||
			OPENAI_API_KEY = await getOpenAIKey(localStorage.token);
 | 
			
		||||
 | 
			
		||||
			imageSize = await getImageSize(localStorage.token);
 | 
			
		||||
			steps = await getImageSteps(localStorage.token);
 | 
			
		||||
 | 
			
		||||
			if (enableImageGeneration) {
 | 
			
		||||
				getModels();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +118,11 @@
 | 
			
		|||
	class="flex flex-col h-full justify-between space-y-3 text-sm"
 | 
			
		||||
	on:submit|preventDefault={async () => {
 | 
			
		||||
		loading = true;
 | 
			
		||||
		await updateDefaultDiffusionModel(localStorage.token, selectedModel);
 | 
			
		||||
		await updateOpenAIKey(localStorage.token, OPENAI_API_KEY);
 | 
			
		||||
 | 
			
		||||
		await updateDefaultImageGenerationModel(localStorage.token, selectedModel);
 | 
			
		||||
 | 
			
		||||
		await updateDefaultImageGenerationModel(localStorage.token, selectedModel);
 | 
			
		||||
		await updateImageSize(localStorage.token, imageSize).catch((error) => {
 | 
			
		||||
			toast.error(error);
 | 
			
		||||
			return null;
 | 
			
		||||
| 
						 | 
				
			
			@ -119,6 +140,23 @@
 | 
			
		|||
		<div>
 | 
			
		||||
			<div class=" mb-1 text-sm font-medium">{$i18n.t('Image Settings')}</div>
 | 
			
		||||
 | 
			
		||||
			<div class=" py-0.5 flex w-full justify-between">
 | 
			
		||||
				<div class=" self-center text-xs font-medium">Image Generation Engine</div>
 | 
			
		||||
				<div class="flex items-center relative">
 | 
			
		||||
					<select
 | 
			
		||||
						class="w-fit pr-8 rounded px-2 p-1 text-xs bg-transparent outline-none text-right"
 | 
			
		||||
						bind:value={imageGenerationEngine}
 | 
			
		||||
						placeholder="Select a mode"
 | 
			
		||||
						on:change={async () => {
 | 
			
		||||
							await updateImageGeneration();
 | 
			
		||||
						}}
 | 
			
		||||
					>
 | 
			
		||||
						<option value="">Default (Automatic1111)</option>
 | 
			
		||||
						<option value="openai">Open AI (Dall-E)</option>
 | 
			
		||||
					</select>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
 | 
			
		||||
			<div>
 | 
			
		||||
				<div class=" py-0.5 flex w-full justify-between">
 | 
			
		||||
					<div class=" self-center text-xs font-medium">
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +166,17 @@
 | 
			
		|||
					<button
 | 
			
		||||
						class="p-1 px-3 text-xs flex rounded transition"
 | 
			
		||||
						on:click={() => {
 | 
			
		||||
							toggleImageGeneration();
 | 
			
		||||
							if (imageGenerationEngine === '' && AUTOMATIC1111_BASE_URL === '') {
 | 
			
		||||
								toast.error('AUTOMATIC1111 Base URL is required.');
 | 
			
		||||
								enableImageGeneration = false;
 | 
			
		||||
							} else if (imageGenerationEngine === 'openai' && OPENAI_API_KEY === '') {
 | 
			
		||||
								toast.error('OpenAI API Key is required.');
 | 
			
		||||
								enableImageGeneration = false;
 | 
			
		||||
							} else {
 | 
			
		||||
								enableImageGeneration = !enableImageGeneration;
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							updateImageGeneration();
 | 
			
		||||
						}}
 | 
			
		||||
						type="button"
 | 
			
		||||
					>
 | 
			
		||||
| 
						 | 
				
			
			@ -143,50 +191,62 @@
 | 
			
		|||
		</div>
 | 
			
		||||
		<hr class=" dark:border-gray-700" />
 | 
			
		||||
 | 
			
		||||
		<div class=" mb-2.5 text-sm font-medium">{$i18n.t('AUTOMATIC1111 Base URL')}</div>
 | 
			
		||||
		<div class="flex w-full">
 | 
			
		||||
			<div class="flex-1 mr-2">
 | 
			
		||||
				<input
 | 
			
		||||
					class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
 | 
			
		||||
					placeholder="Enter URL (e.g. http://127.0.0.1:7860/)"
 | 
			
		||||
					bind:value={AUTOMATIC1111_BASE_URL}
 | 
			
		||||
				/>
 | 
			
		||||
			</div>
 | 
			
		||||
			<button
 | 
			
		||||
				class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded transition"
 | 
			
		||||
				type="button"
 | 
			
		||||
				on:click={() => {
 | 
			
		||||
					// updateOllamaAPIUrlHandler();
 | 
			
		||||
 | 
			
		||||
					updateAUTOMATIC1111UrlHandler();
 | 
			
		||||
				}}
 | 
			
		||||
			>
 | 
			
		||||
				<svg
 | 
			
		||||
					xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
					viewBox="0 0 20 20"
 | 
			
		||||
					fill="currentColor"
 | 
			
		||||
					class="w-4 h-4"
 | 
			
		||||
				>
 | 
			
		||||
					<path
 | 
			
		||||
						fill-rule="evenodd"
 | 
			
		||||
						d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
 | 
			
		||||
						clip-rule="evenodd"
 | 
			
		||||
		{#if imageGenerationEngine === ''}
 | 
			
		||||
			<div class=" mb-2.5 text-sm font-medium">{$i18n.t('AUTOMATIC1111 Base URL')}</div>
 | 
			
		||||
			<div class="flex w-full">
 | 
			
		||||
				<div class="flex-1 mr-2">
 | 
			
		||||
					<input
 | 
			
		||||
						class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
						placeholder="Enter URL (e.g. http://127.0.0.1:7860/)"
 | 
			
		||||
						bind:value={AUTOMATIC1111_BASE_URL}
 | 
			
		||||
					/>
 | 
			
		||||
				</svg>
 | 
			
		||||
			</button>
 | 
			
		||||
		</div>
 | 
			
		||||
				</div>
 | 
			
		||||
				<button
 | 
			
		||||
					class="px-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 rounded-lg transition"
 | 
			
		||||
					type="button"
 | 
			
		||||
					on:click={() => {
 | 
			
		||||
						// updateOllamaAPIUrlHandler();
 | 
			
		||||
 | 
			
		||||
		<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
 | 
			
		||||
			{$i18n.t('Include `--api` flag when running stable-diffusion-webui')}
 | 
			
		||||
			<a
 | 
			
		||||
				class=" text-gray-300 font-medium underline"
 | 
			
		||||
				href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/3734"
 | 
			
		||||
				target="_blank"
 | 
			
		||||
			>
 | 
			
		||||
				<br />
 | 
			
		||||
				{$i18n.t('(e.g. `sh webui.sh --api`)')}
 | 
			
		||||
			</a>
 | 
			
		||||
		</div>
 | 
			
		||||
						updateAUTOMATIC1111UrlHandler();
 | 
			
		||||
					}}
 | 
			
		||||
				>
 | 
			
		||||
					<svg
 | 
			
		||||
						xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
						viewBox="0 0 20 20"
 | 
			
		||||
						fill="currentColor"
 | 
			
		||||
						class="w-4 h-4"
 | 
			
		||||
					>
 | 
			
		||||
						<path
 | 
			
		||||
							fill-rule="evenodd"
 | 
			
		||||
							d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
 | 
			
		||||
							clip-rule="evenodd"
 | 
			
		||||
						/>
 | 
			
		||||
					</svg>
 | 
			
		||||
				</button>
 | 
			
		||||
			</div>
 | 
			
		||||
 | 
			
		||||
			<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
 | 
			
		||||
				Include `--api` flag when running stable-diffusion-webui
 | 
			
		||||
				<a
 | 
			
		||||
					class=" text-gray-300 font-medium"
 | 
			
		||||
					href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/3734"
 | 
			
		||||
					target="_blank"
 | 
			
		||||
				>
 | 
			
		||||
					(e.g. `sh webui.sh --api`)
 | 
			
		||||
				</a>
 | 
			
		||||
			</div>
 | 
			
		||||
		{:else if imageGenerationEngine === 'openai'}
 | 
			
		||||
			<div class=" mb-2.5 text-sm font-medium">OpenAI API Key</div>
 | 
			
		||||
			<div class="flex w-full">
 | 
			
		||||
				<div class="flex-1 mr-2">
 | 
			
		||||
					<input
 | 
			
		||||
						class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
						placeholder="Enter API Key"
 | 
			
		||||
						bind:value={OPENAI_API_KEY}
 | 
			
		||||
					/>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
		{/if}
 | 
			
		||||
 | 
			
		||||
		{#if enableImageGeneration}
 | 
			
		||||
			<hr class=" dark:border-gray-700" />
 | 
			
		||||
| 
						 | 
				
			
			@ -196,7 +256,7 @@
 | 
			
		|||
				<div class="flex w-full">
 | 
			
		||||
					<div class="flex-1 mr-2">
 | 
			
		||||
						<select
 | 
			
		||||
							class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
 | 
			
		||||
							class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
							bind:value={selectedModel}
 | 
			
		||||
							placeholder={$i18n.t('Select a model')}
 | 
			
		||||
						>
 | 
			
		||||
| 
						 | 
				
			
			@ -204,9 +264,7 @@
 | 
			
		|||
								<option value="" disabled selected>{$i18n.t('Select a model')}</option>
 | 
			
		||||
							{/if}
 | 
			
		||||
							{#each models ?? [] as model}
 | 
			
		||||
								<option value={model.title} class="bg-gray-100 dark:bg-gray-700"
 | 
			
		||||
									>{model.model_name}</option
 | 
			
		||||
								>
 | 
			
		||||
								<option value={model.id} class="bg-gray-100 dark:bg-gray-700">{model.name}</option>
 | 
			
		||||
							{/each}
 | 
			
		||||
						</select>
 | 
			
		||||
					</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +276,7 @@
 | 
			
		|||
				<div class="flex w-full">
 | 
			
		||||
					<div class="flex-1 mr-2">
 | 
			
		||||
						<input
 | 
			
		||||
							class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
 | 
			
		||||
							class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
							placeholder="Enter Image Size (e.g. 512x512)"
 | 
			
		||||
							bind:value={imageSize}
 | 
			
		||||
						/>
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +289,7 @@
 | 
			
		|||
				<div class="flex w-full">
 | 
			
		||||
					<div class="flex-1 mr-2">
 | 
			
		||||
						<input
 | 
			
		||||
							class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
 | 
			
		||||
							class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
							placeholder="Enter Number of Steps (e.g. 50)"
 | 
			
		||||
							bind:value={steps}
 | 
			
		||||
						/>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@
 | 
			
		|||
	let liteLLMAPIBase = '';
 | 
			
		||||
	let liteLLMAPIKey = '';
 | 
			
		||||
	let liteLLMRPM = '';
 | 
			
		||||
	let liteLLMMaxTokens = '';
 | 
			
		||||
 | 
			
		||||
	let deleteLiteLLMModelId = '';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -336,7 +337,8 @@
 | 
			
		|||
				model: liteLLMModel,
 | 
			
		||||
				api_base: liteLLMAPIBase,
 | 
			
		||||
				api_key: liteLLMAPIKey,
 | 
			
		||||
				rpm: liteLLMRPM
 | 
			
		||||
				rpm: liteLLMRPM,
 | 
			
		||||
				max_tokens: liteLLMMaxTokens
 | 
			
		||||
			}).catch((error) => {
 | 
			
		||||
				toast.error(error);
 | 
			
		||||
				return null;
 | 
			
		||||
| 
						 | 
				
			
			@ -356,6 +358,7 @@
 | 
			
		|||
		liteLLMAPIBase = '';
 | 
			
		||||
		liteLLMAPIKey = '';
 | 
			
		||||
		liteLLMRPM = '';
 | 
			
		||||
		liteLLMMaxTokens = '';
 | 
			
		||||
 | 
			
		||||
		liteLLMModelInfo = await getLiteLLMModelInfo(localStorage.token);
 | 
			
		||||
		models.set(await getModels());
 | 
			
		||||
| 
						 | 
				
			
			@ -838,6 +841,22 @@
 | 
			
		|||
									</div>
 | 
			
		||||
								</div>
 | 
			
		||||
							</div>
 | 
			
		||||
 | 
			
		||||
							<div>
 | 
			
		||||
								<div class="mb-1.5 text-sm font-medium">Max Tokens</div>
 | 
			
		||||
								<div class="flex w-full">
 | 
			
		||||
									<div class="flex-1">
 | 
			
		||||
										<input
 | 
			
		||||
											class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
 | 
			
		||||
											placeholder="Enter Max Tokens (litellm_params.max_tokens)"
 | 
			
		||||
											bind:value={liteLLMMaxTokens}
 | 
			
		||||
											type="number"
 | 
			
		||||
											min="1"
 | 
			
		||||
											autocomplete="off"
 | 
			
		||||
										/>
 | 
			
		||||
									</div>
 | 
			
		||||
								</div>
 | 
			
		||||
							</div>
 | 
			
		||||
						{/if}
 | 
			
		||||
					</div>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue