mirror of
https://github.com/open-webui/open-webui
synced 2025-03-04 11:29:59 +00:00
refac: manage ollama
This commit is contained in:
parent
7593d11b97
commit
419005a578
@ -44,8 +44,8 @@
|
|||||||
let modelTag = '';
|
let modelTag = '';
|
||||||
|
|
||||||
let createModelLoading = false;
|
let createModelLoading = false;
|
||||||
let createModelTag = '';
|
let createModelObject = {};
|
||||||
let createModelContent = '';
|
|
||||||
let createModelDigest = '';
|
let createModelDigest = '';
|
||||||
let createModelPullProgress = null;
|
let createModelPullProgress = null;
|
||||||
|
|
||||||
@ -427,12 +427,8 @@
|
|||||||
|
|
||||||
const createModelHandler = async () => {
|
const createModelHandler = async () => {
|
||||||
createModelLoading = true;
|
createModelLoading = true;
|
||||||
const res = await createModel(
|
|
||||||
localStorage.token,
|
const res = await createModel(localStorage.token, createModelObject, urlIdx).catch((error) => {
|
||||||
createModelTag,
|
|
||||||
createModelContent,
|
|
||||||
urlIdx
|
|
||||||
).catch((error) => {
|
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -496,18 +492,21 @@
|
|||||||
|
|
||||||
createModelLoading = false;
|
createModelLoading = false;
|
||||||
|
|
||||||
createModelTag = '';
|
createModelObject = {};
|
||||||
createModelContent = '';
|
|
||||||
createModelDigest = '';
|
createModelDigest = '';
|
||||||
createModelPullProgress = null;
|
createModelPullProgress = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
loading = true;
|
loading = true;
|
||||||
ollamaModels = await getOllamaModels(localStorage.token, urlIdx);
|
ollamaModels = await getOllamaModels(localStorage.token, urlIdx).catch((error) => {
|
||||||
|
toast.error(`${error}`);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
console.log(ollamaModels);
|
if (ollamaModels) {
|
||||||
loading = false;
|
loading = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: if (urlIdx !== null) {
|
$: if (urlIdx !== null) {
|
||||||
@ -747,12 +746,12 @@
|
|||||||
placeholder={$i18n.t('Enter model tag (e.g. {{modelTag}})', {
|
placeholder={$i18n.t('Enter model tag (e.g. {{modelTag}})', {
|
||||||
modelTag: 'my-modelfile'
|
modelTag: 'my-modelfile'
|
||||||
})}
|
})}
|
||||||
bind:value={createModelTag}
|
bind:value={createModelObject.model}
|
||||||
disabled={createModelLoading}
|
disabled={createModelLoading}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
bind:value={createModelContent}
|
bind:value={createModelObject.content}
|
||||||
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-100 dark:bg-gray-850 outline-none resize-none scrollbar-hidden"
|
class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-100 dark:bg-gray-850 outline-none resize-none scrollbar-hidden"
|
||||||
rows="6"
|
rows="6"
|
||||||
placeholder={`TEMPLATE """{{ .System }}\nUSER: {{ .Prompt }}\nASSISTANT: """\nPARAMETER num_ctx 4096\nPARAMETER stop "</s>"\nPARAMETER stop "USER:"\nPARAMETER stop "ASSISTANT:"`}
|
placeholder={`TEMPLATE """{{ .System }}\nUSER: {{ .Prompt }}\nASSISTANT: """\nPARAMETER num_ctx 4096\nPARAMETER stop "</s>"\nPARAMETER stop "USER:"\nPARAMETER stop "ASSISTANT:"`}
|
||||||
@ -1013,6 +1012,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{:else if ollamaModels === null}
|
||||||
|
<div class="flex justify-center items-center w-full h-full text-xs py-3">
|
||||||
|
{$i18n.t('Failed to fetch models')}
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<Spinner />
|
<div class="flex justify-center items-center w-full h-full py-3">
|
||||||
|
<Spinner />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user