Update api/utils.py
Browse files- api/utils.py +3 -4
api/utils.py
CHANGED
|
@@ -4,9 +4,8 @@ import uuid
|
|
| 4 |
import asyncio
|
| 5 |
import random
|
| 6 |
import string
|
| 7 |
-
from typing import Any, Dict, Optional
|
| 8 |
import re
|
| 9 |
-
|
| 10 |
import httpx
|
| 11 |
from fastapi import HTTPException
|
| 12 |
from api.config import (
|
|
@@ -23,6 +22,7 @@ from api.models import ChatRequest
|
|
| 23 |
from api.logger import setup_logger
|
| 24 |
from api.validate import getHid # Import the asynchronous getHid function
|
| 25 |
|
|
|
|
| 26 |
logger = setup_logger(__name__)
|
| 27 |
|
| 28 |
# Define the blocked message
|
|
@@ -62,7 +62,6 @@ def message_to_dict(message, model_prefix: Optional[str] = None):
|
|
| 62 |
"imageBase64": image_base64,
|
| 63 |
"fileText": "",
|
| 64 |
"title": "snapshot",
|
| 65 |
-
# Added imagesData field here
|
| 66 |
"imagesData": [
|
| 67 |
{
|
| 68 |
"filePath": f"MultipleFiles/{uuid.uuid4().hex}.jpg",
|
|
@@ -87,7 +86,7 @@ def remove_message_between_special_tags(content: str) -> str:
|
|
| 87 |
content = re.sub(r'\$~~~\$.*?\$~~~\$', '', content, flags=re.DOTALL)
|
| 88 |
return content
|
| 89 |
|
| 90 |
-
# Function to remove search results but keep the links
|
| 91 |
def remove_search_results(content: str) -> str:
|
| 92 |
"""Remove search result sections, keeping the URLs intact."""
|
| 93 |
# Regex to match search result JSON (structured with `title`, `snippet`, `link`)
|
|
|
|
| 4 |
import asyncio
|
| 5 |
import random
|
| 6 |
import string
|
|
|
|
| 7 |
import re
|
| 8 |
+
from typing import Any, Dict, Optional
|
| 9 |
import httpx
|
| 10 |
from fastapi import HTTPException
|
| 11 |
from api.config import (
|
|
|
|
| 22 |
from api.logger import setup_logger
|
| 23 |
from api.validate import getHid # Import the asynchronous getHid function
|
| 24 |
|
| 25 |
+
# Setup logger
|
| 26 |
logger = setup_logger(__name__)
|
| 27 |
|
| 28 |
# Define the blocked message
|
|
|
|
| 62 |
"imageBase64": image_base64,
|
| 63 |
"fileText": "",
|
| 64 |
"title": "snapshot",
|
|
|
|
| 65 |
"imagesData": [
|
| 66 |
{
|
| 67 |
"filePath": f"MultipleFiles/{uuid.uuid4().hex}.jpg",
|
|
|
|
| 86 |
content = re.sub(r'\$~~~\$.*?\$~~~\$', '', content, flags=re.DOTALL)
|
| 87 |
return content
|
| 88 |
|
| 89 |
+
# Function to remove search results but keep the links intact
|
| 90 |
def remove_search_results(content: str) -> str:
|
| 91 |
"""Remove search result sections, keeping the URLs intact."""
|
| 92 |
# Regex to match search result JSON (structured with `title`, `snippet`, `link`)
|