Class: Assistant::GammaToolBuilder::CreateTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Assistant::GammaToolBuilder::CreateTool
- Defined in:
- app/services/assistant/gamma_tool_builder.rb
Overview
Create a new Gamma presentation, document, social post, or webpage using AI.
Instance Method Summary collapse
-
#execute(input_text:, format: 'presentation', text_mode: 'generate', theme_id: nil, num_cards: nil, card_split: 'auto', additional_instructions: nil, tone: nil, audience: nil, text_amount: nil, image_source: nil, dimensions: nil, export_as: nil, language: nil, **_) ⇒ String
JSON result payload.
- #name ⇒ Object
Instance Method Details
#execute(input_text:, format: 'presentation', text_mode: 'generate', theme_id: nil, num_cards: nil, card_split: 'auto', additional_instructions: nil, tone: nil, audience: nil, text_amount: nil, image_source: nil, dimensions: nil, export_as: nil, language: nil, **_) ⇒ String
Returns JSON result payload.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'app/services/assistant/gamma_tool_builder.rb', line 165 def execute(input_text:, format: 'presentation', text_mode: 'generate', theme_id: nil, num_cards: nil, card_split: 'auto', additional_instructions: nil, tone: nil, audience: nil, text_amount: nil, image_source: nil, dimensions: nil, export_as: nil, language: nil, **_) = {} [:amount] = text_amount if text_amount.present? [:tone] = tone if tone.present? [:audience] = audience if audience.present? [:language] = language if language.present? = {} [:source] = image_source if image_source.present? = {} [:dimensions] = dimensions if dimensions.present? client = GammaClient.new result = client.create_and_wait( input_text: input_text, text_mode: text_mode, format: format, theme_id: theme_id, num_cards: num_cards, card_split: card_split, additional_instructions: additional_instructions, export_as: export_as, text_options: .presence, image_options: .presence, card_options: .presence ) if result.success? data = result.data response = { success: true, gamma_url: data[:gamma_url], format: format, message: "Your #{format} is ready! View and edit 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_create failed: #{e.}") { success: false, error: "Gamma creation failed: #{e.}" }.to_json end |
#name ⇒ Object
147 |
# File 'app/services/assistant/gamma_tool_builder.rb', line 147 def name = 'gamma_create' |