mirror of
https://github.com/open-webui/open-webui.git
synced 2026-01-02 14:45:18 +00:00
feat: Dynamically load yaml to speed up page loading (#20204)
This commit is contained in:
parent
267cc14d2d
commit
cc602abcb2
1 changed files with 2 additions and 5 deletions
|
|
@ -1,10 +1,7 @@
|
||||||
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||||
import { convertOpenApiToToolPayload } from '$lib/utils';
|
import { convertOpenApiToToolPayload } from '$lib/utils';
|
||||||
import { getOpenAIModelsDirect } from './openai';
|
import { getOpenAIModelsDirect } from './openai';
|
||||||
|
|
||||||
import { parse } from 'yaml';
|
|
||||||
import { toast } from 'svelte-sonner';
|
|
||||||
|
|
||||||
export const getModels = async (
|
export const getModels = async (
|
||||||
token: string = '',
|
token: string = '',
|
||||||
connections: object | null = null,
|
connections: object | null = null,
|
||||||
|
|
@ -316,7 +313,7 @@ export const getToolServerData = async (token: string, url: string) => {
|
||||||
// Check if URL ends with .yaml or .yml to determine format
|
// Check if URL ends with .yaml or .yml to determine format
|
||||||
if (url.toLowerCase().endsWith('.yaml') || url.toLowerCase().endsWith('.yml')) {
|
if (url.toLowerCase().endsWith('.yaml') || url.toLowerCase().endsWith('.yml')) {
|
||||||
if (!res.ok) throw await res.text();
|
if (!res.ok) throw await res.text();
|
||||||
const text = await res.text();
|
const [text, { parse }] = await Promise.all([res.text(), import('yaml')]);
|
||||||
return parse(text);
|
return parse(text);
|
||||||
} else {
|
} else {
|
||||||
if (!res.ok) throw await res.json();
|
if (!res.ok) throw await res.json();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue