Allow the fetch_webpage tool to return links

This commit is contained in:
oobabooga 2026-03-12 17:08:30 -07:00
parent 09d5e049d6
commit 5c02b7f603
3 changed files with 5 additions and 4 deletions

View file

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

View file

@ -92,7 +92,7 @@ def create_ui():
gr.HTML("<div class='sidebar-vertical-separator'></div>")
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']])

View file

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