Update api/utils.py
Browse files3 unmodified lines45678910111210 unmodified lines23242526272833 unmodified lines6263646566676818 unmodified lines878889909192933 unmodified linesimport asyncioimport randomimport stringfrom typing import Any, Dict, Optionalimport reimport httpxfrom fastapi import HTTPExceptionfrom api.config import (10 unmodified linesfrom api.logger import setup_loggerfrom api.validate import getHid # Import the asynchronous getHid functionlogger = setup_logger(__name__)# Define the blocked message33 unmodified lines"imageBase64": image_base64,"fileText": "","title": "snapshot",# Added imagesData field here"imagesData": [{"filePath": f"MultipleFiles/{uuid.uuid4().hex}.jpg",18 unmodified linescontent = re.sub(r'\$~~~\$.*?\$~~~\$', '', content, flags=re.DOTALL)return content# Function to remove search results but keep the linksdef remove_search_results(content: str) -> str:"""Remove search result sections, keeping the URLs intact."""# Regex to match search result JSON (structured with `title`, `snippet`, `link`)3 unmodified lines456789101110 unmodified lines2223242526272833 unmodified lines62636465666718 unmodified lines868788899091923 unmodified linesimport asyncioimport randomimport stringimport refrom typing import Any, Dict, Optionalimport httpxfrom fastapi import HTTPExceptionfrom api.config import (10 unmodified linesfrom api.logger import setup_loggerfrom api.validate import getHid # Import the asynchronous getHid function# Setup loggerlogger = setup_logger(__name__)# Define the blocked message33 unmodified lines"imageBase64": image_base64,"fileText": "","title": "snapshot","imagesData": [{"filePath": f"MultipleFiles/{uuid.uuid4().hex}.jpg",18 unmodified linescontent = re.sub(r'\$~~~\$.*?\$~~~\$', '', content, flags=re.DOTALL)return content# Function to remove search results but keep the links intactdef remove_search_results(content: str) -> str:"""Remove search result sections, keeping the URLs intact."""# Regex to match search result JSON (structured with `title`, `snippet`, `link`)
api/utils.py+3-4