feat: Dynamically load yaml to speed up page loading (#20204)

This commit is contained in:
Shirasawa 2025-12-29 04:44:22 +08:00 committed by GitHub
parent 267cc14d2d
commit cc602abcb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();