no function clause matching in Pgvector.new/1
This is what I'm doing:
With this
case Req.post(url, json: body) do
{:ok, %{status: 200, body: %{"embeddings" => embeddings}}} ->
binary_embeddings =
embeddings
|> Enum.map(fn %{"values" => values} ->
# Create Pgvector from the float values and convert to binary
values
|> Pgvector.new()
|> Pgvector.to_binary()
end)
{:ok, binary_embeddings}
case Req.post(url, json: body) do
{:ok, %{status: 200, body: %{"embeddings" => embeddings}}} ->
binary_embeddings =
embeddings
|> Enum.map(fn %{"values" => values} ->
# Create Pgvector from the float values and convert to binary
values
|> Pgvector.new()
|> Pgvector.to_binary()
end)
{:ok, binary_embeddings}
vectorize do
attributes description: :description_vector
embedding_model CoffeeViewer.EmbeddingModels.Gemini
strategy :after_action
end
vectorize do
attributes description: :description_vector
embedding_model CoffeeViewer.EmbeddingModels.Gemini
strategy :after_action
end
3 Replies
[debug] QUERY ERROR source="coffee_varieties" db=31.5ms
UPDATE "coffee_varieties" AS c0 SET "updated_at" = $1, "description_vector" = $2 WHERE (c0."id" = $3) RETURNING c0."id", c0."url", c0."origin", c0."name", c0."price_lb", c0."description", c0."processing", c0."source", c0."variety", c0."variety_input", c0."masl", c0."masl_low", c0."masl_high", c0."description_vector", c0."inserted_at", c0."updated_at" [~U[2025-09-27 16:12:58.215750Z], Ash.Vector.new([12.0, 0.0, 0.0, 0.0, 188.0, 92.0, 117.0, 177.0, 60.0, 7.0, 174.0, 3.0, 60.0, 113.0, 207.0, 128.0, 189.0, 153.0, 128.0, 141.0, 60.0, 28.0, 21.0, 147.0, 188.0, 148.0, 127.0, 205.0, 59.0, 57.0, 166.0, 32.0, 188.0, 101.0, 195.0, 101.0, 188.0, 139.0, 77.0, 245.0, 59.0, 141.0, 170.0, 88.0, 189.0, 8.0, 86.0, 216.0, ...]), "715c08a6-1759-49b1-8a55-536023750c5d"]
[debug] QUERY OK db=8.0ms
rollback []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:4178
{:error,
%Ash.Error.Unknown{
bread_crumbs: ["Error returned from: CoffeeViewer.Resources.CoffeeVariety.create"],
changeset: "#Changeset<>",
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1",
field: nil,
value: nil,
splode: Ash.Error,
bread_crumbs: ["Error returned from: CoffeeViewer.Resources.CoffeeVariety.create"],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}}
[debug] QUERY ERROR source="coffee_varieties" db=31.5ms
UPDATE "coffee_varieties" AS c0 SET "updated_at" = $1, "description_vector" = $2 WHERE (c0."id" = $3) RETURNING c0."id", c0."url", c0."origin", c0."name", c0."price_lb", c0."description", c0."processing", c0."source", c0."variety", c0."variety_input", c0."masl", c0."masl_low", c0."masl_high", c0."description_vector", c0."inserted_at", c0."updated_at" [~U[2025-09-27 16:12:58.215750Z], Ash.Vector.new([12.0, 0.0, 0.0, 0.0, 188.0, 92.0, 117.0, 177.0, 60.0, 7.0, 174.0, 3.0, 60.0, 113.0, 207.0, 128.0, 189.0, 153.0, 128.0, 141.0, 60.0, 28.0, 21.0, 147.0, 188.0, 148.0, 127.0, 205.0, 59.0, 57.0, 166.0, 32.0, 188.0, 101.0, 195.0, 101.0, 188.0, 139.0, 77.0, 245.0, 59.0, 141.0, 170.0, 88.0, 189.0, 8.0, 86.0, 216.0, ...]), "715c08a6-1759-49b1-8a55-536023750c5d"]
[debug] QUERY OK db=8.0ms
rollback []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:4178
{:error,
%Ash.Error.Unknown{
bread_crumbs: ["Error returned from: CoffeeViewer.Resources.CoffeeVariety.create"],
changeset: "#Changeset<>",
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1",
field: nil,
value: nil,
splode: Ash.Error,
bread_crumbs: ["Error returned from: CoffeeViewer.Resources.CoffeeVariety.create"],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}}
{:ok, [38.1, 28.4]}
But then I get this:
One Gemini Embedding: [-0.013455794, 0.008281234, 0.0147589445, -0.07495222, 0.009526628,
-0.018127346, 0.0028327778, -0.0140236365, -0.017004946, 0.004323285,
-0.033285946, -0.019286018, 0.0074711614, -0.021341871, 0.13488935,
0.0072718263, -0.004040753, -0.016631586, 0.030813316, -0.028892068,
-0.006682747, -0.008962272, 0.03023256, -0.011179493, -0.0055965167,
-0.027514918, 0.007523568, 0.007230257, 0.039080173, 0.027073363, 0.0077693798,
-0.0025698703, 0.034384217, 0.033681665, -0.0043010274, 0.023705807,
0.052353032, -0.005494421, 0.0042250347, 0.036214583, -0.03179253, 0.045350093,
0.034468018, -0.02169439, -0.022515904, -0.0027886645, -0.010403167,
-0.031022398, -0.02034816, 0.03670774, ...]
[debug] QUERY OK db=1.7ms
rollback []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:4178
** (Ash.Error.Unknown)
Bread Crumbs:
> building changeset for CoffeeViewer.Resources.CoffeeVariety.ash_ai_update_embeddings
> Exception raised in: CoffeeViewer.Resources.CoffeeVariety.create
Unknown Error
* ** (FunctionClauseError) no function clause matching in Ash.Vector.new/1
(ash 3.5.42) lib/ash/vector.ex:19: Ash.Vector.new(-0.013455794)
One Gemini Embedding: [-0.013455794, 0.008281234, 0.0147589445, -0.07495222, 0.009526628,
-0.018127346, 0.0028327778, -0.0140236365, -0.017004946, 0.004323285,
-0.033285946, -0.019286018, 0.0074711614, -0.021341871, 0.13488935,
0.0072718263, -0.004040753, -0.016631586, 0.030813316, -0.028892068,
-0.006682747, -0.008962272, 0.03023256, -0.011179493, -0.0055965167,
-0.027514918, 0.007523568, 0.007230257, 0.039080173, 0.027073363, 0.0077693798,
-0.0025698703, 0.034384217, 0.033681665, -0.0043010274, 0.023705807,
0.052353032, -0.005494421, 0.0042250347, 0.036214583, -0.03179253, 0.045350093,
0.034468018, -0.02169439, -0.022515904, -0.0027886645, -0.010403167,
-0.031022398, -0.02034816, 0.03670774, ...]
[debug] QUERY OK db=1.7ms
rollback []
↳ anonymous fn/3 in Ash.Changeset.with_hooks/3, at: lib/ash/changeset/changeset.ex:4178
** (Ash.Error.Unknown)
Bread Crumbs:
> building changeset for CoffeeViewer.Resources.CoffeeVariety.ash_ai_update_embeddings
> Exception raised in: CoffeeViewer.Resources.CoffeeVariety.create
Unknown Error
* ** (FunctionClauseError) no function clause matching in Ash.Vector.new/1
(ash 3.5.42) lib/ash/vector.ex:19: Ash.Vector.new(-0.013455794)
Solution
i think pg vector package is the issue
figured it out. thanks for coming to my TED talk