context shifting now works with images, images are now inserted inline instead of as placeholders

This commit is contained in:
Concedo
2026-06-29 23:40:43 +08:00
parent 16ef2badf6
commit 1365d11990
3 changed files with 265 additions and 22 deletions
+2 -7
View File
@@ -3772,22 +3772,17 @@ def format_jinja(messages_orig, tools, chat_template_kwargs=None):
if isinstance(m.get("content"), list):
normalized = []
turn_text = ""
media_text = ""
for item in m["content"]:
if item.get("type")=="text":
turn_text += item.get("text","")
for item in m["content"]:
if item.get("type")=="text":
pass
elif item.get("type")=="image_url" or item.get("type")=="image":
media_text += f"\n(Attached Image {mediacount})\n"
turn_text += f"\n(Attached Image {mediacount})\n"
mediacount += 1
elif item.get("type")=="input_audio":
media_text += f"\n(Attached Audio {mediacount})\n"
turn_text += f"\n(Attached Audio {mediacount})\n"
mediacount += 1
else:
normalized.append(item)
turn_text = media_text + turn_text
if turn_text:
normalized.append({"type": "text","text": turn_text})
m["content"] = normalized