Class: Assistant::TechnicalSupport::ResponseGroundingTurn
- Inherits:
-
Object
- Object
- Assistant::TechnicalSupport::ResponseGroundingTurn
- Defined in:
- app/services/assistant/technical_support/response_grounding_turn.rb
Overview
Resolves the persisted user and final assistant messages that bound one
Technical Support response, including recovery paths without a supplied ID.
Instance Method Summary collapse
-
#assistant_message ⇒ AssistantMessage?
Returns the exact or latest nonblank assistant answer after the user.
-
#initialize(conversation:, supplied_user_message_id: nil, assistant_message_id: nil) ⇒ ResponseGroundingTurn
constructor
Builds a resolver for one persisted conversation turn.
-
#user_message_id ⇒ Integer?
Returns the persisted triggering user-message ID.
Constructor Details
#initialize(conversation:, supplied_user_message_id: nil, assistant_message_id: nil) ⇒ ResponseGroundingTurn
Builds a resolver for one persisted conversation turn.
13 14 15 16 17 |
# File 'app/services/assistant/technical_support/response_grounding_turn.rb', line 13 def initialize(conversation:, supplied_user_message_id: nil, assistant_message_id: nil) @conversation = conversation @supplied_user_message_id = @assistant_message_id = end |
Instance Method Details
#assistant_message ⇒ AssistantMessage?
Returns the exact or latest nonblank assistant answer after the user.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/assistant/technical_support/response_grounding_turn.rb', line 31 def return unless scope = conversation. .where(role: 'assistant') .where('id > ?', ) .where.not(content: [nil, '']) scope = scope.where(id: ...) if return scope.find_by(id: ) if scope.order(:id).last end |
#user_message_id ⇒ Integer?
Returns the persisted triggering user-message ID.
22 23 24 25 26 |
# File 'app/services/assistant/technical_support/response_grounding_turn.rb', line 22 def return @user_message_id if defined?(@user_message_id) @user_message_id = || end |