-
-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llms/mistral: Implementing embeddings.EmbedderClient for Mistral and an example with PGVector #1086
base: main
Are you sure you want to change the base?
Conversation
I did a replace in my mod file for my local dev, and was unsure how to handle that in the PR, which I think is the reason for the CI failures. Happy to take pointers on if I should change something in my repo to fix it. KR |
…ents CreateEmbedding and the embeddings.EmbedderClient interface
Ok, I think good to go for reviewing. Also, as said earlier, any pointers or feedback welcome as this is my first PR in this project. |
"errors" | ||
) | ||
|
||
func ConvertFloat64ToFloat32(input []float64) []float32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this function needs to be exported.
allEmbds := make([][]float32, len(embsRes.Data)) | ||
for i, embs := range embsRes.Data { | ||
if len(embs.Embedding) == 0 { | ||
return nil, errors.New("empty embeddings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an exported error variable. var ErrEmptyEmbeddings = errors.new("...")
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
output := sdk.ConvertFloat64ToFloat32(tt.input) | ||
if len(output) != len(tt.expected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use stretchr/testify in test.
value := os.Getenv(envVar) | ||
|
||
// Check if it is set (non-empty) | ||
if value == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use t.Skip instead.
|
||
model, err := sdk.New() | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not panic the errors. Use require.NoError(t, err) from testify instead
if err != nil { | ||
panic(err) | ||
} | ||
t.Logf("Document embeddings: %v\n", docEmbeddings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to include the log statements.
} | ||
fmt.Println("store.SimilaritySearch1:\n", docs) | ||
|
||
time.Sleep(2 * time.Second) // Don't trigger cloudflare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no better solution for this?
This PR implements the embeddings.EmbedderClient interface for mistral, using the "mistral-embed" model. There is an example, heavily inspired by the
openai-embeddings-example
of how it can be used with pgvector.PR Checklist
memory: add interfaces for X, Y
orutil: add whizzbang helpers
).Fixes #123
).golangci-lint
checks.