mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
better error handling
This commit is contained in:
parent
ea227b6462
commit
debb396b44
1 changed files with 16 additions and 12 deletions
|
|
@ -379,17 +379,6 @@ const summarizeItems = async (
|
|||
digestDefinition.summaryPrompt
|
||||
)
|
||||
|
||||
const prompts = await Promise.all(
|
||||
rankedCandidates.map(
|
||||
async (item) =>
|
||||
await contextualTemplate.format({
|
||||
title: item.libraryItem.title,
|
||||
author: item.libraryItem.author ?? '',
|
||||
content: item.libraryItem.readableContent, // markdown content
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
// // send all the ranked candidates to openAI at once in a batch
|
||||
// const summaries = await chain.batch(
|
||||
// rankedCandidates.map((item) => ({
|
||||
|
|
@ -399,7 +388,22 @@ const summarizeItems = async (
|
|||
// }))
|
||||
// )
|
||||
|
||||
const summaries = await llm.batch(prompts)
|
||||
const summaries = await Promise.all(
|
||||
rankedCandidates.map(async (item) => {
|
||||
try {
|
||||
const prompt = await contextualTemplate.format({
|
||||
title: item.libraryItem.title,
|
||||
author: item.libraryItem.author ?? '',
|
||||
content: item.libraryItem.readableContent, // markdown content
|
||||
})
|
||||
|
||||
return llm.invoke(prompt)
|
||||
} catch (error) {
|
||||
logger.error('summarizeItems error', error)
|
||||
return { content: '' }
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
summaries.forEach(
|
||||
(summary, index) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue