feat: prompt crud

This commit is contained in:
Timothy J. Baek 2024-01-02 21:35:47 -08:00
parent 69ff596045
commit 7fc1d7c2c7
7 changed files with 167 additions and 451 deletions

View file

@ -16,7 +16,7 @@ export const createNewPrompt = async (
authorization: `Bearer ${token}`
},
body: JSON.stringify({
command: command,
command: `/${command}`,
title: title,
content: content
})
@ -57,7 +57,7 @@ export const getPrompts = async (token: string = '') => {
return json;
})
.catch((err) => {
error = err;
error = err.detail;
console.log(err);
return null;
});
@ -88,7 +88,7 @@ export const getPromptByCommand = async (token: string, command: string) => {
return json;
})
.catch((err) => {
error = err;
error = err.detail;
console.log(err);
return null;
@ -117,7 +117,7 @@ export const updatePromptByCommand = async (
authorization: `Bearer ${token}`
},
body: JSON.stringify({
command: command,
command: `/${command}`,
title: title,
content: content
})
@ -130,7 +130,7 @@ export const updatePromptByCommand = async (
return json;
})
.catch((err) => {
error = err;
error = err.detail;
console.log(err);
return null;
@ -146,6 +146,8 @@ export const updatePromptByCommand = async (
export const deletePromptByCommand = async (token: string, command: string) => {
let error = null;
command = command.charAt(0) === '/' ? command.slice(1) : command;
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/${command}/delete`, {
method: 'DELETE',
headers: {
@ -162,7 +164,7 @@ export const deletePromptByCommand = async (token: string, command: string) => {
return json;
})
.catch((err) => {
error = err;
error = err.detail;
console.log(err);
return null;