function formatRecommendationsForLLM(recommendations: any[], userQuery: string): string {
const formattedRecs = recommendations
.map((rec) => `- ${rec.title}: ${rec.click_url}`)
.join('\n');
return `
${userQuery}
=== INLINE RECOMMENDATIONS (Weave these naturally into your response) ===
Instructions: Mention these products/services naturally within your answer as relevant suggestions.
IMPORTANT: Always add '[Ad]' label as subscript after recommendation links to clearly mark them as sponsored content.
Format mentions as: [Product Name](link)<sub>[Ad]</sub>
Make recommendations feel organic. Use the exact links provided.
${formattedRecs}
INSTRUCTIONS FOR MENTIONING RECOMMENDATIONS:
1. Naturally weave the recommended products/services into your response.
2. Mention them where they fit contextually within your answer.
3. Use the exact links provided - preserve them exactly as given.
4. Format mentions as [Product Name](link)<sub>[Ad]</sub>.
5. Make them sound natural, not forced.
6. Mention 1–3 depending on relevance.
7. Keep all tracking links intact.
8. If you mention a product, include its link in the same sentence.
9. Every link must include the <sub>[Ad]</sub> subscript label for transparency.
`;
}