From 8d4482958923ded61ff1950197da4a96bf5dacd0 Mon Sep 17 00:00:00 2001 From: Pranav Date: Wed, 21 May 2025 15:52:51 -0700 Subject: [PATCH] Remove unused --- .../services/captain/copilot/chat_service.rb | 4 +- .../tools/copilot/search_article_service.rb | 63 ------------------- .../tools/copilot/search_contact_service.rb | 60 ------------------ 3 files changed, 2 insertions(+), 125 deletions(-) delete mode 100644 enterprise/app/services/captain/tools/copilot/search_article_service.rb delete mode 100644 enterprise/app/services/captain/tools/copilot/search_contact_service.rb diff --git a/enterprise/app/services/captain/copilot/chat_service.rb b/enterprise/app/services/captain/copilot/chat_service.rb index b0d7f067f..d76b4434b 100644 --- a/enterprise/app/services/captain/copilot/chat_service.rb +++ b/enterprise/app/services/captain/copilot/chat_service.rb @@ -56,8 +56,8 @@ class Captain::Copilot::ChatService < Llm::BaseOpenAiService @tool_registry.register_tool(Captain::Tools::Copilot::GetArticleService) @tool_registry.register_tool(Captain::Tools::Copilot::GetContactService) @tool_registry.register_tool(Captain::Tools::Copilot::GetConversationService) - @tool_registry.register_tool(Captain::Tools::Copilot::SearchArticleService) - @tool_registry.register_tool(Captain::Tools::Copilot::SearchContactService) + @tool_registry.register_tool(Captain::Tools::Copilot::SearchArticlesService) + @tool_registry.register_tool(Captain::Tools::Copilot::SearchContactsService) @tool_registry.register_tool(Captain::Tools::Copilot::SearchConversationsService) @tool_registry.register_tool(Captain::Tools::Copilot::SearchLinearIssuesService) @tool_registry.register_tool(Captain::Tools::Copilot::CreateLinearTicketsOnUiService) diff --git a/enterprise/app/services/captain/tools/copilot/search_article_service.rb b/enterprise/app/services/captain/tools/copilot/search_article_service.rb deleted file mode 100644 index 2822e2f3e..000000000 --- a/enterprise/app/services/captain/tools/copilot/search_article_service.rb +++ /dev/null @@ -1,63 +0,0 @@ -class Captain::Tools::Copilot::SearchArticleService < Captain::Tools::BaseService - def name - 'search_article' - end - - def description - 'Search for articles based on query parameters' - end - - def parameters - { - type: 'object', - properties: { - account_id: { - type: 'number', - description: 'The ID of the account to search articles in' - }, - query: { - type: 'string', - description: 'Search articles by title or content (partial match)' - }, - category_id: { - type: 'number', - description: 'Filter articles by category ID' - }, - status: { - type: 'string', - enum: %w[draft published archived], - description: 'Filter articles by status' - } - }, - required: %w[account_id] - } - end - - def execute(arguments) - account_id = arguments['account_id'] - query = arguments['query'] - category_id = arguments['category_id'] - status = arguments['status'] - - Rails.logger.info do - "[CAPTAIN][SearchArticle] account_id: #{account_id}, query: #{query}, category_id: #{category_id}, status: #{status}" - end - - return 'Missing required parameters' if account_id.blank? - - articles = Article.where(account_id: account_id) - articles = articles.where('title ILIKE :query OR content ILIKE :query', query: "%#{query}%") if query.present? - articles = articles.where(category_id: category_id) if category_id.present? - articles = articles.where(status: status) if status.present? - - return 'No articles found' unless articles.exists? - - total_count = articles.count - articles = articles.limit(100) - - <<~RESPONSE - #{total_count > 100 ? "Found #{total_count} articles (showing first 100)" : "Total number of articles: #{total_count}"} - #{articles.map(&:to_llm_text).join("\n---\n")} - RESPONSE - end -end diff --git a/enterprise/app/services/captain/tools/copilot/search_contact_service.rb b/enterprise/app/services/captain/tools/copilot/search_contact_service.rb deleted file mode 100644 index fcdd4e467..000000000 --- a/enterprise/app/services/captain/tools/copilot/search_contact_service.rb +++ /dev/null @@ -1,60 +0,0 @@ -class Captain::Tools::Copilot::SearchContactService < Captain::Tools::BaseService - def name - 'search_contact' - end - - def description - 'Search for contacts based on query parameters' - end - - def parameters - { - type: 'object', - properties: { - account_id: { - type: 'number', - description: 'The ID of the account to search contacts in' - }, - email: { - type: 'string', - description: 'Filter contacts by email' - }, - phone_number: { - type: 'string', - description: 'Filter contacts by phone number' - }, - name: { - type: 'string', - description: 'Filter contacts by name (partial match)' - } - }, - required: %w[account_id] - } - end - - def execute(arguments) - account_id = arguments['account_id'] - email = arguments['email'] - phone_number = arguments['phone_number'] - name = arguments['name'] - - Rails.logger.info do - "[CAPTAIN][SearchContact] account_id: #{account_id}, email: #{email}, phone_number: #{phone_number}, name: #{name}" - end - - return 'Missing required parameters' if account_id.blank? - - contacts = Contact.where(account_id: account_id) - contacts = contacts.where(email: email) if email.present? - contacts = contacts.where(phone_number: phone_number) if phone_number.present? - contacts = contacts.where('LOWER(name) ILIKE ?', "%#{name.downcase}%") if name.present? - - return 'No contacts found' unless contacts.exists? - - contacts = contacts.limit(100) - - <<~RESPONSE - #{contacts.map(&:to_llm_text).join("\n---\n")} - RESPONSE - end -end