""" Analysis tools for understanding and interpreting song lyrics. """ import os from loguru import logger from smolagents import tool from api_utils import make_api_call_with_retry @tool def analyze_lyrics_tool(song_title: str, artist: str, lyrics: str) -> str: """ Performs a deep analysis of the musical track, given its metadata. Args: song_title: Title of the song or music track. artist: The name of the artist. lyrics: The lyrics of the song. Returns: A summary of the song's meaning in English. """ prompt = f"""You are an expert in songs and their meanings. Summarize the meaning of {song_title} by {artist} and identify key themes based on the lyrics: {lyrics}. Include deep idea and vibes analysis with explanations based on references to the exact lines. """ # Determine which model to use based on configuration if os.getenv("USE_ANTHROPIC", "false").lower() == "true": model_to_use = "claude-3-haiku-20240307" logger.info("Using Anthropic model: {} for lyrics analysis", model_to_use) else: model_to_use = "gemini/gemini-2.0-flash" logger.info("Using Gemini model: {} for lyrics analysis", model_to_use) # Use the function with retry mechanism logger.info("Analyzing lyrics for song: '{}' by '{}'", song_title, artist) return make_api_call_with_retry(model_to_use, prompt)