refac
This commit is contained in:
1 parent
00924fbf79
commit
8c57cfa645
1 file changed
+11
-6
@@ -28,7 +28,7 @@ export const getMemories = async (token: string) => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addNewMemory = async (token: string, content: string) => {
|
export const addNewMemory = async (token: string, content: string, type = 'user') => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/memories/add`, {
|
const res = await fetch(`${WEBUI_API_BASE_URL}/memories/add`, {
|
||||||
@@ -39,7 +39,8 @@ export const addNewMemory = async (token: string, content: string) => {
|
|||||||
authorization: `Bearer ${token}`
|
authorization: `Bearer ${token}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
content: content
|
content: content,
|
||||||
|
type
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
@@ -59,8 +60,14 @@ export const addNewMemory = async (token: string, content: string) => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateMemoryById = async (token: string, id: string, content: string) => {
|
export const updateMemoryById = async (
|
||||||
|
token: string,
|
||||||
|
id: string,
|
||||||
|
content: string,
|
||||||
|
type?: string
|
||||||
|
) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
const body = type ? { content, type } : { content };
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/memories/${id}/update`, {
|
const res = await fetch(`${WEBUI_API_BASE_URL}/memories/${id}/update`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -69,9 +76,7 @@ export const updateMemoryById = async (token: string, id: string, content: strin
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
authorization: `Bearer ${token}`
|
authorization: `Bearer ${token}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(body)
|
||||||
content: content
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (!res.ok) throw await res.json();
|
if (!res.ok) throw await res.json();
|
||||||
|
|||||||
Reference in new issue
Block a user