Class: Assistant::TechnicalArticleToolBuilder::ReaderTool

Inherits:
RubyLLM::Tool
  • Object
show all
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

ProcedureReaderTool

Instance Method Summary collapse

Instance Method Details

#execute(id:) ⇒ String

Reads a single approved Technical Article and returns its full content.

Parameters:

  • id (Integer, String)

    numeric Technical Article ID returned by search_technical_articles.

Returns:

  • (String)

    JSON string with article payload or an error object.



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: "#{} 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] #{} read failed: #{e.class}: #{e.message}")
  { error: "#{} could not be read." }.to_json
end

#nameString

Returns the RubyLLM tool name exposed to the assistant.

Returns:

  • (String)

    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'