Skip to content

Commit 870f832

Browse files
authored
Merge pull request #247 from nidzola/vectorstore-embedder-options
vectorstore/options: Extending Vectorstore options to accept optional embedder
2 parents ca2e82f + 1552263 commit 870f832

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

vectorstores/options.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package vectorstores
22

3+
import "github.com/tmc/langchaingo/embeddings"
4+
35
// Option is a function that configures an Options.
46
type Option func(*Options)
57

@@ -8,6 +10,7 @@ type Options struct {
810
NameSpace string
911
ScoreThreshold float64
1012
Filters any
13+
Embedder embeddings.Embedder
1114
}
1215

1316
// WithNameSpace returns an Option for setting the name space.
@@ -32,3 +35,12 @@ func WithFilters(filters any) Option {
3235
o.Filters = filters
3336
}
3437
}
38+
39+
// WithEmbedder returns an Option for setting the embedder that could be used when
40+
// adding documents or doing similarity search (instead the embedder from the Store context)
41+
// this is useful when we are using multiple LLMs with single vectorstore.
42+
func WithEmbedder(embedder embeddings.Embedder) Option {
43+
return func(o *Options) {
44+
o.Embedder = embedder
45+
}
46+
}

0 commit comments

Comments
 (0)