Class: ActiveCortex::Generator::Text

Inherits:
ActiveCortex::Generator show all
Defined in:
lib/active_cortex/generator/text.rb

Instance Attribute Summary

Attributes inherited from ActiveCortex::Generator

#field_name, #max_results, #model, #record

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveCortex::Generator

generate, #initialize

Constructor Details

This class inherits a constructor from ActiveCortex::Generator

Class Method Details

.accepts?(record:, field_name:) ⇒ Boolean

Returns:



2
3
4
# File 'lib/active_cortex/generator/text.rb', line 2

def self.accepts?(record:, field_name:)
  record.class.attribute_types[field_name.to_s].type == :string
end

Instance Method Details

#generationObject



10
11
12
# File 'lib/active_cortex/generator/text.rb', line 10

def generation
  openai_content || raise(ActiveCortex::Error, openai_error_message)
end

#save_generationObject



6
7
8
# File 'lib/active_cortex/generator/text.rb', line 6

def save_generation
  record.send("#{field_name}=", generation)
end