chore: format

This commit is contained in:
Timothy Jaeryang Baek
2024-11-16 23:46:12 -08:00
parent c24bc60d35
commit c338f2cae1
64 changed files with 2668 additions and 1212 deletions
-1
View File
@@ -62,7 +62,6 @@ export const getGroups = async (token: string = '') => {
return res;
};
export const getGroupById = async (token: string, id: string) => {
let error = null;
+1 -4
View File
@@ -2,9 +2,7 @@ import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
export const getModels = async (token: string = '', base: boolean = false) => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/models${
base ? '/base' : ''
}`, {
const res = await fetch(`${WEBUI_BASE_URL}/api/models${base ? '/base' : ''}`, {
method: 'GET',
headers: {
Accept: 'application/json',
@@ -21,7 +19,6 @@ export const getModels = async (token: string = '', base: boolean = false) => {
console.log(err);
return null;
});
if (error) {
throw error;
+7 -2
View File
@@ -1,6 +1,11 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
export const createNewKnowledge = async (token: string, name: string, description: string, accessControl: null|object) => {
export const createNewKnowledge = async (
token: string,
name: string,
description: string,
accessControl: null | object
) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/create`, {
@@ -131,7 +136,7 @@ type KnowledgeUpdateForm = {
name?: string;
description?: string;
data?: object;
access_control?: null|object;
access_control?: null | object;
};
export const updateKnowledgeById = async (token: string, id: string, form: KnowledgeUpdateForm) => {
-9
View File
@@ -1,6 +1,5 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
export const getModels = async (token: string = '') => {
let error = null;
@@ -32,8 +31,6 @@ export const getModels = async (token: string = '') => {
return res;
};
export const getBaseModels = async (token: string = '') => {
let error = null;
@@ -65,8 +62,6 @@ export const getBaseModels = async (token: string = '') => {
return res;
};
export const createNewModel = async (token: string, model: object) => {
let error = null;
@@ -96,8 +91,6 @@ export const createNewModel = async (token: string, model: object) => {
return res;
};
export const getModelById = async (token: string, id: string) => {
let error = null;
@@ -133,7 +126,6 @@ export const getModelById = async (token: string, id: string) => {
return res;
};
export const toggleModelById = async (token: string, id: string) => {
let error = null;
@@ -169,7 +161,6 @@ export const toggleModelById = async (token: string, id: string) => {
return res;
};
export const updateModelById = async (token: string, id: string, model: object) => {
let error = null;
+18 -24
View File
@@ -1,6 +1,5 @@
import { OLLAMA_API_BASE_URL } from '$lib/constants';
export const verifyOllamaConnection = async (
token: string = '',
url: string = '',
@@ -8,21 +7,18 @@ export const verifyOllamaConnection = async (
) => {
let error = null;
const res = await fetch(
`${OLLAMA_API_BASE_URL}/verify`,
{
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url,
key
})
}
)
const res = await fetch(`${OLLAMA_API_BASE_URL}/verify`, {
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
url,
key
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
@@ -72,10 +68,10 @@ export const getOllamaConfig = async (token: string = '') => {
};
type OllamaConfig = {
ENABLE_OLLAMA_API: boolean,
OLLAMA_BASE_URLS: string[],
OLLAMA_API_CONFIGS: object
}
ENABLE_OLLAMA_API: boolean;
OLLAMA_BASE_URLS: string[];
OLLAMA_API_CONFIGS: object;
};
export const updateOllamaConfig = async (token: string = '', config: OllamaConfig) => {
let error = null;
@@ -211,12 +207,10 @@ export const getOllamaVersion = async (token: string, urlIdx?: number) => {
return res?.version ?? false;
};
export const getOllamaModels = async (token: string = '', urlIdx: null|number = null) => {
export const getOllamaModels = async (token: string = '', urlIdx: null | number = null) => {
let error = null;
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/tags${
urlIdx !== null ? `/${urlIdx}` : ''
}`, {
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/tags${urlIdx !== null ? `/${urlIdx}` : ''}`, {
method: 'GET',
headers: {
Accept: 'application/json',
+13 -21
View File
@@ -32,15 +32,12 @@ export const getOpenAIConfig = async (token: string = '') => {
return res;
};
type OpenAIConfig = {
ENABLE_OPENAI_API: boolean;
OPENAI_API_BASE_URLS: string[];
OPENAI_API_KEYS: string[];
OPENAI_API_CONFIGS: object;
}
};
export const updateOpenAIConfig = async (token: string = '', config: OpenAIConfig) => {
let error = null;
@@ -109,7 +106,6 @@ export const getOpenAIUrls = async (token: string = '') => {
return res.OPENAI_API_BASE_URLS;
};
export const updateOpenAIUrls = async (token: string = '', urls: string[]) => {
let error = null;
@@ -249,22 +245,18 @@ export const verifyOpenAIConnection = async (
) => {
let error = null;
const res = await fetch(
`${OPENAI_API_BASE_URL}/verify`,
{
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url,
key
})
}
)
const res = await fetch(`${OPENAI_API_BASE_URL}/verify`, {
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
url,
key
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
+6 -19
View File
@@ -1,19 +1,13 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
type PromptItem = {
command: string;
title: string;
content: string;
access_control: null|object;
}
access_control: null | object;
};
export const createNewPrompt = async (
token: string,
prompt: PromptItem
) => {
export const createNewPrompt = async (token: string, prompt: PromptItem) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/create`, {
@@ -25,7 +19,7 @@ export const createNewPrompt = async (
},
body: JSON.stringify({
...prompt,
command: `/${prompt.command}`,
command: `/${prompt.command}`
})
})
.then(async (res) => {
@@ -76,7 +70,6 @@ export const getPrompts = async (token: string = '') => {
return res;
};
export const getPromptList = async (token: string = '') => {
let error = null;
@@ -108,7 +101,6 @@ export const getPromptList = async (token: string = '') => {
return res;
};
export const getPromptByCommand = async (token: string, command: string) => {
let error = null;
@@ -141,12 +133,7 @@ export const getPromptByCommand = async (token: string, command: string) => {
return res;
};
export const updatePromptByCommand = async (
token: string,
prompt: PromptItem
) => {
export const updatePromptByCommand = async (token: string, prompt: PromptItem) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${prompt.command}/update`, {
@@ -158,7 +145,7 @@ export const updatePromptByCommand = async (
},
body: JSON.stringify({
...prompt,
command: `/${prompt.command}`,
command: `/${prompt.command}`
})
})
.then(async (res) => {
-2
View File
@@ -62,7 +62,6 @@ export const getTools = async (token: string = '') => {
return res;
};
export const getToolList = async (token: string = '') => {
let error = null;
@@ -94,7 +93,6 @@ export const getToolList = async (token: string = '') => {
return res;
};
export const exportTools = async (token: string = '') => {
let error = null;
-3
View File
@@ -1,7 +1,6 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
import { getUserPosition } from '$lib/utils';
export const getUserGroups = async (token: string) => {
let error = null;
@@ -29,8 +28,6 @@ export const getUserGroups = async (token: string) => {
return res;
};
export const getUserDefaultPermissions = async (token: string) => {
let error = null;