remove debug printing, workaround for EOF Ollama error #7
This commit is contained in:
+19
-6
@@ -107,15 +107,22 @@ local process_file = function(data_source, file_name)
|
|||||||
|
|
||||||
local new_embeddings = {}
|
local new_embeddings = {}
|
||||||
for i = 1, #chunks do
|
for i = 1, #chunks do
|
||||||
print("Embedding length:", #chunks[i])
|
-- print("Embedding length:", #chunks[i])
|
||||||
new_embeddings[i] = generate_embeddings(chunks[i]) or {}
|
new_embeddings[i] = generate_embeddings(chunks[i]) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if #new_embeddings[1] == 0 then
|
if #new_embeddings[1] == 0 then
|
||||||
print(file_name)
|
-- print(file_name)
|
||||||
print("Vector lengths:")
|
-- print("Vector lengths:")
|
||||||
for e = 1, #new_embeddings do
|
-- for e = 1, #new_embeddings do
|
||||||
print("", e, #new_embeddings[e])
|
-- print("", e, #new_embeddings[e])
|
||||||
|
-- end
|
||||||
|
if #new_embeddings == 1 then
|
||||||
|
-- Ollama very rarely errors with:
|
||||||
|
-- Error: do embedding request: Post "http://127.0.0.1:53441/v1/embeddings": EOF
|
||||||
|
-- but it is inconsistent and re-running will eventually fix it. (See issue #7 if present.)
|
||||||
|
print(file_name .. "\n encountered an embedding error and will be skipped this run only.")
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- average all embeddings to make the core file embedding
|
-- average all embeddings to make the core file embedding
|
||||||
@@ -145,7 +152,13 @@ local refresh_sources = function()
|
|||||||
local file_name = file_list[f]
|
local file_name = file_list[f]
|
||||||
local function loop()
|
local function loop()
|
||||||
local sha512sum = utility.sha512sum(file_name)
|
local sha512sum = utility.sha512sum(file_name)
|
||||||
if embeddings.vectors[sha512sum] then return end
|
if embeddings.vectors[sha512sum] then
|
||||||
|
-- add file reference if it was missing
|
||||||
|
if not embeddings.files[file_name] then
|
||||||
|
embeddings.files[file_name] = sha512sum
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local file_chunks, file_embeddings = process_file(data_source, file_name)
|
local file_chunks, file_embeddings = process_file(data_source, file_name)
|
||||||
if not file_chunks then return end
|
if not file_chunks then return end
|
||||||
|
|||||||
Reference in New Issue
Block a user