fix loops, improve time estimator
This commit is contained in:
+13
-2
@@ -156,6 +156,7 @@ end
|
||||
|
||||
local convert_ebooks = function(books)
|
||||
for name, data in pairs(books) do
|
||||
local function loop()
|
||||
if data.extracted_file then return end
|
||||
if not data.ebook_file then return end
|
||||
|
||||
@@ -168,6 +169,8 @@ local convert_ebooks = function(books)
|
||||
data.extracted_file_size = utility.file_size(extracted_file)
|
||||
end
|
||||
end
|
||||
loop()
|
||||
end
|
||||
end
|
||||
|
||||
local condense_summary = function(name, data, sections)
|
||||
@@ -248,6 +251,7 @@ end
|
||||
|
||||
local generate_cover_briefs = function(books)
|
||||
for name, data in pairs(books) do
|
||||
local function loop()
|
||||
if data.cover_brief_file then return end
|
||||
print(name)
|
||||
|
||||
@@ -255,7 +259,7 @@ local generate_cover_briefs = function(books)
|
||||
if data.extracted_file_size > config.llm_covers.maximum_bytes then
|
||||
text = generate_summary(name, data)
|
||||
else
|
||||
text = read_all(extracted_file)
|
||||
text = read_all(data.extracted_file)
|
||||
end
|
||||
|
||||
print("Generating cover brief.")
|
||||
@@ -266,15 +270,20 @@ local generate_cover_briefs = function(books)
|
||||
write_all("for_gemini/" .. name .. ".txt", "Title: " .. name .. prompts.for_gemini .. text)
|
||||
data.cover_brief_file = cover_brief_file
|
||||
end
|
||||
loop()
|
||||
end
|
||||
end
|
||||
|
||||
local estimate_time_required = function(books)
|
||||
local sum, count = 0, 0
|
||||
for name, data in pairs(books) do
|
||||
local function loop()
|
||||
if data.cover_brief_file then return end
|
||||
sum = sum + 60 * (2 + data.extracted_file_size/(config.llm_covers.maximum_bytes/7.5))
|
||||
sum = sum + 60 * (1.5 + data.extracted_file_size/(config.llm_covers.maximum_bytes/7.5))
|
||||
count = count + 1
|
||||
end
|
||||
loop()
|
||||
end
|
||||
|
||||
print(count .. " cover briefs to generate. Estimated time: "
|
||||
.. timing.seconds_to_minutes(sum) .. " minutes.")
|
||||
@@ -293,5 +302,7 @@ generate_cover_briefs(books)
|
||||
print("")
|
||||
timing.print_report()
|
||||
|
||||
-- utility.print_table(books)
|
||||
|
||||
-- ebook_file, extracted_file, extracted_file_size,
|
||||
-- intermediate_file, condensed_intermediate_file, cover_brief_file
|
||||
|
||||
Reference in New Issue
Block a user