Class: Collavre::AiAgent::MessageBuilder
- Inherits:
-
Object
- Object
- Collavre::AiAgent::MessageBuilder
- Defined in:
- app/services/collavre/ai_agent/message_builder.rb
Overview
Builds the message array for AI agent conversations.
Extracts creative context, chat history, and the trigger comment into the format expected by AiClient.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(agent:, context:, original_comment: nil) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
Constructor Details
#initialize(agent:, context:, original_comment: nil) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
10 11 12 13 14 |
# File 'app/services/collavre/ai_agent/message_builder.rb', line 10 def initialize(agent:, context:, original_comment: nil) @agent = agent @context = context @original_comment = original_comment end |
Instance Method Details
#build ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/collavre/ai_agent/message_builder.rb', line 16 def build = [] @injected_creative_ids = Set.new append_creative_context() append_context_creatives() append_referenced_creative_contexts() history_count = append_chat_history() () { messages: , first_message: history_count == 0, context_changed: history_count > 0 && context_changed_since_last_reply? } end |