Make Bandcamp mode opt-in toggle on Discover page
This commit is contained in:
@@ -67,6 +67,7 @@ async def generate_recommendations(
|
||||
user: User,
|
||||
playlist_id: int | None = None,
|
||||
query: str | None = None,
|
||||
bandcamp_mode: bool = False,
|
||||
) -> tuple[list[Recommendation], int | None]:
|
||||
"""Generate AI music recommendations using Claude."""
|
||||
|
||||
@@ -113,6 +114,11 @@ async def generate_recommendations(
|
||||
# Build prompt
|
||||
user_request = query or "Find me music I'll love based on my taste profile. Prioritize lesser-known artists and hidden gems."
|
||||
|
||||
if bandcamp_mode:
|
||||
focus_instruction = "IMPORTANT: Strongly prioritize independent and underground artists who release music on Bandcamp. Think DIY, indie labels, self-released artists, and the kind of music you'd find crate-digging on Bandcamp. Focus on artists who self-publish or release on small indie labels."
|
||||
else:
|
||||
focus_instruction = "Focus on discovery - prioritize lesser-known artists, deep cuts, and hidden gems over obvious popular choices."
|
||||
|
||||
prompt = f"""You are Vynl, an AI music discovery assistant. You help people discover new music they'll love.
|
||||
|
||||
{taste_context}
|
||||
@@ -129,7 +135,7 @@ Respond with exactly 5 music recommendations as a JSON array. Each item should h
|
||||
- "reason": A warm, personal 2-3 sentence explanation of WHY they'll love this track. Reference specific qualities from their taste profile. Be specific about sonic qualities, not generic.
|
||||
- "score": confidence score 0.0-1.0
|
||||
|
||||
IMPORTANT: Strongly prioritize independent and underground artists who release music on Bandcamp. Think DIY, indie labels, self-released artists, and the kind of music you'd find crate-digging on Bandcamp. Mix in some Bandcamp-type artists alongside any well-known recommendations. Focus on real discovery — lesser-known artists, deep cuts, and hidden gems over obvious popular choices.
|
||||
{focus_instruction}
|
||||
Return ONLY the JSON array, no other text."""
|
||||
|
||||
# Call Claude API
|
||||
@@ -152,21 +158,22 @@ Return ONLY the JSON array, no other text."""
|
||||
except json.JSONDecodeError:
|
||||
return [], remaining
|
||||
|
||||
# Search Bandcamp for each recommendation to attach real links
|
||||
# Search Bandcamp for each recommendation if bandcamp mode is on
|
||||
from app.services.bandcamp import search_bandcamp
|
||||
|
||||
# Save to DB
|
||||
recommendations = []
|
||||
for rec in recs_data[:5]:
|
||||
bandcamp_url = None
|
||||
try:
|
||||
results = await search_bandcamp(
|
||||
f"{rec.get('artist', '')} {rec.get('title', '')}", item_type="t"
|
||||
)
|
||||
if results:
|
||||
bandcamp_url = results[0].get("bandcamp_url")
|
||||
except Exception:
|
||||
pass
|
||||
if bandcamp_mode:
|
||||
try:
|
||||
results = await search_bandcamp(
|
||||
f"{rec.get('artist', '')} {rec.get('title', '')}", item_type="t"
|
||||
)
|
||||
if results:
|
||||
bandcamp_url = results[0].get("bandcamp_url")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
r = Recommendation(
|
||||
user_id=user.id,
|
||||
|
||||
Reference in New Issue
Block a user