diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 8c3484c69..55ca97f38 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import base64 import hashlib import json import locale @@ -652,9 +653,11 @@ class Coder: image_messages = [] for fname, content in self.get_abs_fnames_content(): if is_image_file(fname): + with open(fname, "rb") as image_file: + encoded_string = base64.b64encode(image_file.read()).decode('utf-8') mime_type, _ = mimetypes.guess_type(fname) if mime_type and mime_type.startswith("image/"): - image_url = f"data:{mime_type};base64,{content}" + image_url = f"data:{mime_type};base64,{encoded_string}" rel_fname = self.get_rel_fname(fname) image_messages += [ {"type": "text", "text": f"Image file: {rel_fname}"},