feat: direct api settings backend

This commit is contained in:
Timothy Jaeryang Baek
2025-02-11 22:29:45 -08:00
parent 24cbc469cc
commit 3891161173
5 changed files with 147 additions and 10 deletions
+57
View File
@@ -58,6 +58,63 @@ export const exportConfig = async (token: string) => {
return res;
};
export const getDirectApiConfig = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/direct_api`, {
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.log(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const setDirectApiConfig = async (token: string, config: object) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/direct_api`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
...config
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const getCodeInterpreterConfig = async (token: string) => {
let error = null;