Skip to content

Commit 8c3fd8d

Browse files
committed
Feat: Add support to Action Text enabled content
Improved the `extract_content` method to correctly process Action Text. When `message` model uses `has_rich_text :content`, `message.content` becomes `ActionText:RichText`, returning HTML tags unintentionally. Adjustments ensure only the desired content is extracted.
1 parent 5fc937c commit 8c3fd8d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/ruby_llm/active_record/acts_as.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,15 @@ def extract_tool_call_id
353353
end
354354

355355
def extract_content
356-
return content unless respond_to?(:attachments) && attachments.attached?
356+
text_content = if content.respond_to?(:to_plain_text)
357+
content.to_plain_text
358+
else
359+
content.to_s
360+
end
357361

358-
RubyLLM::Content.new(content).tap do |content_obj|
362+
return text_content unless respond_to?(:attachments) && attachments.attached?
363+
364+
RubyLLM::Content.new(text_content).tap do |content_obj|
359365
@_tempfiles = []
360366

361367
attachments.each do |attachment|

0 commit comments

Comments
 (0)