Skip to content

Commit 03d6db8

Browse files
Set a Langchain::Vectorsearch::* instance on each class instead of pointing to the same object. This fixes a bug when 1+ ActiveRecord models use vectorsearh (#37)
1 parent 18a753d commit 03d6db8

File tree

1 file changed

+2
-2
lines changed
  • lib/langchainrb_rails/active_record

1 file changed

+2
-2
lines changed

lib/langchainrb_rails/active_record/hooks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ module ClassMethods
7171
#
7272
# @param provider [Object] The `Langchain::Vectorsearch::*` instance
7373
def vectorsearch
74-
class_variable_set(:@@provider, LangchainrbRails.config.vectorsearch)
74+
class_variable_set(:@@provider, LangchainrbRails.config.vectorsearch.dup)
7575

7676
# Pgvector-specific configuration
7777
if LangchainrbRails.config.vectorsearch.is_a?(Langchain::Vectorsearch::Pgvector)
7878
has_neighbors(:embedding)
79-
LangchainrbRails.config.vectorsearch.model = self
79+
class_variable_get(:@@provider).model = self
8080
end
8181
end
8282

0 commit comments

Comments
 (0)