Skip to content
10 changes: 8 additions & 2 deletions lib/ruby_llm/active_record/acts_as.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,15 @@ def extract_tool_call_id
end

def extract_content
return content unless respond_to?(:attachments) && attachments.attached?
text_content = if content.respond_to?(:to_plain_text)
content.to_plain_text
else
content.to_s
end

RubyLLM::Content.new(content).tap do |content_obj|
return text_content unless respond_to?(:attachments) && attachments.attached?

RubyLLM::Content.new(text_content).tap do |content_obj|
@_tempfiles = []

attachments.each do |attachment|
Expand Down