mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
refac
This commit is contained in:
parent
00924fbf79
commit
8c57cfa645
1 changed files with 11 additions and 6 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue