Accept optional user_images on regenerate and apply them when resolving the model turn.

This commit is contained in:
CREDO23 2026-04-27 19:25:20 +02:00
parent 9f5b6205e1
commit 056870464a
2 changed files with 16 additions and 0 deletions

View file

@ -1456,6 +1456,9 @@ async def regenerate_response(
user_query_to_use
)
if request.user_images is not None:
regenerate_image_urls = [p.as_data_url() for p in request.user_images]
if user_query_to_use is None:
raise HTTPException(
status_code=400,

View file

@ -238,6 +238,9 @@ class RegenerateRequest(BaseModel):
2. Reload: Leave user_query empty to regenerate the last AI response with the same query
Both operations rewind the LangGraph checkpointer to the appropriate state.
For edit, optional user_images (when not None) replaces image URLs resolved from
checkpoint/DB so the client can send the full user turn (text and/or images).
"""
search_space_id: int
@ -250,6 +253,16 @@ class RegenerateRequest(BaseModel):
filesystem_mode: Literal["cloud", "desktop_local_folder"] = "cloud"
client_platform: Literal["web", "desktop"] = "web"
local_filesystem_mounts: list[LocalFilesystemMountPayload] | None = None
user_images: list[NewChatUserImagePart] | None = Field(
default=None,
description="If set, use these images for the regenerated turn (edit); overrides checkpoint/DB",
)
@model_validator(mode="after")
def _validate_regenerate_user_images(self) -> Self:
if self.user_images is not None and len(self.user_images) > MAX_NEW_CHAT_IMAGES:
raise ValueError(f"At most {MAX_NEW_CHAT_IMAGES} images allowed")
return self
# =============================================================================