Skip to content

Commit 0dbc273

Browse files
Use the parent generator class
1 parent e82bd7c commit 0dbc273

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

langchainrb_rails.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Gem::Specification.new do |spec|
3030
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
3131
spec.require_paths = ["lib"]
3232

33-
# TODO - add back ... loading locally
34-
#spec.add_dependency "langchainrb", "~> 0.7.0"
33+
spec.add_dependency "langchainrb", "~> 0.7.0"
3534

3635
spec.add_development_dependency "pry-byebug", "~> 3.10.0"
3736
spec.add_development_dependency "yard", "~> 0.9.34"

lib/langchainrb_rails/generators/langchainrb_rails/pgvector_generator.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
require "rails/generators/active_record"
1+
# frozen_string_literal: true
22

33
module LangchainrbRails
44
module Generators
55
#
66
# Usage:
77
# rails g langchain:pgvector -model=Product -llm=openai
88
#
9-
class PgvectorGenerator < Rails::Generators::Base
9+
class PgvectorGenerator < LangchainrbRails::Generators::BaseGenerator
1010
desc "This generator adds Pgvector vectorsearch integration to your ActiveRecord model"
11-
12-
include ::ActiveRecord::Generators::Migration
1311
source_root File.join(__dir__, "templates")
1412

15-
class_option :model, type: :string, required: true, desc: "ActiveRecord Model to add vectorsearch to", aliases: "-m"
16-
class_option :llm, type: :string, required: true, desc: "LLM provider that will be used to generate embeddings and completions"
17-
18-
LLMS = {
19-
"cohere" => "Langchain::LLM::Cohere",
20-
"google_palm" => "Langchain::LLM::GooglePalm",
21-
"hugging_face" => "Langchain::LLM::HuggingFace",
22-
"llama_cpp" => "Langchain::LLM::LlamaCpp",
23-
"ollama" => "Langchain::LLM::Ollama",
24-
"openai" => "Langchain::LLM::OpenAI",
25-
"replicate" => "Langchain::LLM::Replicate"
26-
}
27-
2813
def copy_migration
2914
migration_template "enable_vector_extension_template.rb", "db/migrate/enable_vector_extension.rb", migration_version: migration_version
3015
migration_template "add_vector_column_template.rb", "db/migrate/add_vector_column_to_#{table_name}.rb", migration_version: migration_version

0 commit comments

Comments
 (0)