mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: OpenAPI YAML support for frontend toolserver
This commit is contained in:
@@ -2,6 +2,7 @@ import { WEBUI_API_BASE_URL, 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 (
|
||||
@@ -271,8 +272,15 @@ export const getToolServerData = async (token: string, url: string) => {
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
// 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();
|
||||
return parse(text);
|
||||
} else {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
Reference in New Issue
Block a user