Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit cbc57dd

Browse files
committed
fix, in chat we need enough context so we know exactly what uploads a user uploaded.
1 parent b219915 commit cbc57dd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/completions/prompt_messages_builder.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ def self.messages_from_chat(
7171
thread_title = m.thread&.title if include_thread_titles && m.thread_id
7272
mapped_message = "(#{thread_title})\n#{m.message}" if thread_title
7373

74+
if m.uploads.present?
75+
mapped_message =
76+
"#{mapped_message} -- uploaded(#{m.uploads.map(&:short_url).join(", ")})"
77+
end
78+
7479
builder.push(
7580
type: :user,
7681
content: mapped_message,

spec/lib/completions/prompt_messages_builder_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@
240240
)
241241

242242
# Find the message with upload
243-
message = context.find { |m| m[:content] == ["Check this image", { upload_id: upload.id }] }
243+
message =
244+
context.find do |m|
245+
m[:content] ==
246+
["Check this image -- uploaded(#{upload.short_url})", { upload_id: upload.id }]
247+
end
244248
expect(message).to be_present
245249
end
246250

@@ -261,7 +265,8 @@
261265
)
262266

263267
# Find the message with upload
264-
message = context.find { |m| m[:content] == "Check this image" }
268+
message =
269+
context.find { |m| m[:content] == "Check this image -- uploaded(#{upload.short_url})" }
265270
expect(message).to be_present
266271
expect(message[:upload_ids]).to be_nil
267272
end

0 commit comments

Comments
 (0)