refac
This commit is contained in:
@@ -218,6 +218,42 @@ export const getNoteById = async (token: string, id: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getNoteChatById = async (token: string, id: string) => {
|
||||
let error = null;
|
||||
const url = `${WEBUI_API_BASE_URL}/notes/${id}/chat`;
|
||||
|
||||
console.info('[note-chat] fetching linked chat', { noteId: id, url });
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.info('[note-chat] linked chat response', {
|
||||
noteId: id,
|
||||
status: res.status,
|
||||
ok: res.ok
|
||||
});
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
console.error('[note-chat] linked chat request failed', { noteId: id, error: err });
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateNoteById = async (token: string, id: string, note: NoteItem) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user