Skip to content

Fix/pyannote ollama#13

Closed
Gambitnl wants to merge 7 commits intomainfrom
fix/pyannote-ollama
Closed

Fix/pyannote ollama#13
Gambitnl wants to merge 7 commits intomainfrom
fix/pyannote-ollama

Conversation

@Gambitnl
Copy link
Copy Markdown
Owner

@Gambitnl Gambitnl commented Nov 7, 2025

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Gambitnl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's stability and user experience by addressing core issues in its processing pipeline. It introduces robust memory management for Ollama-based classification and fixes a critical embedding extraction bug in PyAnnote diarization, making these components more resilient. Furthermore, the user interface is improved with a live transcription preview and a fully functional, modern 'Characters' tab, providing users with better real-time feedback and comprehensive character management capabilities.

Highlights

  • Robust Ollama Memory Handling: Implemented a retry mechanism for the Ollama classifier to gracefully handle memory allocation errors. This includes an initial retry with low-VRAM settings and an optional fallback model, significantly improving stability on systems with limited RAM. Preflight checks now also warn users about potential memory issues based on their selected model.
  • PyAnnote Diarization Embedding Fix: Resolved a critical issue in PyAnnote 3.x diarization where embedding extraction would crash due to changes in output types (numpy arrays instead of torch tensors). A new helper function normalizes embedding outputs, and error handling ensures that individual embedding failures do not halt the entire diarization process.
  • Live Transcription Preview in UI: Introduced a live-updating preview of chunk transcriptions in the Gradio UI. During Stage 3 processing, users can now see the latest transcribed text and timing metadata, providing real-time feedback and improving visibility into the transcription progress.
  • Modern UI Character Tab Parity: The 'Characters' tab in the modern UI has been brought to feature parity with its legacy counterpart. It now includes a campaign-filtered table, character overview, import/export functionalities, and an automatic transcript extraction workflow, all integrated seamlessly with the campaign management system.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several significant improvements and bug fixes. Key changes include making PyAnnote embedding extraction more resilient to prevent crashes, adding robust memory-error handling to the Ollama classifier with low-VRAM and fallback model retries, and implementing a live transcription preview in the UI. The changes are well-tested and documented in the implementation plans. My review includes a few suggestions to improve the maintainability and robustness of the new classifier logic.

Comment thread src/classifier.py
Comment thread src/classifier.py
Comment on lines +330 to +350
def _estimate_required_memory_gb(self, model_name: str) -> Optional[int]:
model_lower = model_name.lower()
match = re.search(r"(\d+)\s*b", model_lower)
if not match:
return None
try:
size = int(match.group(1))
except (TypeError, ValueError):
return None

if size >= 20:
return 16
if size >= 14:
return 12
if size >= 10:
return 10
if size >= 7:
return 8
if size >= 5:
return 6
return None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The series of if statements to determine the required memory based on model size is not easily maintainable. If new model sizes are introduced, this logic will need to be modified. A data-driven approach would be more robust and easier to extend.

    def _estimate_required_memory_gb(self, model_name: str) -> Optional[int]:
        model_lower = model_name.lower()
        match = re.search(r"(\d+)\s*b", model_lower)
        if not match:
            return None
        try:
            size = int(match.group(1))
        except (TypeError, ValueError):
            return None

        # (size_in_b, required_ram_gb)
        ram_map = [
            (20, 16),
            (14, 12),
            (10, 10),
            (7, 8),
            (5, 6),
        ]
        for size_threshold, ram_required in ram_map:
            if size >= size_threshold:
                return ram_required
        return None

Comment thread src/classifier.py
Comment on lines +358 to +359
except Exception:
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _estimate_total_memory_gb function uses a broad except Exception: pass block when trying to estimate memory with psutil. Silently ignoring all exceptions can hide underlying issues and make debugging difficult. It would be better to log the exception at a DEBUG level to aid in troubleshooting while still allowing the function to proceed to the next estimation method.

Suggested change
except Exception:
pass
except Exception as exc:
self.logger.debug("Failed to estimate memory with psutil: %s", exc)
pass

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Gambitnl Gambitnl closed this Nov 7, 2025
@Gambitnl Gambitnl deleted the fix/pyannote-ollama branch November 12, 2025 08:13
Gambitnl pushed a commit that referenced this pull request Nov 16, 2025
Fixed issues identified by code review bot:

1. Corrected bug count from 25 to 23 bugs
2. Fixed BUG #12 location (line 120, not 155-161) and improved description
3. Fixed BUG #13 with proper cleanup suggestion (removed useless finally: pass)
4. Removed BUG #20 (invalid - code already implements suggested fix)
5. Removed BUG #25 (invalid - code uses correct pattern with Optional[]=None)
6. Updated summary counts: Medium 7→8, Low 11→8
7. Renumbered remaining bugs after removals
8. Updated total effort estimate: 34-46h → 32-44h

All bugs now verified against actual source code with correct line numbers
and accurate descriptions.
Gambitnl added a commit that referenced this pull request Nov 16, 2025
* docs: Add comprehensive bug report with 25 identified issues

Created docs/KNOWN_ISSUES.md documenting all bugs found during
systematic codebase analysis. Bugs are categorized by severity:

- Critical (3): Security vulnerabilities and data loss risks
- High (4): Crashes and race conditions
- Medium (7): Logic errors and resource leaks
- Low (11): Edge cases and type inconsistencies

Each bug includes:
- File location and line numbers
- Detailed description and impact assessment
- Code examples and suggested fixes
- Priority classification

Also includes fix priority roadmap with estimated effort (34-46 hours
total) and testing recommendations for each category.

* fix: Correct inaccuracies in KNOWN_ISSUES.md based on code review

Fixed issues identified by code review bot:

1. Corrected bug count from 25 to 23 bugs
2. Fixed BUG #12 location (line 120, not 155-161) and improved description
3. Fixed BUG #13 with proper cleanup suggestion (removed useless finally: pass)
4. Removed BUG #20 (invalid - code already implements suggested fix)
5. Removed BUG #25 (invalid - code uses correct pattern with Optional[]=None)
6. Updated summary counts: Medium 7→8, Low 11→8
7. Renumbered remaining bugs after removals
8. Updated total effort estimate: 34-46h → 32-44h

All bugs now verified against actual source code with correct line numbers
and accurate descriptions.

---------

Co-authored-by: Claude <noreply@anthropic.com>
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