refac
This commit is contained in:
@@ -171,6 +171,38 @@ export const getPromptByCommand = async (token: string, command: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getPromptById = async (token: string, promptId: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/id/${promptId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.then((json) => {
|
||||
return json;
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
|
||||
console.error(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updatePromptByCommand = async (token: string, prompt: PromptItem) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
{#each filteredItems as prompt}
|
||||
<a
|
||||
class=" flex space-x-4 cursor-pointer text-left w-full px-3 py-2.5 dark:hover:bg-gray-850/50 hover:bg-gray-50 transition rounded-2xl"
|
||||
href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
|
||||
href={`/workspace/prompts/${prompt.id}`}
|
||||
>
|
||||
<div class=" flex flex-col flex-1 space-x-4 cursor-pointer w-full pl-1">
|
||||
<div class="flex items-center justify-between w-full">
|
||||
|
||||
Reference in New Issue
Block a user