From 5c02b7f60369be70b52ccf0432a69380b7f5ab4a Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 12 Mar 2026 17:08:30 -0700 Subject: [PATCH] Allow the fetch_webpage tool to return links --- modules/tool_use.py | 3 ++- modules/ui_chat.py | 2 +- modules/web_search.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/tool_use.py b/modules/tool_use.py index cb1e140d..e464d5d4 100644 --- a/modules/tool_use.py +++ b/modules/tool_use.py @@ -4,13 +4,14 @@ import random from modules import shared from modules.logging_colors import logger +from modules.utils import natural_keys def get_available_tools(): """Return sorted list of tool script names from user_data/tools/*.py.""" tools_dir = shared.user_data_dir / 'tools' tools_dir.mkdir(parents=True, exist_ok=True) - return sorted(p.stem for p in tools_dir.glob('*.py')) + return sorted((p.stem for p in tools_dir.glob('*.py')), key=natural_keys) def load_tools(selected_names): diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 8112d956..039b9af6 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -92,7 +92,7 @@ def create_ui(): gr.HTML("
") from modules.tool_use import get_available_tools - shared.gradio['selected_tools'] = gr.CheckboxGroup(choices=get_available_tools(), value=[], label='Tools', info='Functions the model can call during generation.', elem_id='tools-group') + shared.gradio['selected_tools'] = gr.CheckboxGroup(choices=get_available_tools(), value=shared.settings.get('selected_tools', []), label='Tools', info='Functions the model can call during generation.', elem_id='tools-group') shared.gradio['tools_refresh'] = gr.Button('Refresh list', elem_id='tools-refresh-btn', visible=False) shared.gradio['tools_refresh'].click(fn=lambda: gr.update(choices=get_available_tools()), inputs=[], outputs=[shared.gradio['selected_tools']]) diff --git a/modules/web_search.py b/modules/web_search.py index 597af4b2..b14cd042 100644 --- a/modules/web_search.py +++ b/modules/web_search.py @@ -18,7 +18,7 @@ def get_current_timestamp(): return datetime.now().strftime('%b %d, %Y %H:%M') -def download_web_page(url, timeout=10): +def download_web_page(url, timeout=10, include_links=False): """ Download a web page and convert its HTML content to structured Markdown text. """ @@ -35,7 +35,7 @@ def download_web_page(url, timeout=10): h = html2text.HTML2Text() h.body_width = 0 h.ignore_images = True - h.ignore_links = True + h.ignore_links = not include_links # Convert the HTML to Markdown markdown_text = h.handle(response.text)