Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
302bd11b
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "561778d04dfc25f06bca4d94d0ac4ed6fc236005"
Commit
302bd11b
authored
Mar 24, 2024
by
Timothy J. Baek
Browse files
fix: pull model from selector
parent
c19ea89a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
14 deletions
+42
-14
src/lib/components/chat/ModelSelector/Selector.svelte
src/lib/components/chat/ModelSelector/Selector.svelte
+16
-14
src/lib/utils/index.ts
src/lib/utils/index.ts
+26
-0
No files found.
src/lib/components/chat/ModelSelector/Selector.svelte
View file @
302bd11b
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
import { cancelOllamaRequest, deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama';
import { cancelOllamaRequest, deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama';
import { user, MODEL_DOWNLOAD_POOL } from '$lib/stores';
import { user, MODEL_DOWNLOAD_POOL
, models
} from '$lib/stores';
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { splitStream } from '$lib/utils';
import {
getModels,
splitStream } from '$lib/utils';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
const i18n = getContext('i18n');
const i18n = getContext('i18n');
...
@@ -141,6 +141,8 @@
...
@@ -141,6 +141,8 @@
modelName: sanitizedModelTag
modelName: sanitizedModelTag
})
})
);
);
models.set(await getModels(localStorage.token));
} else {
} else {
toast.error('Download canceled');
toast.error('Download canceled');
}
}
...
@@ -233,6 +235,17 @@
...
@@ -233,6 +235,17 @@
</div>
</div>
{/each}
{/each}
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user.role === 'admin'}
<button
class="flex w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-none transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-850 rounded-lg cursor-pointer data-[highlighted]:bg-muted"
on:click={() => {
pullModelHandler();
}}
>
Pull "{searchValue}" from Ollama.com
</button>
{/if}
{#each Object.keys($MODEL_DOWNLOAD_POOL) as model}
{#each Object.keys($MODEL_DOWNLOAD_POOL) as model}
<div
<div
class="flex w-full justify-between font-medium select-none rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-none transition-all duration-75 rounded-lg cursor-pointer data-[highlighted]:bg-muted"
class="flex w-full justify-between font-medium select-none rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-none transition-all duration-75 rounded-lg cursor-pointer data-[highlighted]:bg-muted"
...
@@ -279,7 +292,7 @@
...
@@ -279,7 +292,7 @@
</div>
</div>
</div>
</div>
<div class="mr-
3
translate-y-0.5">
<div class="mr-
2
translate-y-0.5">
<Tooltip content="Cancel">
<Tooltip content="Cancel">
<button
<button
class="text-gray-800 dark:text-gray-100"
class="text-gray-800 dark:text-gray-100"
...
@@ -309,17 +322,6 @@
...
@@ -309,17 +322,6 @@
</div>
</div>
</div>
</div>
{/each}
{/each}
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user.role === 'admin'}
<button
class="flex w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-none transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-850 rounded-lg cursor-pointer data-[highlighted]:bg-muted"
on:click={() => {
pullModelHandler();
}}
>
Pull "{searchValue}" from Ollama.com
</button>
{/if}
</div>
</div>
</slot>
</slot>
</Select.Content>
</Select.Content>
...
...
src/lib/utils/index.ts
View file @
302bd11b
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
import
sha256
from
'
js-sha256
'
;
import
sha256
from
'
js-sha256
'
;
import
{
getOllamaModels
}
from
'
$lib/apis/ollama
'
;
import
{
getOpenAIModels
}
from
'
$lib/apis/openai
'
;
import
{
getLiteLLMModels
}
from
'
$lib/apis/litellm
'
;
export
const
getModels
=
async
(
token
:
string
)
=>
{
let
models
=
await
Promise
.
all
([
await
getOllamaModels
(
token
).
catch
((
error
)
=>
{
console
.
log
(
error
);
return
null
;
}),
await
getOpenAIModels
(
token
).
catch
((
error
)
=>
{
console
.
log
(
error
);
return
null
;
}),
await
getLiteLLMModels
(
token
).
catch
((
error
)
=>
{
console
.
log
(
error
);
return
null
;
})
]);
models
=
models
.
filter
((
models
)
=>
models
)
.
reduce
((
a
,
e
,
i
,
arr
)
=>
a
.
concat
(
e
,
...(
i
<
arr
.
length
-
1
?
[{
name
:
'
hr
'
}]
:
[])),
[]);
return
models
;
};
//////////////////////////
//////////////////////////
// Helper functions
// Helper functions
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment