Make image writing to and reading from LLMContext more robust; let's allow storing in context image types other than JPEG, meaning not lossily and unnecessarily re-encoding non-JPEG images as JPEG.

This commit is contained in:
Paul Kompfner
2025-12-15 10:34:33 -05:00
parent e604e9b490
commit 54926f390d
7 changed files with 46 additions and 43 deletions

View File

@@ -833,11 +833,11 @@ class LLMAssistantAggregator(LLMContextAggregator):
async def _handle_assistant_image_frame(self, frame: AssistantImageRawFrame):
logger.debug(f"{self} Appending AssistantImageRawFrame to LLM context (size: {frame.size})")
if frame.original_jpeg:
if frame.original_data and frame.original_mime_type:
await self._context.add_image_frame_message(
format="JPEG",
format=frame.original_mime_type,
size=frame.size, # Technically doesn't matter, since already encoded
image=frame.original_jpeg,
image=frame.original_data,
role="assistant",
)
else: