Class: Assistant::TechnicalArticleToolBuilder::SearchTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Assistant::TechnicalArticleToolBuilder::SearchTool
- Defined in:
- app/services/assistant/technical_article_tool_builder.rb
Overview
Search approved Technical Articles and reject any result whose stored
embedding cannot be proven to match its current source content.
Direct Known Subclasses
Instance Method Summary collapse
-
#execute(query:, limit: 8) ⇒ String
Runs a semantic search over Technical Articles and returns verified results.
-
#name ⇒ String
The RubyLLM tool name exposed to the assistant.
Instance Method Details
#execute(query:, limit: 8) ⇒ String
Runs a semantic search over Technical Articles and returns verified results.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/services/assistant/technical_article_tool_builder.rb', line 49 def execute(query:, limit: 8, **) limit = limit.to_i.clamp(1, MAX_SEARCH_RESULTS) candidates = search(query, limit:) (candidates) articles = candidates.filter_map { |result| format_result(result) }.first(limit) ChatToolBuilder.truncate_result( { query: query, total_results: articles.size, articles: articles }.to_json ) rescue StandardError => e Rails.logger.error("[TechnicalArticleToolBuilder] #{article_label} search failed: #{e.class}: #{e.}") { error: "#{article_label} search failed." }.to_json end |
#name ⇒ String
Returns the RubyLLM tool name exposed to the assistant.
42 |
# File 'app/services/assistant/technical_article_tool_builder.rb', line 42 def name = 'search_technical_articles' |