Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Move the embedding process outside of transaction to preven timeout e…
Browse files Browse the repository at this point in the history
…rrors in postgres
  • Loading branch information
karol-t-wilk committed Jun 5, 2024
1 parent 68d22d4 commit 353cd25
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/search/embeddings/bumblebee_provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ defmodule Search.Embeddings.BumblebeeProvider do

now = DateTime.utc_now(:second)

Repo.transaction(fn ->
embeddings_params =
[fragments, embeddings]
|> Stream.zip()
|> Enum.map(fn {fragment, embedding} ->
%{
embedding: embedding,
doc_fragment_id: fragment.id,
inserted_at: now,
updated_at: now
}
end)
embeddings_params =
[fragments, embeddings]
|> Stream.zip()
|> Enum.map(fn {fragment, embedding} ->
%{
embedding: embedding,
doc_fragment_id: fragment.id,
inserted_at: now,
updated_at: now
}
end)

Repo.transaction(fn ->
{inserted, embeddings} =
Repo.insert_all(
{table_name, Embeddings.Embedding},
Expand Down

0 comments on commit 353cd25

Please sign in to comment.