Class: Assistant::TechnicalSupport::CaseReplayConversation

Inherits:
Object
  • Object
show all
Defined in:
app/services/assistant/technical_support/case_replay_conversation.rb

Overview

Runs the observable episode through Sunny and returns the persisted tool trace
plus separately selected replay and hidden-outcome facts for grading.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chat_runner:, account:, support_case:, episode:, events:, tool_services:) ⇒ CaseReplayConversation

Returns a new instance of CaseReplayConversation.



36
37
38
39
40
41
42
43
# File 'app/services/assistant/technical_support/case_replay_conversation.rb', line 36

def initialize(chat_runner:, account:, support_case:, episode:, events:, tool_services:)
  @chat_runner = chat_runner
  @account = 
  @support_case = support_case
  @episode = episode
  @events = Array(events)
  @tool_services = tool_services
end

Class Method Details

.call(**attributes) ⇒ Result

Returns replay conversation outcome.

Parameters:

  • attributes (Hash)

    constructor keywords forwarded to #initialize

Options Hash (**attributes):

  • chat_runner (Proc)

    runs the replay conversation

  • account (Account)

    replaying account

  • support_case (SupportCase)

    case being replayed

  • episode (Object)

    extracted replay episode

  • events (Array)

    observable case events

  • tool_services (Hash)

    tool services available to the replay

Returns:

  • (Result)

    replay conversation outcome



31
32
33
# File 'app/services/assistant/technical_support/case_replay_conversation.rb', line 31

def call(**attributes)
  new(**attributes).call
end

Instance Method Details

#callObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/services/assistant/technical_support/case_replay_conversation.rb', line 45

def call
  run = chat_runner.call(
    account:,
    support_case:,
    prompts: prompts,
    tool_services:
  )

  Result.new(
    conversation_id: run.conversation_id,
    answer: run.answer.to_s,
    tool_trace: normalize_tool_trace(run.tool_trace),
    system_prompt_trace: normalize_system_prompt_trace(run.system_prompt_trace),
    replay_facts: replay_events.map { |event| event_fact(event) },
    outcome_facts: outcome_events.map { |event| event_fact(event) }
  )
end