This commit is contained in:
Timothy Jaeryang Baek
2024-11-16 17:49:13 -08:00
parent af0ba53715
commit a1ce8422fd
9 changed files with 67 additions and 69 deletions

View File

@@ -1,10 +1,18 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
type PromptItem = {
command: string;
title: string;
content: string;
access_control: null|object;
}
export const createNewPrompt = async (
token: string,
command: string,
title: string,
content: string
prompt: PromptItem
) => {
let error = null;
@@ -16,9 +24,8 @@ export const createNewPrompt = async (
authorization: `Bearer ${token}`
},
body: JSON.stringify({
command: `/${command}`,
title: title,
content: content
...prompt,
command: `/${prompt.command}`,
})
})
.then(async (res) => {
@@ -134,15 +141,15 @@ export const getPromptByCommand = async (token: string, command: string) => {
return res;
};
export const updatePromptByCommand = async (
token: string,
command: string,
title: string,
content: string
prompt: PromptItem
) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${command}/update`, {
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${prompt.command}/update`, {
method: 'POST',
headers: {
Accept: 'application/json',
@@ -150,9 +157,8 @@ export const updatePromptByCommand = async (
authorization: `Bearer ${token}`
},
body: JSON.stringify({
command: `/${command}`,
title: title,
content: content
...prompt,
command: `/${prompt.command}`,
})
})
.then(async (res) => {