Convert a local image file to a base64-encoded data URL.
(image_path)
| 189 | # ============================================================ |
| 190 | |
| 191 | def local_image_to_data_url(image_path): |
| 192 | """Convert a local image file to a base64-encoded data URL.""" |
| 193 | mime_type, _ = guess_type(image_path) |
| 194 | if mime_type is None: |
| 195 | mime_type = "application/octet-stream" |
| 196 | with open(image_path, "rb") as f: |
| 197 | encoded = base64.b64encode(f.read()).decode("utf-8") |
| 198 | return f"data:{mime_type};base64,{encoded}" |
| 199 | |
| 200 | |
| 201 | def build_system_prompt(prompt, testpoint, test_desc, lang): |
no outgoing calls
no test coverage detected