fix: add length check before summarization in HypaV3
This commit is contained in:
@@ -442,23 +442,25 @@ export async function hypaMemoryV3(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attempt summarization
|
// Attempt summarization
|
||||||
const summarizeResult = await retryableSummarize(toSummarize);
|
if (toSummarize.length > 0) {
|
||||||
|
const summarizeResult = await retryableSummarize(toSummarize);
|
||||||
|
|
||||||
if (!summarizeResult.success) {
|
if (!summarizeResult.success) {
|
||||||
return {
|
return {
|
||||||
currentTokens,
|
currentTokens,
|
||||||
chats,
|
chats,
|
||||||
error: `[HypaV3] Summarization failed after maximum retries: ${summarizeResult.data}`,
|
error: `[HypaV3] Summarization failed after maximum retries: ${summarizeResult.data}`,
|
||||||
memory: toSerializableHypaV3Data(data),
|
memory: toSerializableHypaV3Data(data),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
data.summaries.push({
|
||||||
|
text: summarizeResult.data,
|
||||||
|
chatMemos: new Set(toSummarize.map((chat) => chat.memo)),
|
||||||
|
isImportant: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
data.summaries.push({
|
|
||||||
text: summarizeResult.data,
|
|
||||||
chatMemos: new Set(toSummarize.map((chat) => chat.memo)),
|
|
||||||
isImportant: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
currentTokens -= toSummarizeTokens;
|
currentTokens -= toSummarizeTokens;
|
||||||
startIdx = endIdx;
|
startIdx = endIdx;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user