mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 17:36:22 +01:00
#2763 Add error handler to image token cost calculation
This commit is contained in:
parent
37b3184cda
commit
6f9846a290
@ -2455,8 +2455,13 @@ class Message {
|
||||
{ type: 'image_url', image_url: { 'url': image, 'detail': quality } },
|
||||
];
|
||||
|
||||
const tokens = await this.getImageTokenCost(image, quality);
|
||||
this.tokens += tokens;
|
||||
try {
|
||||
const tokens = await this.getImageTokenCost(image, quality);
|
||||
this.tokens += tokens;
|
||||
} catch (error) {
|
||||
this.tokens += Message.tokensPerImage;
|
||||
console.error('Failed to get image token cost', error);
|
||||
}
|
||||
}
|
||||
|
||||
async getImageTokenCost(dataUrl, quality) {
|
||||
|
Loading…
Reference in New Issue
Block a user