Commit db4acbbe authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix identification silently failing: swap overloaded gemini-3.7-flash for gemini-2.5-flash

Uploads were coming back unidentified for any song Shazam couldn't
match - AcoustID's key is independently broken (unrelated, already
known), but the Gemini last-resort fallback was ALSO failing on every
call, always timing out at the configured deadline. Direct testing
against Google's API confirmed gemini-3.7-flash is currently returning
503 "experiencing high demand" and the SDK's retry loop was burning the
whole timeout before surfacing that. gemini-2.5-flash responds in
single-digit seconds for the same audio and correctly identifies songs
Shazam can't. Swapped in the 4 places that hardcoded the model name
(music identification, inline genre backfill, remix planning, and the
legacy Telegram bot's remix recipe).
parent b36805a8
Pipeline #1285 canceled with stage
...@@ -139,7 +139,7 @@ async def _identify_tag_and_store( ...@@ -139,7 +139,7 @@ async def _identify_tag_and_store(
title, artist = candidate.get("title", ""), candidate.get("artist", "") title, artist = candidate.get("title", ""), candidate.get("artist", "")
if title and artist and title != "Unknown" and artist != "Unknown": if title and artist and title != "Unknown" and artist != "Unknown":
try: try:
model = genai.GenerativeModel('gemini-3.7-flash') model = genai.GenerativeModel('gemini-2.5-flash')
prompt = f"What is the genre of the song '{title}' by '{artist}'? Reply with ONLY a single genre name (e.g. Pop, Synth-pop, Classical). Do not include any other text." prompt = f"What is the genre of the song '{title}' by '{artist}'? Reply with ONLY a single genre name (e.g. Pop, Synth-pop, Classical). Do not include any other text."
response = await asyncio.to_thread( response = await asyncio.to_thread(
model.generate_content, prompt, request_options={"timeout": 15} model.generate_content, prompt, request_options={"timeout": 15}
......
...@@ -103,7 +103,7 @@ async def identify_with_gemini(file_path: str, lang_pref: str) -> dict: ...@@ -103,7 +103,7 @@ async def identify_with_gemini(file_path: str, lang_pref: str) -> dict:
if not GEMINI_API_KEY: if not GEMINI_API_KEY:
raise Exception("GEMINI_API_KEY not configured.") raise Exception("GEMINI_API_KEY not configured.")
model = genai.GenerativeModel('gemini-3.7-flash', generation_config={"response_mime_type": "application/json"}) model = genai.GenerativeModel('gemini-2.5-flash', generation_config={"response_mime_type": "application/json"})
script_instruction = "Use standard Persian (Farsi) script for the Title and Artist." if lang_pref == "native" else "Use Finglish/English characters (transliterated) for the Title and Artist." script_instruction = "Use standard Persian (Farsi) script for the Title and Artist." if lang_pref == "native" else "Use Finglish/English characters (transliterated) for the Title and Artist."
......
...@@ -203,7 +203,7 @@ async def plan_remix(prompt: str, songs_info: list) -> dict: ...@@ -203,7 +203,7 @@ async def plan_remix(prompt: str, songs_info: list) -> dict:
raise Exception("GEMINI_API_KEY not configured.") raise Exception("GEMINI_API_KEY not configured.")
model = genai.GenerativeModel( model = genai.GenerativeModel(
"gemini-3.7-flash", generation_config={"response_mime_type": "application/json"} "gemini-2.5-flash", generation_config={"response_mime_type": "application/json"}
) )
song_lines = [] song_lines = []
......
...@@ -15,7 +15,7 @@ async def get_remix_recipe(user_prompt: str, original_title: str) -> dict: ...@@ -15,7 +15,7 @@ async def get_remix_recipe(user_prompt: str, original_title: str) -> dict:
if not GEMINI_API_KEY: if not GEMINI_API_KEY:
raise Exception("GEMINI_API_KEY not configured.") raise Exception("GEMINI_API_KEY not configured.")
model = genai.GenerativeModel('gemini-3.7-flash', generation_config={"response_mime_type": "application/json"}) model = genai.GenerativeModel('gemini-2.5-flash', generation_config={"response_mime_type": "application/json"})
prompt = f""" prompt = f"""
Analyze this user request for an audio remix: "{user_prompt}" Analyze this user request for an audio remix: "{user_prompt}"
The original song title is "{original_title}". The original song title is "{original_title}".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment