Skip to content

Commit 1ad1ff6

Browse files
Fix the post install instructions and the env var name (#81)
1 parent acbdfe0 commit 1ad1ff6

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/langchainrb_rails/generators/langchainrb_rails/base_generator.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ class BaseGenerator < Rails::Generators::Base
1919
"openai" => "Langchain::LLM::OpenAI",
2020
"replicate" => "Langchain::LLM::Replicate"
2121
}
22+
23+
def post_install_message
24+
say "Please do the following to start Q&A with your #{model_name} records:", :green
25+
say "1. Run `bundle install` to install the new gems."
26+
say "2. Set an environment variable ENV['#{llm.upcase}_API_KEY'] for your #{llm_class}."
27+
say "3. Run `rails db:migrate` to apply the database migrations to enable pgvector and add the embedding column."
28+
say "4. In Rails console, run `#{model_name}.embed!` to set the embeddings for all records."
29+
say "5. Ask a question in the Rails console, ie: `#{model_name}.ask('[YOUR QUESTION]')`"
30+
end
2231
end
2332
end
2433
end

lib/langchainrb_rails/generators/langchainrb_rails/pgvector_generator.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ def add_to_gemfile
3535
gem "ruby-openai"
3636
end
3737

38-
def post_install_message
39-
say "Please do the following to start Q&A with your #{model_name} records:", :green
40-
say "1. Run `bundle install` to install the new gems."
41-
say "2. Set `OPENAI_API_KEY` environment variable to your OpenAI API key."
42-
say "3. Run `rails db:migrate` to apply the database migrations to enable pgvector and add the embedding column."
43-
say "4. In Rails console, run `#{model_name}.embed!` to set the embeddings for all records."
44-
say "5. Ask a question in the Rails console, ie: `#{model_name}.ask('[YOUR QUESTION]')`"
45-
end
46-
4738
private
4839

4940
# @return [String] Name of the model

lib/langchainrb_rails/generators/langchainrb_rails/templates/pgvector_initializer.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
LangchainrbRails.configure do |config|
44
config.vectorsearch = Langchain::Vectorsearch::Pgvector.new(
5-
llm: <%= llm_class %>.new(api_key: ENV["OPENAI_API_KEY"])
5+
llm: <%= llm_class %>.new(api_key: ENV["<%= llm.upcase %>_API_KEY"])
66
)
77
end

0 commit comments

Comments
 (0)