refac
This commit is contained in:
1 parent
de939a6562
commit
8cbb7f765c
11 files changed
+580
-17
No files matched your search
@@ -58,7 +58,12 @@ export const updateChatConfig = async (token: string, config: object) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const createNewChat = async (token: string, chat: object, folderId: string | null) => {
|
||||
export const createNewChat = async (
|
||||
token: string,
|
||||
chat: object,
|
||||
folderId: string | null,
|
||||
variables: object | null = null
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/new`, {
|
||||
@@ -70,6 +75,7 @@ export const createNewChat = async (token: string, chat: object, folderId: strin
|
||||
},
|
||||
body: JSON.stringify({
|
||||
chat: chat,
|
||||
...(variables !== null ? { variables } : {}),
|
||||
folder_id: folderId ?? null
|
||||
})
|
||||
})
|
||||
@@ -1197,7 +1203,12 @@ export const getChatAccessGrants = async (token: string, id: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateChatById = async (token: string, id: string, chat: object) => {
|
||||
export const updateChatById = async (
|
||||
token: string,
|
||||
id: string,
|
||||
chat: object,
|
||||
variables: object | null = null
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}`, {
|
||||
@@ -1208,7 +1219,8 @@ export const updateChatById = async (token: string, id: string, chat: object) =>
|
||||
...(token && { authorization: `Bearer ${token}` })
|
||||
},
|
||||
body: JSON.stringify({
|
||||
chat: chat
|
||||
chat: chat,
|
||||
...(variables !== null ? { variables } : {})
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
|
||||
@@ -163,7 +163,14 @@ export const getModels = async (
|
||||
// Remove duplicates
|
||||
const modelsMap = {};
|
||||
for (const model of models) {
|
||||
modelsMap[model.id] = model;
|
||||
const existing = modelsMap[model.id];
|
||||
modelsMap[model.id] = existing
|
||||
? {
|
||||
...existing,
|
||||
...model,
|
||||
info: existing.info ?? model.info
|
||||
}
|
||||
: model;
|
||||
}
|
||||
|
||||
models = Object.values(modelsMap);
|
||||
|
||||
Reference in new issue
Block a user