From b606e13da3753027ead0e92e35e1399b60c96c8e Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 10 Aug 2026 19:44:56 -0600 Subject: [PATCH] refac --- backend/open_webui/utils/tools.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 7e44d28820..5a3852b89d 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -848,17 +848,26 @@ def parse_docstring(docstring): return {} # Regex to match `:param name: description` format - param_pattern = re.compile(r':param (\w+):\s*(.+)') + param_pattern = re.compile(r':param (\w+):\s*(.*)') param_descriptions = {} + current_param = None for line in docstring.splitlines(): - match = param_pattern.match(line.strip()) - if not match: + line = line.strip() + match = param_pattern.match(line) + if match: + param_name, param_description = match.groups() + current_param = None if param_name.startswith('__') else param_name + if current_param: + param_descriptions[current_param] = param_description continue - param_name, param_description = match.groups() - if param_name.startswith('__'): + + if line.startswith(':'): + current_param = None continue - param_descriptions[param_name] = param_description + + if current_param and line: + param_descriptions[current_param] = '\n'.join(filter(None, [param_descriptions[current_param], line])) return param_descriptions