ibrohm commited on
Commit
b0dcff5
·
1 Parent(s): e546c83

fix(ai): Fix banner aspect ratio to match android perfectly and remove generic banner tags from gemini prompt

Browse files
Files changed (1) hide show
  1. bot/bot.js +12 -11
bot/bot.js CHANGED
@@ -34,22 +34,23 @@ function downloadImage(url) {
34
  });
35
  }
36
 
37
- // AI yordamida (Gemini) promptni professional darajada kengaytirish
38
  async function enhancePromptWithGemini(userText, templateBase = '') {
39
  if (!process.env.GEMINI_API_KEY) {
40
- return (templateBase ? templateBase + ', ' : '') + userText + ', professional advertising banner, highly detailed';
41
  }
42
  try {
43
  const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
44
  const prompt = `You are an expert AI image prompt engineer for an e-commerce platform.
45
- The user wants to generate an advertising banner but they are writing in Uzbek and might have typos.
46
- CRITICAL RULE: Always interpret the words in the context of FASHION, CLOTHING, TECH, or E-COMMERCE. For example, if they write "manti", "mantiani", or "mantiya", they mean "graduation gown", "mantle", "coat", or "cloak" (clothing), ABSOLUTELY NOT the food (dumplings).
47
 
48
- Step 1: Understand their intent and correct any typos to fit fashion/electronic/event themes.
49
- Step 2: Convert the idea into a highly detailed, professional, comma-separated English prompt for a text-to-image AI (like Flux or Midjourney).
50
- Step 3: Ensure it describes the visual elements beautifully. Include stylistic tags like: wide landscape banner, professional advertising photography, cinematic lighting, photorealistic, 8k resolution, highly detailed, beautiful faces, modern, no text on image.
 
51
 
52
- Template Context (if any): ${templateBase || 'None'}
53
  User's Idea: "${userText}"
54
 
55
  Respond ONLY with the final English prompt string, and nothing else.`;
@@ -57,7 +58,7 @@ Respond ONLY with the final English prompt string, and nothing else.`;
57
  return result.response.text().trim();
58
  } catch (e) {
59
  console.error("Gemini error:", e);
60
- return (templateBase ? templateBase + ', ' : '') + userText + ', professional advertising banner, cinematic lighting, photorealistic';
61
  }
62
  }
63
 
@@ -805,8 +806,8 @@ if (process.env.BOT_TOKEN && process.env.BOT_TOKEN !== 'YOUR_TELEGRAM_BOT_TOKEN'
805
  const encoded = encodeURIComponent(finalPrompt);
806
 
807
  // Hozirgi eng maxsus fotorealistik model: FLUX va Flux-Realism (turli qiyofa va xato oldini olish uchun)
808
- const url1 = `https://image.pollinations.ai/prompt/${encoded}?width=1024&height=512&seed=${ts1}&nologo=true&model=flux`;
809
- const url2 = `https://image.pollinations.ai/prompt/${encoded}?width=1024&height=512&seed=${ts2}&nologo=true&model=flux-realism`;
810
 
811
  await ctx.reply('⏳ Gemini promptni kengaytirib, Flux 2 ta variant yaratmoqda... (Kuting, 20-40 soniya)');
812
 
 
34
  });
35
  }
36
 
37
+ // AI yordamida (Gemini) promptni professional kengaytirish
38
  async function enhancePromptWithGemini(userText, templateBase = '') {
39
  if (!process.env.GEMINI_API_KEY) {
40
+ return (templateBase ? templateBase + ', ' : '') + userText + ', photorealistic, detailed';
41
  }
42
  try {
43
  const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
44
  const prompt = `You are an expert AI image prompt engineer for an e-commerce platform.
45
+ The user wants to generate a banner image, but they write in Uzbek and might have typos.
46
+ CRITICAL RULE: Interpret words in FASHION, CLOTHING, TECH, or E-COMMERCE contexts. E.g., if they write "manti", "mantiani", or "mantiya", they mean "graduation gown", "coat", or "mantle" (clothing), NEVER the food (dumplings).
47
 
48
+ Step 1: Understand their intent and correct typos.
49
+ Step 2: Convert the idea into a clean, highly descriptive English prompt for Midjourney/Flux.
50
+ Step 3: Keep it heavily focused on the SUBJECT. DO NOT add generic tags like "banner" or "advertising" that ruin the immersion. Just describe the scene, the models, the clothes, and the environment. Add: ", photorealistic, cinematic, highly detailed, no text".
51
+ Example Output: "A handsome male student and a beautiful female student wearing elegant graduation gowns, evening graduation party, cinematic lighting, photorealistic, no text"
52
 
53
+ Template Context: ${templateBase || 'None'}
54
  User's Idea: "${userText}"
55
 
56
  Respond ONLY with the final English prompt string, and nothing else.`;
 
58
  return result.response.text().trim();
59
  } catch (e) {
60
  console.error("Gemini error:", e);
61
+ return userText + ', photorealistic, no text';
62
  }
63
  }
64
 
 
806
  const encoded = encodeURIComponent(finalPrompt);
807
 
808
  // Hozirgi eng maxsus fotorealistik model: FLUX va Flux-Realism (turli qiyofa va xato oldini olish uchun)
809
+ const url1 = `https://image.pollinations.ai/prompt/${encoded}?width=1024&height=430&seed=${ts1}&nologo=true&model=flux`;
810
+ const url2 = `https://image.pollinations.ai/prompt/${encoded}?width=1024&height=430&seed=${ts2}&nologo=true&model=flux-realism`;
811
 
812
  await ctx.reply('⏳ Gemini promptni kengaytirib, Flux 2 ta variant yaratmoqda... (Kuting, 20-40 soniya)');
813