A simple tool which lets you scrape twitter accounts and crosspost them to bluesky accounts! Comes with a CLI and a webapp for managing profiles! Works with images/videos/link embeds/threads.

feat: improve gemini alt text with tweet context

jack 02445ab6 c595dd08

+9 -12
+9 -12
src/index.ts
··· 18 18 19 19 // ... existing code ... 20 20 21 - async function generateAltText(buffer: Buffer, mimeType: string): Promise<string | undefined> { 21 + async function generateAltText(buffer: Buffer, mimeType: string, contextText: string): Promise<string | undefined> { 22 22 const config = getConfig(); 23 - const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8'; // Fallback to provided key if not set 23 + const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8'; 24 24 25 25 if (!apiKey) return undefined; 26 26 27 27 try { 28 28 const genAI = new GoogleGenerativeAI(apiKey); 29 - const model = genAI.getGenerativeModel({ model: 'models/gemini-2.0-flash' }); // Updated to 2.0-flash as likely intended, user said 2.5 but likely meant 1.5 or 2.0. 30 - // Actually, user explicitly said "models/gemini-2.5-flash". I will try to use exactly what they said, 31 - // but if it fails I might need to fallback. 32 - // Let's stick to the prompt's request exactly first. 33 - 34 - // NOTE: 'gemini-2.5-flash' is not a standard known model at this time (Jan 2026 context). 35 - // It might be a custom fine-tune or a future preview. 36 - // I will use it as requested. 37 29 const modelRequested = genAI.getGenerativeModel({ model: 'models/gemini-2.5-flash' }); 38 30 31 + const prompt = `Describe this image for alt text. Be concise but descriptive. 32 + Context from the tweet text: "${contextText}". 33 + Use the context to identify specific people, objects, or context mentioned, but describe what is visually present in the image.`; 34 + 39 35 const result = await modelRequested.generateContent([ 40 - "Describe this image in detail for alt text. Be concise but descriptive.", 36 + prompt, 41 37 { 42 38 inlineData: { 43 39 data: buffer.toString('base64'), ··· 873 869 let altText = media.ext_alt_text; 874 870 if (!altText) { 875 871 console.log(`[${twitterUsername}] 🤖 Generating alt text via Gemini...`); 876 - altText = await generateAltText(buffer, mimeType); 872 + // Use original tweet text for context, not the modified/cleaned one 873 + altText = await generateAltText(buffer, mimeType, tweetText); 877 874 if (altText) console.log(`[${twitterUsername}] ✅ Alt text generated: ${altText.substring(0, 50)}...`); 878 875 } 879 876