Add limit to the conversations

This commit is contained in:
Pranav
2025-05-12 14:36:29 -07:00
parent 98cb3e0bf8
commit 5f412b0baf
3 changed files with 11 additions and 9 deletions
@@ -52,8 +52,11 @@ class Captain::Tools::Copilot::SearchArticleService < Captain::Tools::BaseServic
return 'No articles found' unless articles.exists?
total_count = articles.count
articles = articles.limit(100)
<<~RESPONSE
Total number of articles: #{articles.count}
#{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
@@ -51,9 +51,9 @@ class Captain::Tools::Copilot::SearchContactService < Captain::Tools::BaseServic
return 'No contacts found' unless contacts.exists?
<<~RESPONSE
Total number of contacts: #{contacts.count}
contacts = contacts.limit(100)
<<~RESPONSE
#{contacts.map(&:to_llm_text).join("\n---\n")}
RESPONSE
end
@@ -53,13 +53,12 @@ class Captain::Tools::Copilot::SearchConversationService < Captain::Tools::BaseS
return 'No conversations found' unless conversations.exists?
total_count = conversations.count
conversations = conversations.limit(100)
<<~RESPONSE
Total number of conversations: #{conversations.count}
#{
conversations.map do |conversation|
conversation.to_llm_text(include_contact_details: true)
end.join("\n---\n")
}
#{total_count > 100 ? "Found #{total_count} conversations (showing first 100)" : "Total number of conversations: #{total_count}"}
#{conversations.map { |conversation| conversation.to_llm_text(include_contact_details: true) }.join("\n---\n")}
RESPONSE
end
end