Class: DailyFocus::ChatRunner

Inherits:
Object
  • Object
show all
Defined in:
app/services/daily_focus/chat_runner.rb

Overview

Single path for Daily Focus LLM generation: Assistant::ChatService + tools (no DataGatherer prompt).

Class Method Summary collapse

Class Method Details

.run!(conversation:, primary_employee:, covered_employees:, manager_party:, stream_proc:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/daily_focus/chat_runner.rb', line 6

def self.run!(conversation:, primary_employee:, covered_employees:, manager_party:, stream_proc:)
  focus_date = Prompt.focus_date_for_conversation(conversation)
  user_message = Prompt.user_message(
    primary_employee: primary_employee,
    covered_employees: covered_employees,
    date: focus_date
  )
  user_context = UserContextBuilder.for_manager_party(manager_party)

  RubyLLM::Instrumentation.with(
    feature: 'daily_focus_analysis',
    conversation_id: conversation.id,
    log_subject: conversation,
    log_account_id: Account.where(party_id: primary_employee.id).pick(:id)
  ) do
    service = Assistant::ChatService.new(
      conversation: conversation,
      user_message: user_message,
      model: DailyFocus::CHAT_MODEL_KEY,
      tool_services: DailyFocus::TOOL_SERVICE_KEYS,
      permitted_services: DailyFocus::TOOL_SERVICE_KEYS,
      user_context: user_context,
      on_status: nil,
      cancel_check: -> { false }
    )
    service.call(&stream_proc)
  end
end