Commit 4d1f15ee authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Switch all Gemini calls from 2.5-flash to 3.7-flash

Genre fallback (music.py), Discovery's AI identification (music_identification.py),
remix planning (remix_engine.py), and the Telegram bot's remix recipe parser
(ai_remix.py) all move to the current flash model. Verified gemini-3.7-flash is a
real, listed model for this API key via a live generateContent call before
switching (returned a transient 503 "high demand" on first probe, not a 429/403
access-denial - confirmed the key itself is fine with a control call against the
old model in the same window).
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent b1f5d610
Pipeline #1140 passed with stage
in 6 minutes and 29 seconds
...@@ -123,7 +123,7 @@ async def _identify_tag_and_store( ...@@ -123,7 +123,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-2.5-flash') model = genai.GenerativeModel('gemini-3.7-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(model.generate_content, prompt) response = await asyncio.to_thread(model.generate_content, prompt)
raw_text = response.text.strip() raw_text = response.text.strip()
......
...@@ -98,7 +98,7 @@ async def identify_with_gemini(file_path: str, lang_pref: str) -> dict: ...@@ -98,7 +98,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-2.5-flash', generation_config={"response_mime_type": "application/json"}) model = genai.GenerativeModel('gemini-3.7-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."
......
...@@ -192,18 +192,18 @@ async def plan_remix(prompt: str, songs_info: list) -> dict: ...@@ -192,18 +192,18 @@ async def plan_remix(prompt: str, songs_info: list) -> dict:
pitch target, sidechain routing, and a style preset - not just "pick some stems and slap pitch target, sidechain routing, and a style preset - not just "pick some stems and slap
reverb on it". reverb on it".
gemini-2.5-pro would reason about structure better than flash, but this API key's free A pro-tier model would likely reason about structure better than flash, but this API
tier has a hard zero quota for -pro (confirmed via a live 429: "limit: 0" - not key's free tier had a hard zero quota for gemini-2.5-pro (confirmed via a live 429:
exhausted, actually zero allocation), so flash is what's actually usable here. The "limit: 0" - not exhausted, actually zero allocation) - not re-verified for the current
"refinement" is in the prompt itself: real audio previews of every song, real detected 3.7 generation, so flash remains what's actually used here. The "refinement" is in the
BPM/key data instead of guesses, and an explicit schema for structure/harmony/sidechain/ prompt itself: real audio previews of every song, real detected BPM/key data instead of
style that flash is quite capable of following even if it reasons less deeply than pro guesses, and an explicit schema for structure/harmony/sidechain/style that flash is quite
would.""" capable of following even if it reasons less deeply than pro would."""
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( model = genai.GenerativeModel(
"gemini-2.5-flash", generation_config={"response_mime_type": "application/json"} "gemini-3.7-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-2.5-flash', generation_config={"response_mime_type": "application/json"}) model = genai.GenerativeModel('gemini-3.7-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