-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
Add Embeddings
service to the AI integration packages
#4368
Conversation
🦋 Changeset detectedLatest commit: 9c21de3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
a60b382
to
4d71f07
Compare
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.
You need to yield here
}).pipe(Layer.provide(NodeHttpClient.layerUndici)) | ||
|
||
// Create an embeddings service for the `text-embedding-3-large` model | ||
const TextEmbeddingsLarge = OpenAiEmbeddings.layerDataLoader({ |
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.
will it batch if I use
(documents: Array<string>) => Effect.forEach(documents, embedding.embed, { concurrency: "unbounded" })
and OpenAiEmbeddings.layer
?
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.
You would need to add batching true to the forEach options as under the hood it's using RequestResolver.batched.
Unless you use the data loader variant, in which case it will always batch as much as it can during the specified window (up to the max batch size).
}), | ||
Effect.map((response) => | ||
response.data.map(({ embedding, index }) => ({ | ||
embeddings: embedding as Array<number>, |
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.
should we define EmbeddingVector
data type?
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 see a real reason to do so unless I'm missing something?
I'm just casting from a read only array to a mutable one here.
bf8ee12
to
d8ef64b
Compare
9c21de3
to
fa1948c
Compare
Type
Description
Related