mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
4cea3a57be
commit
30d1dc2c60
2 changed files with 24 additions and 2 deletions
|
|
@ -354,8 +354,19 @@ export const getToolServersData = async (servers: object[]) => {
|
|||
.filter((server) => server?.config?.enable)
|
||||
.map(async (server) => {
|
||||
let error = null;
|
||||
|
||||
let toolServerToken = null;
|
||||
const auth_type = server?.auth_type ?? 'bearer';
|
||||
if (auth_type === 'bearer') {
|
||||
toolServerToken = server?.key;
|
||||
} else if (auth_type === 'none') {
|
||||
// No authentication
|
||||
} else if (auth_type === 'session') {
|
||||
toolServerToken = localStorage.token;
|
||||
}
|
||||
|
||||
const data = await getToolServerData(
|
||||
(server?.auth_type ?? 'bearer') === 'bearer' ? server?.key : localStorage.token,
|
||||
toolServerToken,
|
||||
(server?.path ?? '').includes('://')
|
||||
? server?.path
|
||||
: `${server?.url}${(server?.path ?? '').startsWith('/') ? '' : '/'}${server?.path}`
|
||||
|
|
|
|||
|
|
@ -222,8 +222,19 @@
|
|||
|
||||
if (toolServer) {
|
||||
console.log(toolServer);
|
||||
|
||||
let toolServerToken = null;
|
||||
const auth_type = toolServer?.auth_type ?? 'bearer';
|
||||
if (auth_type === 'bearer') {
|
||||
toolServerToken = toolServer?.key;
|
||||
} else if (auth_type === 'none') {
|
||||
// No authentication
|
||||
} else if (auth_type === 'session') {
|
||||
toolServerToken = localStorage.token;
|
||||
}
|
||||
|
||||
const res = await executeToolServer(
|
||||
(toolServer?.auth_type ?? 'bearer') === 'bearer' ? toolServer?.key : localStorage.token,
|
||||
toolServerToken,
|
||||
toolServer.url,
|
||||
data?.name,
|
||||
data?.params,
|
||||
|
|
|
|||
Loading…
Reference in a new issue