From 27e8c6fce4d3b543bc1749b63c8891ece9388304 Mon Sep 17 00:00:00 2001 From: Thomas Rehn <271119+tremlin@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:11:37 +0200 Subject: [PATCH] feat: add support for OpenAPI spec in YAML format --- backend/open_webui/utils/tools.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 734c23e1b..3d7f627b5 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -4,6 +4,7 @@ import re import inspect import aiohttp import asyncio +import yaml from typing import Any, Awaitable, Callable, get_type_hints, Dict, List, Union, Optional from functools import update_wrapper, partial @@ -398,7 +399,13 @@ async def get_tool_server_data(token: str, url: str) -> Dict[str, Any]: if response.status != 200: error_body = await response.json() raise Exception(error_body) - res = await response.json() + + # Check if URL ends with .yaml or .yml to determine format + if url.lower().endswith((".yaml", ".yml")): + text_content = await response.text() + res = yaml.safe_load(text_content) + else: + res = await response.json() except Exception as err: print("Error:", err) if isinstance(err, dict) and "detail" in err: