Class: Assistant::TechnicalSupport::ResponseGroundingAssessmentBuilder

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/assistant/technical_support/response_grounding_assessment_builder.rb

Overview

Combines normalized model output with deterministic citation and evidence
checks into the bounded JSONB audit stored on an assistant message.

Constant Summary collapse

POLICY =
{
  version: 4,
  mode: 'shadow',
  service: 'technical_support',
  max_answer_chars: ResponseGroundingAnswerSegments::MAX_ANSWER_CHARS,
  max_urls: 30,
  max_claims: ResponseGroundingAnswerSegments::MAX_SEGMENTS
}.freeze
CONVERSATION_TYPES =
%w[technical_support technical_support_replay].freeze
MAX_CLAIMS =
POLICY.fetch(:max_claims)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Class Method Details

.applies_to?(conversation) ⇒ Boolean

Reports whether a conversation explicitly belongs to this funnel.

Parameters:

Returns:

  • (Boolean)

    true for the Technical Support profile and holdout replays



52
53
54
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 52

def applies_to?(conversation)
  CONVERSATION_TYPES.include?(conversation&.conversation_type.to_s)
end

.max_answer_charsInteger

Returns the answer-size ceiling sent to the grader.

Returns:

  • (Integer)

    maximum answer characters



59
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 59

def max_answer_chars = POLICY.fetch(:max_answer_chars)

.modeString

Returns the current observation mode.

Returns:

  • (String)

    shadow-mode identifier



41
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 41

def mode = POLICY.fetch(:mode)

.serviceString

Returns the Sunny funnel this policy audits.

Returns:

  • (String)

    persisted funnel identifier



46
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 46

def service = POLICY.fetch(:service)

.versionInteger

Returns the persisted assessment schema version.

Returns:

  • (Integer)

    assessment version



36
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 36

def version = POLICY.fetch(:version)

Instance Method Details

#callHash

Builds the complete persisted assessment payload.

Returns:

  • (Hash)

    string-keyed JSONB assessment



65
66
67
68
69
70
71
72
73
74
75
# File 'app/services/assistant/technical_support/response_grounding_assessment_builder.rb', line 65

def call
  decision = build_decision
  ResponseGroundingAssessmentPayload.call(
    answer: answer_text,
    model:,
    evidence:,
    decision:,
    user_message_id:,
    assistant_message:
  ).merge(normalized_analysis)
end