Class: LangchainrbRails::Generators::PineconeGenerator
- Inherits:
-
BaseGenerator
- Object
- Rails::Generators::Base
- BaseGenerator
- LangchainrbRails::Generators::PineconeGenerator
- Defined in:
- lib/langchainrb_rails/generators/langchainrb_rails/pinecone_generator.rb
Overview
PineconeGenerator does the following:
-
Creates the ‘langchainrb_rails.rb` initializer file
-
Adds necessary code to the ActiveRecord model to enable vectorsearch
-
Adds ‘pinecone` gem to the Gemfile
Usage:
rails generate langchainrb_rails:pinecone --model=Product --llm=openai
Constant Summary
Constants inherited from BaseGenerator
Instance Method Summary collapse
-
#add_to_gemfile ⇒ Object
Adds ‘pinecone` gem to the Gemfile.
-
#add_to_model ⇒ Object
Adds ‘vectorsearch` class method to the model and `after_save` callback that calls `upsert_to_vectorsearch()`.
-
#create_initializer_file ⇒ Object
Creates the ‘langchainrb_rails.rb` initializer file.
Methods inherited from BaseGenerator
#after_generate, #post_install_message
Instance Method Details
#add_to_gemfile ⇒ Object
Adds ‘pinecone` gem to the Gemfile
31 32 33 |
# File 'lib/langchainrb_rails/generators/langchainrb_rails/pinecone_generator.rb', line 31 def add_to_gemfile gem "pinecone" end |
#add_to_model ⇒ Object
Adds ‘vectorsearch` class method to the model and `after_save` callback that calls `upsert_to_vectorsearch()`
24 25 26 27 28 |
# File 'lib/langchainrb_rails/generators/langchainrb_rails/pinecone_generator.rb', line 24 def add_to_model inject_into_class "app/models/#{model_name.downcase}.rb", model_name do " vectorsearch\n\n after_save :upsert_to_vectorsearch\n\n" end end |
#create_initializer_file ⇒ Object
Creates the ‘langchainrb_rails.rb` initializer file
19 20 21 |
# File 'lib/langchainrb_rails/generators/langchainrb_rails/pinecone_generator.rb', line 19 def create_initializer_file template "pinecone_initializer.rb", "config/initializers/langchainrb_rails.rb" end |