fix(images): cache Telegram photos by unique_id and pass base64 to LLM commands
Stop reading image files inside gemini/mistral commands; use pre-encoded image data from message parts Rework loadImagesIfExists / loadImagesFromFileIds to return cached file_unique_ids and download only missing sizes Encode cached images to base64 when assembling the reply chain Make getPhotoMaxSize synchronous (returns PhotoSize), and map to URL only when needed Await MessageStore.put / UserStore.put and prefetch single-image downloads on message receipt
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
oldReplyToMessage,
|
||||
startIntervalEditor
|
||||
} from "../util/utils";
|
||||
import fs from "node:fs";
|
||||
|
||||
export class GeminiChat extends ChatCommand {
|
||||
command = "gemini";
|
||||
@@ -66,10 +65,9 @@ export class GeminiChat extends ChatCommand {
|
||||
const images = messageParts[0].images;
|
||||
|
||||
images.forEach(image => {
|
||||
const base64Image = Buffer.from(fs.readFileSync(image)).toString("base64");
|
||||
input.push({
|
||||
type: "image",
|
||||
data: base64Image,
|
||||
data: image,
|
||||
mime_type: "image/png"
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user