Merge pull request #12606 from alpha-pet/feat-openapi-yaml-support
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11.x) (push) Waiting to run
Python CI / Format Backend (3.12.x) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run

Feat: openapi yaml support
This commit is contained in:
Tim Jaeryang Baek
2025-04-09 18:37:09 -07:00
committed by GitHub
4 changed files with 41 additions and 11 deletions

View File

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