57 files changed
+2994
-879
No files matched your search
@@ -3,10 +3,11 @@ import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
type ChannelForm = {
|
||||
type?: string;
|
||||
name: string;
|
||||
is_private?: boolean;
|
||||
is_private?: boolean | null;
|
||||
data?: object;
|
||||
meta?: object;
|
||||
access_control?: object;
|
||||
access_grants?: object[];
|
||||
group_ids?: string[];
|
||||
user_ids?: string[];
|
||||
};
|
||||
|
||||
|
||||
@@ -99,6 +99,38 @@ export const getGroupById = async (token: string, id: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getGroupInfoById = async (token: string, id: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/groups/id/${id}/info`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.then((json) => {
|
||||
return json;
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
|
||||
console.error(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateGroupById = async (token: string, id: string, group: object) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ export const createNewKnowledge = async (
|
||||
token: string,
|
||||
name: string,
|
||||
description: string,
|
||||
accessControl: null | object
|
||||
accessGrants: object[]
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
@@ -18,7 +18,7 @@ export const createNewKnowledge = async (
|
||||
body: JSON.stringify({
|
||||
name: name,
|
||||
description: description,
|
||||
access_control: accessControl
|
||||
access_grants: accessGrants
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
@@ -248,7 +248,7 @@ type KnowledgeUpdateForm = {
|
||||
name?: string;
|
||||
description?: string;
|
||||
data?: object;
|
||||
access_control?: null | object;
|
||||
access_grants?: object[];
|
||||
};
|
||||
|
||||
export const updateKnowledgeById = async (token: string, id: string, form: KnowledgeUpdateForm) => {
|
||||
@@ -265,7 +265,7 @@ export const updateKnowledgeById = async (token: string, id: string, form: Knowl
|
||||
name: form?.name ? form.name : undefined,
|
||||
description: form?.description ? form.description : undefined,
|
||||
data: form?.data ? form.data : undefined,
|
||||
access_control: form.access_control
|
||||
access_grants: form.access_grants
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
|
||||
@@ -5,7 +5,7 @@ type NoteItem = {
|
||||
title: string;
|
||||
data: object;
|
||||
meta?: null | object;
|
||||
access_control?: null | object;
|
||||
access_grants?: object[];
|
||||
};
|
||||
|
||||
export const createNewNote = async (token: string, note: NoteItem) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ type PromptItem = {
|
||||
content: string;
|
||||
data?: object | null;
|
||||
meta?: object | null;
|
||||
access_control?: null | object;
|
||||
access_grants?: object[];
|
||||
version_id?: string | null; // Active version
|
||||
commit_message?: string | null; // For history tracking
|
||||
is_production?: boolean; // Whether to set new version as production
|
||||
@@ -23,7 +23,7 @@ type PromptHistoryItem = {
|
||||
command: string;
|
||||
data: object;
|
||||
meta: object;
|
||||
access_control: object | null;
|
||||
access_grants: object[];
|
||||
};
|
||||
user_id: string;
|
||||
commit_message: string | null;
|
||||
@@ -42,7 +42,7 @@ type PromptDiff = {
|
||||
to_snapshot: object;
|
||||
content_diff: string[];
|
||||
name_changed: boolean;
|
||||
access_control_changed: boolean;
|
||||
access_grants_changed: boolean;
|
||||
};
|
||||
|
||||
export const createNewPrompt = async (token: string, prompt: PromptItem) => {
|
||||
@@ -611,4 +611,3 @@ export const getPromptDiff = async (
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -327,6 +327,33 @@ export const getUserById = async (token: string, userId: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getUserInfoById = async (token: string, userId: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/users/${userId}/info`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
error = err.detail;
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateUserStatus = async (token: string, formData: object) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user