File size: 3,154 Bytes
bc27e65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<script>

	import { toast } from 'svelte-sonner';



	import { createEventDispatcher, getContext, onMount } from 'svelte';

	const i18n = getContext('i18n');

	const dispatch = createEventDispatcher();



	import { user } from '$lib/stores';



	import Modal from '$lib/components/common/Modal.svelte';

	import ManageOllama from './Manage/ManageOllama.svelte';

	import { getOllamaConfig } from '$lib/apis/ollama';

	import Spinner from '$lib/components/common/Spinner.svelte';

	import ManageMultipleOllama from './Manage/ManageMultipleOllama.svelte';



	export let show = false;



	let selected = null;

	let ollamaConfig = null;



	onMount(async () => {

		if ($user?.role === 'admin') {

			await Promise.all([

				(async () => {

					ollamaConfig = await getOllamaConfig(localStorage.token);

				})()

			]);



			if (ollamaConfig) {

				selected = 'ollama';

				return;

			}



			selected = '';

		}

	});

</script>

<Modal size="sm" bind:show>
	<div>

		<div class=" flex justify-between dark:text-gray-100 px-5 pt-4">

			<div class=" text-lg font-medium self-center font-primary">

				{$i18n.t('Manage Models')}

			</div>

			<button

				class="self-center"

				on:click={() => {

					show = false;

				}}

			>

				<svg

					xmlns="http://www.w3.org/2000/svg"

					viewBox="0 0 20 20"

					fill="currentColor"

					class="w-5 h-5"

				>

					<path

						d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"

					/>

				</svg>

			</button>
		</div>

		<div class="flex flex-col md:flex-row w-full px-3 pb-4 md:space-x-4 dark:text-gray-200">

			<div class=" flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6">

				{#if selected === ''}

					<div class=" py-5 text-gray-400 text-xs">

						<div>

							{$i18n.t('No inference engine with management support found')}

						</div>

					</div>

				{:else if selected !== null}

					<div class=" flex w-full flex-col">

						<div

							class="flex gap-1 scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-full bg-transparent dark:text-gray-200"

						>

							<button

								class="min-w-fit rounded-full p-1.5 {selected === 'ollama'

									? ''

									: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"

								on:click={() => {

									selected = 'ollama';

								}}>{$i18n.t('Ollama')}</button

							>



							<!-- <button

								class="min-w-fit rounded-full p-1.5 {selected === 'llamacpp'

									? ''

									: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"

								on:click={() => {

									selected = 'llamacpp';

								}}>{$i18n.t('Llama.cpp')}</button

							> -->

						</div>



						<div class=" px-1.5 py-1">

							{#if selected === 'ollama'}

								<ManageMultipleOllama {ollamaConfig} />

							{/if}

						</div>

					</div>

				{:else}

					<div class=" py-5">

						<Spinner />

					</div>

				{/if}

			</div>
		</div>
	</div>
</Modal>