Class: Assistant::PublicationToolBuilder::ReaderTool

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
app/services/assistant/publication_tool_builder.rb

Instance Method Summary collapse

Instance Method Details

#execute(id:, offset: 0) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'app/services/assistant/publication_tool_builder.rb', line 34

def execute(id:, offset: 0, **)
  publication = Item.publications.active.with_publication_attached.find_by(id: id.to_i)
  return { error: 'Publication not found.' }.to_json unless publication

  payload_for(publication, offset: offset.to_i).to_json
rescue StandardError => e
  Rails.logger.error("[PublicationToolBuilder] Read failed: #{e.class}: #{e.message}")
  { error: 'Publication could not be read.' }.to_json
end

#nameObject



32
# File 'app/services/assistant/publication_tool_builder.rb', line 32

def name = 'get_publication'