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;

View file

@ -53,8 +53,8 @@
<div class=" text-lg font-medium mt-2">/</div>
</div>
<div class="max-h-60 flex flex-col w-full">
<div class=" overflow-y-auto bg-white p-2 rounded-r-lg space-y-0.5">
<div class="max-h-60 flex flex-col w-full rounded-r-lg">
<div class=" overflow-y-auto bg-white p-2 rounded-t-lg space-y-0.5">
{#each filteredPromptCommands as command, commandIdx}
<button
class=" px-3 py-1.5 rounded-lg w-full text-left {commandIdx === selectedCommandIdx
@ -80,7 +80,9 @@
{/each}
</div>
<div class=" px-2 py-0.5 text-xs text-gray-600 flex items-center space-x-1">
<div
class=" px-2 py-0.5 text-xs text-gray-600 bg-white rounded-b-lg flex items-center space-x-1"
>
<div>
<svg
xmlns="http://www.w3.org/2000/svg"