Class: DailyFocus::ChatRunner
- Inherits:
-
Object
- Object
- DailyFocus::ChatRunner
- 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:, initiator: 'system') ⇒ 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 34 35 36 37 38 39 40 |
# File 'app/services/daily_focus/chat_runner.rb', line 6 def self.run!(conversation:, primary_employee:, covered_employees:, manager_party:, stream_proc:, initiator: 'system') focus_date = Prompt.focus_date_for_conversation(conversation) = Prompt.( primary_employee: primary_employee, covered_employees: covered_employees, date: focus_date ) user_context = UserContextBuilder.for_manager_party(manager_party) # Registers this exact turn as application-generated, which is what makes # the chat UI collapse it behind "Automated AI briefing request" instead # of dumping 17KB of prompt above the briefing. OpportunityBriefing has # always done this; Daily Focus never did, so every briefing since the # feature shipped has rendered expanded. conversation.update!(template_prompt_digests: conversation.template_prompt_digests_including()) 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: , 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 }, log_metadata: { initiator: initiator } ) service.call(&stream_proc) end end |