move max_photo_size to environment variable

This commit is contained in:
2026-01-12 19:41:40 +03:00
parent 8fbc8e43db
commit 123bda888f
3 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ export class OllamaChat extends ChatCommand {
let imageFilePath: string | null = null;
const maxSize = await getPhotoMaxSize(msg.photo, 600);
const maxSize = await getPhotoMaxSize(msg.photo);
if (maxSize) {
const res = await axios.get<ArrayBuffer>(maxSize.url, {responseType: "arraybuffer"});
const src = Buffer.from(res.data);
+4
View File
@@ -22,6 +22,8 @@ export class Environment {
static OLLAMA_API_KEY?: string;
static SYSTEM_PROMPT?: string;
static MAX_PHOTO_SIZE: number;
static GEMINI_API_KEY?: string;
static waitText = "⏳ Дайте-ка подумать...";
@@ -45,6 +47,8 @@ export class Environment {
Environment.OLLAMA_API_KEY = process.env.OLLAMA_API_KEY;
Environment.SYSTEM_PROMPT = process.env.SYSTEM_PROMPT?.trim();
Environment.MAX_PHOTO_SIZE = Number(process.env.MAX_PHOTO_SIZE || "1280");
Environment.GEMINI_API_KEY = process.env.GEMINI_API_KEY;
}
+1 -1
View File
@@ -754,7 +754,7 @@ export function getRuntimeInfo(): RuntimeInfo {
export type PhotoMaxSize = { width: number, height: number, url: string; unique_file_id: string; };
export async function getPhotoMaxSize(photos: PhotoSize[], target: number = 1280): Promise<PhotoMaxSize | null> {
export async function getPhotoMaxSize(photos: PhotoSize[], target: number = Environment.MAX_PHOTO_SIZE): Promise<PhotoMaxSize | null> {
if (!photos) return null;
photos = photos.filter(p => Math.max(p.width, p.height) <= target);