feat: edit file content support

This commit is contained in:
Timothy J. Baek
2024-10-04 00:46:32 -07:00
parent 630a78cead
commit 8013c152d0
5 changed files with 147 additions and 6 deletions
+35
View File
@@ -173,6 +173,41 @@ export const addFileToKnowledgeById = async (token: string, id: string, fileId:
return res;
};
export const updateFileFromKnowledgeById = async (token: string, id: string, fileId: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/knowledge/${id}/file/update`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: `Bearer ${token}`
},
body: JSON.stringify({
file_id: fileId
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err.detail;
console.log(err);
return null;
});
if (error) {
throw error;
}
return res;
};
export const removeFileFromKnowledgeById = async (token: string, id: string, fileId: string) => {
let error = null;