1
0
mirror of https://github.com/algora-io/tv.git synced 2024-11-16 00:58:59 +02:00

don't init new index on load error

This commit is contained in:
zafer 2024-05-04 14:11:39 +03:00
parent 30be48155f
commit 24215f5e33

View File

@ -39,14 +39,8 @@ defmodule Algora.ML do
end
defp load_index_from_disk!(path) do
case HNSWLib.Index.load_index(:cosine, 768, path, max_elements: 100_000) do
{:ok, index} ->
index
{:error, _} ->
{:ok, index} = HNSWLib.Index.new(:cosine, 768, 1_000_000)
save_index(index)
index
with {:ok, index} <- HNSWLib.Index.load_index(:cosine, 768, path, max_elements: 100_000) do
index
end
end