Skip to content

ai parsing - #105

Merged
MohanEhab merged 1 commit into
developfrom
feature/ai-chatbot
May 3, 2026
Merged

MohanEhab merged 1 commit into
developfrom
feature/ai-chatbot

Conversation

@MohanEhab

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 3, 2026 01:52
@MohanEhab
MohanEhab merged commit d91d8e1 into develop May 3, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the mock AI intent parsing and genre handling so that “best/top N …” and many genre phrases are routed to recommend_by_genre, and shifts genre-based playlist creation/recommendations to use DB-backed public track search rather than the Discovery “trending by genre” endpoint.

Changes:

  • Expanded genre phrase detection in the mock AI provider and added new recommend_by_genre routing for “best/top N … tracks/songs/music”.
  • Updated AiActionService genre search term generation to include DB genre lookups and variants, and switched playlist-from-genre creation to reuse the public track finder.
  • Updated/expanded unit tests to cover the new parsing and DB-backed genre term behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/ai/providers/mock-ai.provider.ts Adds new genre terms + stricter token matching, introduces new “best/top N …” → recommend_by_genre routing, and adds freeform genre phrase extraction.
src/ai/ai.service.spec.ts Updates tests to reflect recommend_by_genre becoming the default for “find <genre> tracks” cases and adds more genre parsing coverage.
src/ai/ai-action.service.ts Switches playlist-from-genre to DB-backed findPublicTracksByGenre, makes genreSearchTerms async with DB lookups + variants, and adjusts replies.
src/ai/ai-action.service.spec.ts Adds Prisma mocks and new tests asserting DB genre lookup behavior, alias separation, and playlist creation behavior when no tracks exist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +493 to +494
? `Created "${playlist.title}" with ${tracks.length} ${genre} track${tracks.length === 1 ? '' : 's'}. I found fewer public finished tracks than the ${limit} requested.`
: `Created "${playlist.title}" with ${tracks.length} ${genre} track${tracks.length === 1 ? '' : 's'}${allRequested ? `, capped at ${tracks.length}.` : '.'}`,
Comment on lines +1266 to +1278
const localTerms = Array.from(
new Set([normalized, ...this.genreTermVariants(normalized), ...aliasTerms]),
).filter(Boolean);
const dbGenres = await this.prisma.genre.findMany({
where: {
OR: localTerms.flatMap((term) => [
{ slug: { contains: term, mode: 'insensitive' as const } },
{ name: { contains: term, mode: 'insensitive' as const } },
]),
},
select: { slug: true, name: true },
take: 10,
});
Comment on lines +154 to +160
if (/(find|show|get|recommend|suggest).*(best|top|\d+).*(tracks?|songs?|music)/i.test(msg)) {
const genre = extractGenre(msg);
if (genre !== 'mixed') {
return {
intent: 'recommend_by_genre',
parameters: { genre, limit: extractLimit(msg, 5) },
confidence: 0.88,
Comment on lines +322 to +329
const genre = extractGenre(query);
if (genre !== 'mixed') {
return {
intent: 'recommend_by_genre',
parameters: { genre, limit: extractLimit(msg, 5) },
confidence: 0.88,
needsConfirmation: false,
};
Comment on lines 104 to 115
'rnb',
'r&b',
'hip hop',
'hip-hop',
'hiphop',
'electronic',
'classical',
'arabic',
'country',
'folk singer songwriter',
'folk',
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants