From 1e66c83649bddaf39eeb1d11caba8f35f8b48587 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Fri, 27 Mar 2026 13:35:01 +0000
Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
studio/backend/core/inference/tools.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/studio/backend/core/inference/tools.py b/studio/backend/core/inference/tools.py
index 04fdae54cc..0752200ef5 100644
--- a/studio/backend/core/inference/tools.py
+++ b/studio/backend/core/inference/tools.py
@@ -147,18 +147,25 @@ def _fetch_page_text(url: str, max_chars: int = 4000, timeout: int = 10) -> str:
"""Fetch a URL and extract plain text content (best-effort)."""
import urllib.request
import urllib.error
+
try:
req = urllib.request.Request(url, headers = {"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout = timeout) as resp:
raw = resp.read(200_000).decode("utf-8", errors = "replace")
# Strip HTML tags (lightweight, no extra deps)
import re
- text = re.sub(r"", "", raw, flags = re.DOTALL | re.IGNORECASE)
- text = re.sub(r"", "", text, flags = re.DOTALL | re.IGNORECASE)
+
+ text = re.sub(
+ r"", "", raw, flags = re.DOTALL | re.IGNORECASE
+ )
+ text = re.sub(
+ r"", "", text, flags = re.DOTALL | re.IGNORECASE
+ )
text = re.sub(r"<[^>]+>", " ", text)
text = re.sub(r"\s+", " ", text).strip()
# Decode HTML entities
import html
+
text = html.unescape(text)
if len(text) > max_chars:
text = text[:max_chars] + "..."