feat: modelfile backend & ollama version 0.0.0 whitelisted
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
import Advanced from '$lib/components/chat/Settings/Advanced.svelte';
|
||||
import { splitStream } from '$lib/utils';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { createModel } from '$lib/apis/ollama';
|
||||
import { createNewModelfile, getModelfiles } from '$lib/apis/modelfiles';
|
||||
|
||||
let loading = false;
|
||||
|
||||
@@ -93,11 +95,14 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
||||
};
|
||||
|
||||
const saveModelfile = async (modelfile) => {
|
||||
await modelfiles.set([
|
||||
...$modelfiles.filter((m) => m.tagName !== modelfile.tagName),
|
||||
modelfile
|
||||
]);
|
||||
localStorage.setItem('modelfiles', JSON.stringify($modelfiles));
|
||||
// await modelfiles.set([
|
||||
// ...$modelfiles.filter((m) => m.tagName !== modelfile.tagName),
|
||||
// modelfile
|
||||
// ]);
|
||||
// localStorage.setItem('modelfiles', JSON.stringify($modelfiles));
|
||||
|
||||
await createNewModelfile(localStorage.token, modelfile);
|
||||
await modelfiles.set(await getModelfiles(localStorage.token));
|
||||
};
|
||||
|
||||
const submitHandler = async () => {
|
||||
@@ -128,17 +133,12 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
||||
Object.keys(categories).filter((category) => categories[category]).length > 0 &&
|
||||
!$models.includes(tagName)
|
||||
) {
|
||||
const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/create`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'text/event-stream',
|
||||
...($user && { Authorization: `Bearer ${localStorage.token}` })
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: tagName,
|
||||
modelfile: content
|
||||
})
|
||||
});
|
||||
const res = await createModel(
|
||||
$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL,
|
||||
localStorage.token,
|
||||
tagName,
|
||||
content
|
||||
);
|
||||
|
||||
if (res) {
|
||||
const reader = res.body
|
||||
|
||||
Reference in New Issue
Block a user