Class: Assistant::GammaToolBuilder::ReworkTool

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

Overview

Rework an existing Gamma presentation, document, or webpage into a new one.

Instance Method Summary collapse

Instance Method Details

#execute(gamma_id:, prompt:, theme_id: nil, export_as: nil, image_style: nil, **_) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'app/services/assistant/gamma_tool_builder.rb', line 258

def execute(gamma_id:, prompt:, theme_id: nil, export_as: nil, image_style: nil, **_)
  gamma_id      = extract_gamma_id(gamma_id)
  image_options = image_style.present? ? { style: image_style } : nil

  client = GammaClient.new
  result = client.rework_and_wait(
    gamma_id:      gamma_id,
    prompt:        prompt,
    theme_id:      theme_id,
    export_as:     export_as,
    image_options: image_options
  )

  if result.success?
    data = result.data
    response = {
      success:   true,
      gamma_url: data[:gamma_url],
      message:   "Your reworked gamma is ready! View it here: #{data[:gamma_url]}"
    }
    response[:export_url] = data[:export_url] if data[:export_url].present?
    response[:credits]    = data[:credits]    if data[:credits].present?
    response.to_json
  else
    { success: false, error: result.error }.to_json
  end
rescue StandardError => e
  Rails.logger.error("[GammaToolBuilder] gamma_rework failed: #{e.message}")
  { success: false, error: "Gamma rework failed: #{e.message}" }.to_json
end

#nameObject



256
# File 'app/services/assistant/gamma_tool_builder.rb', line 256

def name = 'gamma_rework'