Remove unused
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user