mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
More accurate token estimates
This commit is contained in:
@@ -160,9 +160,13 @@
|
|||||||
|
|
||||||
// Get an estimate of the total prompt size we're sending
|
// Get an estimate of the total prompt size we're sending
|
||||||
const promptTokenCount:number = filtered.reduce((a, m) => {
|
const promptTokenCount:number = filtered.reduce((a, m) => {
|
||||||
a += encode(m.content).length + 8 // + 8, always seems to under count by around 8
|
// Not sure how OpenAI formats it, but this seems to get close to the right counts
|
||||||
|
// Sure would be nice to know
|
||||||
|
a += encode('## ' + m.role + " ##:\r\n\r\n" + m.content + "\r\n\r\n\r\n").length
|
||||||
return a
|
return a
|
||||||
}, 0)
|
}, 0) + 3
|
||||||
|
|
||||||
|
// console.log('Estimated',promptTokenCount,'prompt token for this request')
|
||||||
|
|
||||||
if (chatSettings.useSummarization &&
|
if (chatSettings.useSummarization &&
|
||||||
!withSummary && !doingSummary &&
|
!withSummary && !doingSummary &&
|
||||||
|
|||||||
Reference in New Issue
Block a user