Add error handling to parseTokenCounts function
This commit is contained in:
parent
a6c7a935cc
commit
63985a490d
|
@ -3208,14 +3208,14 @@ function parseTokenCounts(counts, thisPromptBits) {
|
|||
const total = Object.values(counts).filter(x => !Number.isNaN(x)).reduce((acc, val) => acc + val, 0);
|
||||
|
||||
thisPromptBits.push({
|
||||
oaiStartTokens: Object.entries(counts)[0][1],
|
||||
oaiPromptTokens: Object.entries(counts)[1][1],
|
||||
oaiBiasTokens: Object.entries(counts)[2][1],
|
||||
oaiNudgeTokens: Object.entries(counts)[3][1],
|
||||
oaiJailbreakTokens: Object.entries(counts)[4][1],
|
||||
oaiImpersonateTokens: Object.entries(counts)[5][1],
|
||||
oaiExamplesTokens: Object.entries(counts)[6][1],
|
||||
oaiConversationTokens: Object.entries(counts)[7][1],
|
||||
oaiStartTokens: Object.entries(counts)?.[0]?.[1] ?? 0,
|
||||
oaiPromptTokens: Object.entries(counts)?.[1]?.[1] ?? 0,
|
||||
oaiBiasTokens: Object.entries(counts)?.[2]?.[1] ?? 0,
|
||||
oaiNudgeTokens: Object.entries(counts)?.[3]?.[1] ?? 0,
|
||||
oaiJailbreakTokens: Object.entries(counts)?.[4]?.[1] ?? 0,
|
||||
oaiImpersonateTokens: Object.entries(counts)?.[5]?.[1] ?? 0,
|
||||
oaiExamplesTokens: Object.entries(counts)?.[6]?.[1] ?? 0,
|
||||
oaiConversationTokens: Object.entries(counts)?.[7]?.[1] ?? 0,
|
||||
oaiTotalTokens: total,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue