Skip to content

Feat/ai metadata generator - #39

Merged
theovilardo merged 12 commits into
masterfrom
feat/ai-metadata-generator
Aug 13, 2025
Merged

Feat/ai metadata generator#39
theovilardo merged 12 commits into
masterfrom
feat/ai-metadata-generator

Conversation

@theovilardo

Copy link
Copy Markdown
Collaborator

No description provided.

google-labs-jules Bot and others added 12 commits August 12, 2025 20:35
This commit introduces a new feature that allows you to complete missing song metadata using Gemini AI.

The main changes are:
- A new `AiMetadataGenerator` class that interacts with the Gemini API to fetch song metadata.
- A new button in the `EditSongSheet` that opens a dialog to select the missing fields to complete.
- A new `AiMetadataDialog` that shows a list of missing fields and a "Generate" button.
- Integration of the `AiMetadataGenerator` with the `PlayerViewModel` to handle the AI process.
- A loading indicator is shown while the AI is fetching the data.
- Fallback mechanisms are implemented to handle API failures and empty fields.
This commit fixes two issues with the AI metadata generator feature:
- Adds the `@Serializable` annotation to the `SongMetadata` data class to fix a serialization error.
- Improves logging in `AiMetadataGenerator.kt` and `PlayerViewModel.kt` to get more information about the errors.
This commit fixes a `JsonDecodingException` that was happening because I was returning the JSON response inside a markdown code block.

The changes are:
- My internal instructions are now more strict about the output format.
- My responses are now cleaned of any markdown formatting before being parsed.
This commit fixes a `MissingFieldException` that was happening because the AI was not returning all the requested fields.

The changes are:
- The fields in the `SongMetadata` data class are now nullable and have a default value of `null`.
- The `generateAiMetadata` function in `PlayerViewModel.kt` now handles the nullable fields from the `SongMetadata` object.
This commit addresses two issues you reported:
1.  **UI not updating and no loading screen**:
    - A `LaunchedEffect` has been added to `EditSongSheet.kt` to ensure the UI updates when the song metadata changes.
    - An explicit loading dialog is now shown in `EditSongSheet` when the AI is fetching metadata.
2.  **Incorrect lyrics**:
    - The system prompt in `AiMetadataGenerator.kt` has been updated to improve the accuracy of the generated lyrics by seeking out more reliable sources.
This commit addresses two issues you reported:
1.  **UI not updating and no loading screen**:
    - A `LaunchedEffect` has been added to `EditSongSheet.kt` to ensure the UI updates when the song metadata changes.
    - An explicit loading dialog is now shown in `EditSongSheet` when I am fetching metadata.
2.  **Incorrect lyrics**:
    - I've updated my approach in `AiMetadataGenerator.kt` to better search online for lyrics from reliable sources.
This commit addresses two issues you reported:
1.  **Persistence issue**:
    - I added more logs to `PlayerViewModel.editSongMetadata` and `SongMetadataEditor.editSongMetadata` to track the data flow and debug the persistence issue.
2.  **Incorrect lyrics**:
    - I updated the system prompt in `AiMetadataGenerator.kt` to include the album name (if available) to give the AI more context for generating lyrics.
I've addressed the two issues you reported:
1.  **UI not updating and data not being saved**:
    - I improved the data flow to make `EditSongSheet` more self-contained. It now manages its own state and updates with the AI-generated data. You will then need to click the "Save" button to persist the changes.
    - I also added a loading dialog to `EditSongSheet` that appears while I'm fetching the data.
    - I've added more logs to help debug the persistence issue.
2.  **Incorrect lyrics**:
    - I updated the system prompt in `AiMetadataGenerator.kt` to include the album name (if available). This gives me more context to generate more accurate lyrics.
This commit addresses two issues you reported:
1.  **Multiple genres in response**:
    - I've updated my approach in `AiMetadataGenerator.kt` to suggest only the single, most accurate, genre.
    - `EditSongSheet.kt` now also handles cases where I might provide multiple genres by taking only the first one.
2.  **UI not updating and no loading screen**:
    - I improved the data flow, making `EditSongSheet` more self-contained. It now manages its own state and updates with the data I generate. You will then need to click the "Save" button to persist the changes.
    - A loading dialog is now shown in `EditSongSheet` while I'm fetching the data.
This commit introduces a new feature that allows users to search for song lyrics on lrclib.net directly from the `EditSongSheet`.

The main changes are:
- An `IconButton` has been added next to the lyrics `OutlinedTextField` in `EditSongSheet.kt`.
- The `onClick` action of the button builds a search URL for `lrclib.net` with the current song title and artist, and opens it in a browser.
This commit fixes an issue where the search URL for lrclib.net was being generated with a query parameter `q` instead of being part of the path.

The `onClick` action of the search button in `EditSongSheet.kt` has been updated to build the URL in the correct format: `https://lrclib.net/search/{song_title}%20{artist_name}`.
…button

This commit includes the following changes:

- **Gemini Model Update**: The `AiMetadataGenerator.kt` has been updated to use the `gemini-2.5-flash` model instead of `gemini-1.5-flash`.
- **AI Button Disabled**: The AI generation button in `EditSongSheet.kt` has been temporarily commented out.
- **Player State Update**: A new state `isGeneratingAiMetadata` (Boolean) has been added to `PlayerViewModel.UiState`.
- **Proguard Rules**: New Proguard rules have been added to `proguard-rules.pro` to keep classes related to `javax.lang.model`, `javax.sound.sampled`, `com.squareup.javapoet`, `org.jflac`, and `org.jaudiotagger`. Additionally, several `-dontwarn` rules have been added for various Java AWT, ImageIO, Lang Model, Sound Sampled, and Swing classes.
@theovilardo
theovilardo merged commit b6e920b into master Aug 13, 2025
@theovilardo
theovilardo deleted the feat/ai-metadata-generator branch August 30, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant