Skip to content

Commit 775498f

Browse files
committed
fix(Message): Improve file attachment handling by rejecting empty strings
1 parent 1b2c7e9 commit 775498f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/ruby_llm/active_record/acts_as.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ def create_user_message(content, with: nil)
150150
)
151151

152152
if with.present?
153-
files = Array(with).reject(&:blank?)
154-
155-
if files.any? && files.first.is_a?(ActionDispatch::Http::UploadedFile)
156-
message_record.attachments.attach(files)
157-
else
158-
attach_files(message_record, process_attachments(with))
153+
files = Array(with).reject(&:empty?)
154+
155+
if files.any?
156+
if files.first.is_a?(ActionDispatch::Http::UploadedFile)
157+
message_record.attachments.attach(files)
158+
else
159+
attach_files(message_record, process_attachments(with))
160+
end
159161
end
160162
end
161163

0 commit comments

Comments
 (0)