forked from erp-dev/erp
feat: correct first
This commit is contained in:
@@ -3,7 +3,7 @@ import re
|
||||
from mission.models import MissionPayloadProcessorEnum
|
||||
|
||||
|
||||
STRUCTURED_DESCRIPTION_IMAGE_PREFIX = "款式图:"
|
||||
STRUCTURED_DESCRIPTION_IMAGE_PREFIXES = ("款式图:", "款式图:")
|
||||
|
||||
|
||||
def _extract_labeled_image_url(lines: list[str]) -> tuple[list[str], str]:
|
||||
@@ -11,12 +11,18 @@ def _extract_labeled_image_url(lines: list[str]) -> tuple[list[str], str]:
|
||||
image_url = ""
|
||||
for line in lines:
|
||||
stripped_line = line.strip()
|
||||
if stripped_line.startswith(STRUCTURED_DESCRIPTION_IMAGE_PREFIX):
|
||||
candidate = stripped_line.removeprefix(STRUCTURED_DESCRIPTION_IMAGE_PREFIX).strip()
|
||||
if candidate:
|
||||
image_url = candidate
|
||||
matched_prefix = None
|
||||
for prefix in STRUCTURED_DESCRIPTION_IMAGE_PREFIXES:
|
||||
if stripped_line.startswith(prefix):
|
||||
matched_prefix = prefix
|
||||
break
|
||||
if matched_prefix is None:
|
||||
kept_lines.append(line)
|
||||
continue
|
||||
kept_lines.append(line)
|
||||
|
||||
candidate = stripped_line.removeprefix(matched_prefix).strip()
|
||||
if candidate:
|
||||
image_url = candidate
|
||||
return kept_lines, image_url
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user