Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assistant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Assistant Changelog

## v8.18.3

- **Fix**: A gif URL in a message no longer breaks the response. Gif URLs were matched and sent to the vision API, which returned a 400 `Error while downloading ...gif` (the API can't process animated gifs). Excluded gif from the image URL regex to match the attachment handler (which already skipped gif), and the `BadRequestError` handler now also strips images and retries on `Error while downloading` so any unfetchable image URL degrades gracefully instead of failing the whole reply.

## v8.18.2

- **Fix**: `[p]assistant backup` no longer wipes live conversations. It excluded conversation data by clearing `self.db.conversations` on the real in-memory store; with per-file persistence that also caused the on-disk files to be overwritten on next use. Now excludes conversations from the dump non-destructively via `model_dump_json(exclude=...)`.
Expand Down
10 changes: 8 additions & 2 deletions assistant/common/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ async def handle_message(
outputfile_pattern = r"--outputfile\s+([^\s]+)"
extract_pattern = r"--extract"
get_last_message_pattern = r"--last"
image_url_pattern = r"(https?:\/\/\S+\.(?:png|gif|webp|jpg|jpeg)(?:\?\S*)?)"
# NOTE: gif is intentionally excluded. The vision API cannot process (animated) gifs and
# responds with a 400 "Error while downloading" which breaks the response. This mirrors the
# attachment handling below which also excludes gif.
image_url_pattern = r"(https?:\/\/\S+\.(?:png|webp|jpg|jpeg)(?:\?\S*)?)"

# Extract the optional arguments and their values
outputfile_match = re.search(outputfile_pattern, question)
Expand Down Expand Up @@ -1054,7 +1057,10 @@ async def _get_chat_response(
continue
raise e
except openai.BadRequestError as e:
if "Invalid image" in str(e):
err_text = str(e)
# Some image URLs (e.g. gifs, or links the API can't fetch) cause a 400. Rather than
# failing the whole response, strip images from the payload and retry without them.
if "Invalid image" in err_text or "Error while downloading" in err_text:
Comment on lines 1059 to +1063
await purge_images(messages)
tries += 1
continue
Expand Down