From ab955d34e599d26d47620066f69f555bae46c1b1 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 20 Jan 2025 15:48:17 +0530 Subject: [PATCH] feat: log increments --- .../jobs/captain/conversation/response_builder_job.rb | 1 + .../app/services/captain/copilot/chat_service.rb | 1 + enterprise/listeners/captain_listener.rb | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/enterprise/app/jobs/captain/conversation/response_builder_job.rb b/enterprise/app/jobs/captain/conversation/response_builder_job.rb index 2118af2f6..c8c511a57 100644 --- a/enterprise/app/jobs/captain/conversation/response_builder_job.rb +++ b/enterprise/app/jobs/captain/conversation/response_builder_job.rb @@ -26,6 +26,7 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob return process_action('handoff') if handoff_requested? create_messages + Rails.logger.info("[CAPTAIN][ResponseBuilderJob] Incrementing response usage for #{account.id}") account.increment_response_usage end diff --git a/enterprise/app/services/captain/copilot/chat_service.rb b/enterprise/app/services/captain/copilot/chat_service.rb index d2d221183..ea15ac4e8 100644 --- a/enterprise/app/services/captain/copilot/chat_service.rb +++ b/enterprise/app/services/captain/copilot/chat_service.rb @@ -9,6 +9,7 @@ class Captain::Copilot::ChatService def execute(input) @agent.execute(input, conversation_history_context) + Rails.logger.info("[CAPTAIN][CopilotChatService] Incrementing response usage for #{account.id}") @assistant.account.increment_response_usage end diff --git a/enterprise/listeners/captain_listener.rb b/enterprise/listeners/captain_listener.rb index 1958fb78b..0dc4099b4 100644 --- a/enterprise/listeners/captain_listener.rb +++ b/enterprise/listeners/captain_listener.rb @@ -14,11 +14,17 @@ class CaptainListener < BaseListener def generate_notes(assistant, conversation) Captain::Llm::ContactNotesService.new(assistant, conversation).generate_and_update_notes - conversation.account.increment_response_usage + + account = conversation.account + Rails.logger.info("[CAPTAIN][ContactNotesService] Incrementing response usage for #{account.id}") + account.increment_response_usage end def generate_faqs(assistant, conversation) Captain::Llm::ConversationFaqService.new(assistant, conversation).generate_and_deduplicate - conversation.account.increment_response_usage + + account = conversation.account + Rails.logger.info("[CAPTAIN][ConversationFaqService] Incrementing response usage for #{account.id}") + account.increment_response_usage end end