Skip to content
Open
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
14 changes: 8 additions & 6 deletions lib/ruby_llm/active_record/chat_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def resolve_model_from_strings # rubocop:disable Metrics/PerceivedComplexity
@provider_string = nil
end

def populate_messages
@chat.reset_messages!
messages_association.each do |msg|
@chat.add_message(msg.to_llm)
end
end

public

def to_llm
Expand All @@ -81,12 +88,7 @@ def to_llm
model: model_record.model_id,
provider: model_record.provider.to_sym
)
@chat.reset_messages!

messages_association.each do |msg|
@chat.add_message(msg.to_llm)
end

populate_messages
setup_persistence_callbacks
end

Expand Down