check if photo already downloaded
This commit is contained in:
@@ -36,15 +36,15 @@ export class OllamaChat extends ChatCommand {
|
|||||||
|
|
||||||
const maxSize = await getPhotoMaxSize(msg.photo);
|
const maxSize = await getPhotoMaxSize(msg.photo);
|
||||||
if (maxSize) {
|
if (maxSize) {
|
||||||
const res = await axios.get<ArrayBuffer>(maxSize.url, {responseType: "arraybuffer"});
|
|
||||||
const src = Buffer.from(res.data);
|
|
||||||
|
|
||||||
const imagePath = path.join(Environment.DATA_PATH, "temp");
|
const imagePath = path.join(Environment.DATA_PATH, "temp");
|
||||||
if (!fs.existsSync(imagePath)) {
|
if (!fs.existsSync(imagePath)) {
|
||||||
fs.mkdirSync(imagePath);
|
fs.mkdirSync(imagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
imageFilePath = path.join(imagePath, maxSize.unique_file_id + ".jpg");
|
imageFilePath = path.join(imagePath, maxSize.unique_file_id + ".jpg");
|
||||||
|
if (!fs.existsSync(imageFilePath)) {
|
||||||
|
const res = await axios.get<ArrayBuffer>(maxSize.url, {responseType: "arraybuffer"});
|
||||||
|
const src = Buffer.from(res.data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(imageFilePath, src);
|
fs.writeFileSync(imageFilePath, src);
|
||||||
@@ -53,6 +53,7 @@ export class OllamaChat extends ChatCommand {
|
|||||||
imageFilePath = null;
|
imageFilePath = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const messageParts = await collectReplyChainText(msg);
|
const messageParts = await collectReplyChainText(msg);
|
||||||
console.log("MESSAGE PARTS", messageParts);
|
console.log("MESSAGE PARTS", messageParts);
|
||||||
|
|||||||
+5
-1
@@ -126,7 +126,11 @@ if (Environment.GEMINI_API_KEY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log(`TEST_ENVIRONMENT: ${Environment.TEST_ENVIRONMENT}\nDATA_PATH: ${Environment.DATA_PATH}`);
|
console.log(
|
||||||
|
`TEST_ENVIRONMENT: ${Environment.TEST_ENVIRONMENT}\n` +
|
||||||
|
`DATA_PATH: ${Environment.DATA_PATH}\n` + `
|
||||||
|
MAX_PHOTO_SIZE: ${Environment.MAX_PHOTO_SIZE}`
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
|
|||||||
Reference in New Issue
Block a user