enh: reference note in chat

This commit is contained in:
Timothy Jaeryang Baek
2025-07-09 01:17:25 +04:00
parent f2ee99d760
commit d5f9bbc7a7
8 changed files with 105 additions and 24 deletions
+36 -1
View File
@@ -39,7 +39,7 @@ export const createNewNote = async (token: string, note: NoteItem) => {
return res;
};
export const getNotes = async (token: string = '') => {
export const getNotes = async (token: string = '', raw: boolean = false) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/notes/`, {
@@ -67,6 +67,10 @@ export const getNotes = async (token: string = '') => {
throw error;
}
if (raw) {
return res; // Return raw response if requested
}
if (!Array.isArray(res)) {
return {}; // or throw new Error("Notes response is not an array")
}
@@ -87,6 +91,37 @@ export const getNotes = async (token: string = '') => {
return grouped;
};
export const getNoteList = async (token: string = '') => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/notes/list`, {
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 getNoteById = async (token: string, id: string) => {
let error = null;