refac
This commit is contained in:
1 parent
e355959e91
commit
2f37e853d1
1 file changed
+79
@@ -311,6 +311,33 @@ export const putOrchestratorPolicy = async (
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getOrchestratorPolicy = async (
|
||||||
|
token: string,
|
||||||
|
url: string,
|
||||||
|
key: string,
|
||||||
|
policyId: string,
|
||||||
|
authType: string = 'bearer'
|
||||||
|
): Promise<any> => {
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers/policy`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
url: url.replace(/\/$/, ''),
|
||||||
|
key,
|
||||||
|
auth_type: authType,
|
||||||
|
policy_id: policyId
|
||||||
|
})
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
const body = await res.json();
|
||||||
|
throw Object.assign(new Error(body.detail || 'Failed to read policy'), { status: res.status });
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
export const putOrchestratorLifecycle = async (
|
export const putOrchestratorLifecycle = async (
|
||||||
token: string,
|
token: string,
|
||||||
url: string,
|
url: string,
|
||||||
@@ -352,6 +379,33 @@ export const putOrchestratorLifecycle = async (
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getOrchestratorLifecycle = async (
|
||||||
|
token: string,
|
||||||
|
url: string,
|
||||||
|
key: string,
|
||||||
|
policyId: string,
|
||||||
|
authType: string = 'bearer'
|
||||||
|
): Promise<any> => {
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers/lifecycle`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
url: url.replace(/\/$/, ''),
|
||||||
|
key,
|
||||||
|
auth_type: authType,
|
||||||
|
policy_id: policyId
|
||||||
|
})
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
const body = await res.json();
|
||||||
|
throw Object.assign(new Error(body.detail || 'Failed to read lifecycle'), { status: res.status });
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
export const refreshOrchestratorTerminals = async (
|
export const refreshOrchestratorTerminals = async (
|
||||||
token: string,
|
token: string,
|
||||||
url: string,
|
url: string,
|
||||||
@@ -661,6 +715,31 @@ export const setModelsConfig = async (token: string, config: object) => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getSubagentsConfig = async (token: string) => {
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/subagents`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setSubagentsConfig = async (token: string, config: object) => {
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/subagents`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify(config)
|
||||||
|
});
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
export const setDefaultPromptSuggestions = async (token: string, promptSuggestions: string) => {
|
export const setDefaultPromptSuggestions = async (token: string, promptSuggestions: string) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user