Repository navigation
ai parsing - #105
Merged
Merged
ai parsing#105
Conversation
There was a problem hiding this comment.
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_genrerouting for “best/top N … tracks/songs/music”. - Updated
AiActionServicegenre 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', | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.