Skip to content

Commit

Permalink
add image-preview
Browse files Browse the repository at this point in the history
Signed-off-by: root <root@localhost.localdomain>
  • Loading branch information
root committed Nov 11, 2024
1 parent 90afb0c commit abe809b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/core/tools/utils/web_reader_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from core.helper import ssrf_proxy
from core.rag.extractor import extract_processor
from core.rag.extractor.extract_processor import ExtractProcessor
import logging

FULL_TEMPLATE = """
TITLE: {title}
Expand Down Expand Up @@ -359,12 +360,15 @@ def content_digest(element):


def get_image_upload_file_ids(content):
pattern = r"!\[image\]\((.*?file-preview)\)"
pattern = r"!\[image\]\((http?://.*?(file-preview|image-preview))\)"
matches = re.findall(pattern, content)
content_pattern = r"files/([^/]+)/file-preview"
image_upload_file_ids = []
for match in matches:
content_match = re.search(content_pattern, match)
if match[1] == 'file-preview':
content_pattern = r"files/([^/]+)/file-preview"
else:
content_pattern = r"files/([^/]+)/image-preview"
content_match = re.search(content_pattern, match[0])
if content_match:
image_upload_file_id = content_match.group(1)
image_upload_file_ids.append(image_upload_file_id)
Expand Down

0 comments on commit abe809b

Please sign in to comment.