refac
This commit is contained in:
1 parent
6ab7d54982
commit
44da9c6523
4 files changed
+75
-7
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user