Skip to content

Commit 60e4273

Browse files
committed
fix(chat): include youtube field in search tool and prevent placeholder URLs
1 parent b6ee13c commit 60e4273

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎apps/site/src/lib/sanity/queries/search.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const semanticSearchQuery = defineQuery(`
2424
"slug": slug.current,
2525
"excerpt": coalesce(excerpt, transcript->summary),
2626
"transcriptSummary": transcript->summary,
27+
"youtube": coalesce(youtube, listenLinks.youtube, transcript->youtubeUrl),
2728
coverImage,
2829
date,
2930
_score
@@ -57,6 +58,7 @@ export const textSearchFallbackQuery = defineQuery(`
5758
"slug": slug.current,
5859
"excerpt": coalesce(excerpt, transcript->summary),
5960
"transcriptSummary": transcript->summary,
61+
"youtube": coalesce(youtube, listenLinks.youtube, transcript->youtubeUrl),
6062
coverImage,
6163
date,
6264
_score

‎apps/site/src/pages/api/chat.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export const POST: APIRoute = async ({ request }) => {
208208
slug: item.slug,
209209
url: `/${item._type === "podcast" ? "podcast" : item._type === "post" ? "post" : item._type}/${item.slug}`,
210210
excerpt: item.excerpt || item.transcriptSummary || "",
211+
youtube: item.youtube || undefined,
211212
}));
212213
},
213214
}),
@@ -398,7 +399,7 @@ export const POST: APIRoute = async ({ request }) => {
398399
"- When asked for 'top videos' or popular video podcasts, search for high-profile episodes with video recordings (e.g. episodes featuring Guillermo Rauch, Rich Harris, Lee Robinson, or recent GenAI/MCP video podcasts) and provide their YouTube links alongside CodingCat.dev episode links.\n" +
399400
"- Use `groq_query` for precise lookups when searching for specific author profiles (e.g. *[_type == 'author' && title match '*Alex*']).\n" +
400401
"- CRITICAL: ALWAYS execute tools by invoking them via function calls. NEVER output raw JSON or code blocks in your text describing tool calls instead of executing them.\n" +
401-
'- Once you receive results from your tool calls, synthesize them into an engaging, helpful response. List the relevant episode or article titles, brief descriptions, and markdown links using relative paths (e.g. [Episode Title](/podcast/slug) or [Post Title](/post/slug)). When YouTube links are available, always include them directly on their own line (e.g. https://www.youtube.com/watch?v=VIDEO_ID or https://youtu.be/VIDEO_ID). NEVER output localhost URLs, internal IP addresses, or malformed URL brackets like ["/slug"](http://localhost:3000/slug).',
402+
'- Once you receive results from your tool calls, synthesize them into an engaging, helpful response. List the relevant episode or article titles, brief descriptions, and markdown links using relative paths (e.g. [Episode Title](/podcast/slug) or [Post Title](/post/slug)). When an exact YouTube URL is present in the tool results (e.g. item.youtube), include that exact URL on its own line (e.g. https://www.youtube.com/watch?v=VIDEO_ID or https://youtu.be/VIDEO_ID). NEVER invent placeholder strings like "https://www.youtube.com/watch?v=VIDEO_ID", localhost URLs, or malformed URL brackets like ["/slug"](http://localhost:3000/slug).',
402403
messages: coreMessages,
403404
tools,
404405
stopWhen: isStepCount(5),

0 commit comments

Comments
 (0)