Class: LangchainrbRails::Generators::QdrantGenerator
- Inherits:
-
BaseGenerator
- Object
- Rails::Generators::Base
- BaseGenerator
- LangchainrbRails::Generators::QdrantGenerator
- Defined in:
- lib/langchainrb_rails/generators/langchainrb_rails/qdrant_generator.rb
Overview
PineconeGenerator does the following:
-
Creates the
langchainrb_rails.rbinitializer file -
Adds necessary code to the ActiveRecord model to enable vectorsearch
-
Adds
qdrant-rubygem to the Gemfile
Usage:
rails generate langchainrb_rails:qdrant --model=Product --llm=openai
Constant Summary
Constants inherited from BaseGenerator
Instance Method Summary collapse
-
#add_to_gemfile ⇒ Object
Adds
qdrant-rubygem to the Gemfile. -
#add_to_model ⇒ Object
Adds
vectorsearchclass method to the model andafter_savecallback that calls ‘upsert_to_vectorsearch()`. -
#create_initializer_file ⇒ Object
Creates the
langchainrb_rails.rbinitializer file.
Methods inherited from BaseGenerator
#after_generate, #post_install_message
Instance Method Details
#add_to_gemfile ⇒ Object
Adds qdrant-ruby gem to the Gemfile
31 32 33 |
# File 'lib/langchainrb_rails/generators/langchainrb_rails/qdrant_generator.rb', line 31 def add_to_gemfile gem "qdrant-ruby" 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/qdrant_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/qdrant_generator.rb', line 19 def create_initializer_file template "qdrant_initializer.rb", "config/initializers/langchainrb_rails.rb" end |