From cc602abcb285e45cba509ec8e697131bcd044c7c Mon Sep 17 00:00:00 2001 From: Shirasawa <764798966@qq.com> Date: Mon, 29 Dec 2025 04:44:22 +0800 Subject: [PATCH] feat: Dynamically load yaml to speed up page loading (#20204) --- src/lib/apis/index.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index e865e9ba0e..f37f525793 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -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 { getOpenAIModelsDirect } from './openai'; -import { parse } from 'yaml'; -import { toast } from 'svelte-sonner'; - export const getModels = async ( token: string = '', 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 if (url.toLowerCase().endsWith('.yaml') || url.toLowerCase().endsWith('.yml')) { 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); } else { if (!res.ok) throw await res.json();