mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 08:25:01 -06:00
refac
This commit is contained in:
@@ -28,7 +28,7 @@ export const getMemories = async (token: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const addNewMemory = async (token: string, content: string) => {
|
||||
export const addNewMemory = async (token: string, content: string, type = 'user') => {
|
||||
let error = null;
|
||||
|
||||
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}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: content
|
||||
content: content,
|
||||
type
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
@@ -59,8 +60,14 @@ export const addNewMemory = async (token: string, content: string) => {
|
||||
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;
|
||||
const body = type ? { content, type } : { content };
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/memories/${id}/update`, {
|
||||
method: 'POST',
|
||||
@@ -69,9 +76,7 @@ export const updateMemoryById = async (token: string, id: string, content: strin
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: content
|
||||
})
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
|
||||
Reference in New Issue
Block a user