Class: Assistant::TechnicalArticleToolBuilder::ReaderTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Assistant::TechnicalArticleToolBuilder::ReaderTool
- Defined in:
- app/services/assistant/technical_article_tool_builder.rb
Overview
Read one approved Technical Article directly from its source-of-truth row,
including both legacy related-article slots and curated ContentLinks.
Direct Known Subclasses
Instance Method Summary collapse
-
#execute(id:) ⇒ String
Reads a single approved Technical Article and returns its full content.
-
#name ⇒ String
The RubyLLM tool name exposed to the assistant.
Instance Method Details
#execute(id:) ⇒ String
Reads a single approved Technical Article and returns its full content.
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'app/services/assistant/technical_article_tool_builder.rb', line 233 def execute(id:, **) article = article_class.where(state: ALLOWED_STATES).knowledge_corpus.find_by(id: id.to_i) return { error: "#{article_label} not found." }.to_json unless article ChatToolBuilder.truncate_result( payload_for(article).to_json, max_chars: MAX_READER_RESULT_CHARS ) rescue StandardError => e Rails.logger.error("[TechnicalArticleToolBuilder] #{article_label} read failed: #{e.class}: #{e.}") { error: "#{article_label} could not be read." }.to_json end |
#name ⇒ String
Returns the RubyLLM tool name exposed to the assistant.
227 |
# File 'app/services/assistant/technical_article_tool_builder.rb', line 227 def name = 'get_technical_article' |