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, **_) ⇒ String

Returns JSON result payload.

Parameters:

  • gamma_id (String)

    Gamma URL or gammaId of the deck to rework

  • prompt (String)

    rework instructions

  • theme_id (String, nil) (defaults to: nil)

    Gamma theme id to apply

  • export_as (String, nil) (defaults to: nil)

    request a download export (pdf or pptx)

  • image_style (String, nil) (defaults to: nil)

    image style override for AI-generated images

  • _ (Hash)

    a customizable set of options

Options Hash (**_):

  • :ignored (Object)

    extra keyword arguments are accepted and ignored

Returns:

  • (String)

    JSON result payload



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'app/services/assistant/gamma_tool_builder.rb', line 281

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



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

def name = 'gamma_rework'