Class: LangchainrbRails::Generators::PromptGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/langchainrb_rails/generators/langchainrb_rails/prompt_generator.rb

Overview

Adds prompt templating capabilities to your ActiveRecord model

Usage:

rails generate langchainrb_rails:prompt

Instance Method Summary collapse

Instance Method Details

#copy_migrationObject



22
23
24
# File 'lib/langchainrb_rails/generators/langchainrb_rails/prompt_generator.rb', line 22

def copy_migration
  migration_template "create_prompts.rb", "db/migrate/create_prompts.rb", migration_version: migration_version
end

#create_model_fileObject



18
19
20
# File 'lib/langchainrb_rails/generators/langchainrb_rails/prompt_generator.rb', line 18

def create_model_file
  template "prompt_model.rb", "app/models/prompt.rb"
end

#migration_versionObject



26
27
28
# File 'lib/langchainrb_rails/generators/langchainrb_rails/prompt_generator.rb', line 26

def migration_version
  "[#{::ActiveRecord::VERSION::MAJOR}.#{::ActiveRecord::VERSION::MINOR}]"
end