This commit is contained in:
Timothy Jaeryang Baek
2025-04-05 04:05:52 -06:00
parent 0f310b3509
commit 0c0505e1cd
12 changed files with 613 additions and 368 deletions

View File

@@ -115,6 +115,93 @@ export const setDirectConnectionsConfig = async (token: string, config: object)
return res;
};
export const getToolServerConnections = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/tool_servers`, {
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 setToolServerConnections = async (token: string, connections: object) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/tool_servers`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
...connections
})
})
.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 verifyToolServerConnection = async (token: string, connection: object) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/tool_servers/verify`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
...connection
})
})
.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 getCodeExecutionConfig = async (token: string) => {
let error = null;

View File

@@ -306,11 +306,11 @@ export const getToolServersData = async (i18n, servers: object[]) => {
.map(async (server) => {
const data = await getToolServerData(
server?.key,
server?.url + (server?.path ?? '/openapi.json')
server?.url + '/' + (server?.path ?? 'openapi.json')
).catch((err) => {
toast.error(
i18n.t(`Failed to connect to {{URL}} OpenAPI tool server`, {
URL: server?.url + (server?.path ?? '/openapi.json')
URL: server?.url + '/' + (server?.path ?? 'openapi.json')
})
);
return null;