feat: modelfiles to models
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { getModels as _getModels } from '$lib/utils';
|
||||
import { getAllModels as _getAllModels } from '$lib/utils';
|
||||
import { getOllamaVersion } from '$lib/apis/ollama';
|
||||
import { getModelfiles } from '$lib/apis/modelfiles';
|
||||
import { getModels } from '$lib/apis/models';
|
||||
import { getPrompts } from '$lib/apis/prompts';
|
||||
|
||||
import { getDocs } from '$lib/apis/documents';
|
||||
@@ -46,8 +46,8 @@
|
||||
|
||||
let showShortcuts = false;
|
||||
|
||||
const getModels = async () => {
|
||||
return _getModels(localStorage.token);
|
||||
const getAllModels = async () => {
|
||||
return _getAllModels(localStorage.token);
|
||||
};
|
||||
|
||||
const setOllamaVersion = async (version: string = '') => {
|
||||
@@ -91,10 +91,10 @@
|
||||
|
||||
await Promise.all([
|
||||
(async () => {
|
||||
models.set(await getModels());
|
||||
models.set(await getAllModels());
|
||||
})(),
|
||||
(async () => {
|
||||
modelfiles.set(await getModelfiles(localStorage.token));
|
||||
modelfiles.set(await getModels(localStorage.token));
|
||||
})(),
|
||||
(async () => {
|
||||
prompts.set(await getPrompts(localStorage.token));
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
modelfiles.subscribe(async () => {
|
||||
// should fetch models
|
||||
models.set(await getModels());
|
||||
models.set(await getAllModels());
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { splitStream } from '$lib/utils';
|
||||
import { onMount, tick, getContext } from 'svelte';
|
||||
import { createModel } from '$lib/apis/ollama';
|
||||
import { createNewModelfile, getModelfileByTagName, getModelfiles } from '$lib/apis/modelfiles';
|
||||
import { addNewModel, getModelById, getModels } from '$lib/apis/models';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -98,8 +98,8 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
||||
};
|
||||
|
||||
const saveModelfile = async (modelfile) => {
|
||||
await createNewModelfile(localStorage.token, modelfile);
|
||||
await modelfiles.set(await getModelfiles(localStorage.token));
|
||||
await addNewModel(localStorage.token, modelfile);
|
||||
await modelfiles.set(await getModels(localStorage.token));
|
||||
};
|
||||
|
||||
const submitHandler = async () => {
|
||||
@@ -116,7 +116,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
||||
|
||||
if (
|
||||
$models.map((model) => model.name).includes(tagName) ||
|
||||
(await getModelfileByTagName(localStorage.token, tagName).catch(() => false))
|
||||
(await getModelById(localStorage.token, tagName).catch(() => false))
|
||||
) {
|
||||
toast.error(
|
||||
`Uh-oh! It looks like you already have a model named '${tagName}'. Please choose a different name to complete your modelfile.`
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import { splitStream } from '$lib/utils';
|
||||
|
||||
import { createModel } from '$lib/apis/ollama';
|
||||
import { getModelfiles, updateModelfileByTagName } from '$lib/apis/modelfiles';
|
||||
import { getModels, updateModelById } from '$lib/apis/models';
|
||||
|
||||
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
|
||||
|
||||
@@ -85,8 +85,8 @@
|
||||
});
|
||||
|
||||
const updateModelfile = async (modelfile) => {
|
||||
await updateModelfileByTagName(localStorage.token, modelfile.tagName, modelfile);
|
||||
await modelfiles.set(await getModelfiles(localStorage.token));
|
||||
await updateModelById(localStorage.token, modelfile.tagName, modelfile);
|
||||
await modelfiles.set(await getModels(localStorage.token));
|
||||
};
|
||||
|
||||
const updateHandler = async () => {
|
||||
|
||||
Reference in New Issue
Block a user