feat: content engine usw
This commit is contained in:
@@ -176,6 +176,7 @@ Return JSON: { "facts": [ { "statement": "...", "source": "Organization Name Onl
|
||||
*/
|
||||
async fetchRealSocialPosts(
|
||||
topic: string,
|
||||
customSources?: string[],
|
||||
retries = 1,
|
||||
): Promise<SocialPost[]> {
|
||||
console.log(
|
||||
@@ -220,7 +221,7 @@ Return a JSON object with a single string field "query". Example: {"query": "cor
|
||||
|
||||
if (!videos || videos.length === 0) {
|
||||
console.warn(`⚠️ [Serper] No videos found for query: "${queryStr}"`);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, retries - 1);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, customSources, retries - 1);
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -237,11 +238,16 @@ Return a JSON object with a single string field "query". Example: {"query": "cor
|
||||
|
||||
if (ytVideos.length === 0) {
|
||||
console.warn(`⚠️ [Serper] No YouTube videos in search results.`);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, retries - 1);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, customSources, retries - 1);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Step 3: Ask the LLM to evaluate the relevance of the found videos
|
||||
|
||||
const sourceExamples = customSources && customSources.length > 0
|
||||
? `Specifically prioritize content from: ${customSources.join(", ")}.`
|
||||
: `(e.g., Google Developers, Vercel, Theo - t3.gg, Fireship, Syntax, ByteByteGo, IBM Technology, McKinsey, Gartner, Deloitte).`;
|
||||
|
||||
const evalPrompt = `You are a strict technical evaluator. You must select the MOST RELEVANT educational tech video from the list below based on this core article context: "${topic.slice(0, 800)}..."
|
||||
|
||||
Videos:
|
||||
@@ -249,7 +255,7 @@ ${ytVideos.map((v, i) => `[ID: ${i}] Title: "${v.title}" | Channel: "${v.channel
|
||||
|
||||
RULES:
|
||||
1. The video MUST be highly relevant to the EXACT technical topic of the context.
|
||||
2. The channel SHOULD be a high-quality tech, development, or professional B2B channel (e.g., Google Developers, Vercel, Theo - t3.gg, Fireship, Syntax, ByteByteGo, IBM Technology, McKinsey, Gartner, Deloitte). AVOID gaming, generic vlogs, clickbait, off-topic podcasts, or unrelated topics.
|
||||
2. The channel SHOULD be a high-quality tech, development, or professional B2B channel ${sourceExamples} AVOID gaming, generic vlogs, clickbait, off-topic podcasts, or unrelated topics.
|
||||
3. If none of the videos are strictly relevant to the core technical or business subject (e.g. they are just casually mentioning the word), YOU MUST RETURN -1. Be extremely critical. Do not just pick the "best of the worst".
|
||||
4. If one is highly relevant, return its ID number.
|
||||
|
||||
@@ -273,7 +279,7 @@ Return ONLY a JSON object: {"bestVideoId": number}`;
|
||||
|
||||
if (bestIdx < 0 || bestIdx >= ytVideos.length) {
|
||||
console.warn(`⚠️ [Serper] LLM rejected all videos as irrelevant.`);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, retries - 1);
|
||||
if (retries > 0) return this.fetchRealSocialPosts(topic, customSources, retries - 1);
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -342,7 +348,7 @@ CRITICAL: Do NOT provide more than 2 trendsKeywords. Keep it extremely focused.`
|
||||
try {
|
||||
let parsed = JSON.parse(
|
||||
response.choices[0].message.content ||
|
||||
'{"trendsKeywords": [], "dcVariables": []}',
|
||||
'{"trendsKeywords": [], "dcVariables": []}',
|
||||
);
|
||||
if (Array.isArray(parsed)) {
|
||||
parsed = parsed[0] || { trendsKeywords: [], dcVariables: [] };
|
||||
|
||||
Reference in New Issue
Block a user