Process image_path: convert to base64 if local path, keep unchanged if HTTP link
(image_path)
| 17 | return base64.b64encode(image_data).decode("utf-8") |
| 18 | |
| 19 | |
| 20 | def process_image_path(image_path) -> Any | str: |
| 21 | """Process image_path: convert to base64 if local path, keep unchanged if HTTP link""" |
| 22 | if isinstance(image_path, list): |
| 23 | return [process_image_path(path) for path in image_path] |
| 24 | if not image_path: |
| 25 | return image_path |
| 26 | |
| 27 | if image_path.startswith(("http://", "https://")): |
| 28 | return image_path |
| 29 | |
| 30 | if os.path.exists(image_path): |
| 31 | return image_to_base64(image_path) |
| 32 | else: |
| 33 | logger.warning(f"Image path not found: {image_path}") |
| 34 | return image_path |
no test coverage detected