Skip to content

Conversation

@Dhivya-Bharathy
Copy link
Contributor

@Dhivya-Bharathy Dhivya-Bharathy commented Jun 10, 2025

User description

BERT + Whisper Agent combines speech recognition and natural language understanding in a lightweight Colab environment.
It uses Whisper to transcribe audio into text and BERT to generate semantic embeddings for intelligent downstream tasks.
Ideal for building voice-driven NLP applications like semantic search, classification, and context-aware assistants.


PR Type

enhancement, documentation


Description

  • Introduces a new agent combining BERT Large and Whisper Large V3.

    • Enables speech-to-text transcription using Whisper.
    • Provides semantic embeddings and NLP capabilities via BERT.
  • Adds example notebooks demonstrating agent usage.

    • Includes a dedicated notebook for the BERT + Whisper agent.
    • Adds an additional example for MistralTechAgent.

Changes walkthrough 📝

Relevant files
Documentation
bert_whisper_agent.ipynb
Example notebook for BERT + Whisper Large V3 agent             

examples/cookbooks/bert_whisper_agent.ipynb

  • Adds a notebook demonstrating BERT + Whisper agent usage.
  • Shows speech-to-text and semantic NLP integration.
  • Provides code and explanations for building voice-driven NLP apps.
  • +6094/-0
    MistralTechAgent.ipynb
    Example notebook for MistralTechAgent                                       

    examples/cookbooks/MistralTechAgent.ipynb

  • Adds an example notebook for MistralTechAgent.
  • Demonstrates usage and capabilities of the agent.
  • +4383/-0

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @gemini-code-assist
    Copy link
    Contributor

    Note

    Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

    @coderabbitai
    Copy link
    Contributor

    coderabbitai bot commented Jun 10, 2025

    Important

    Review skipped

    Review was skipped as selected files did not have any reviewable changes.

    💤 Files selected but had no reviewable changes (2)
    • examples/cookbooks/MistralTechAgent.ipynb
    • examples/cookbooks/bert_whisper_agent.ipynb

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share
    🪧 Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>, please review it.
      • Explain this complex logic.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai explain this code block.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
      • @coderabbitai read src/utils.ts and explain its main purpose.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Support

    Need help? Create a ticket on our support page for assistance with any issues or questions.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai generate docstrings to generate docstrings for this PR.
    • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
    • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
    • Add @coderabbitai anywhere in the PR title to generate the title automatically.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    @qodo-merge-pro
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    @qodo-merge-pro
    Copy link

    qodo-merge-pro bot commented Jun 10, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Add audio file error handling

    Add error handling for file loading and audio processing operations. The
    function should handle cases where the file doesn't exist, is corrupted, or has
    unsupported format to prevent runtime crashes.

    examples/cookbooks/bert_whisper_agent.ipynb [549-557]

     def transcribe_audio(file_path):
    -    audio, rate = torchaudio.load(file_path)
    +    try:
    +        audio, rate = torchaudio.load(file_path)
    +    except Exception as e:
    +        raise ValueError(f"Failed to load audio file: {e}")
    +    
         if rate != 16000:
             resampler = torchaudio.transforms.Resample(orig_freq=rate, new_freq=16000)
             audio = resampler(audio)
         input_features = processor(audio.squeeze().numpy(), sampling_rate=16000, return_tensors="pt").input_features
         input_features = input_features.to(model.device)
         predicted_ids = model.generate(input_features)
         return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly proposes adding a try-except block to handle potential errors when loading an audio file with torchaudio.load(). This improves the robustness of the example notebook by preventing crashes from invalid file paths or formats.

    Medium
    Add text input validation

    Add input validation to handle empty or None text inputs. The function should
    check for valid text input before processing to prevent tokenization errors.

    examples/cookbooks/bert_whisper_agent.ipynb [232-236]

     def classify_text(text):
    +    if not text or not isinstance(text, str):
    +        raise ValueError("Text input must be a non-empty string")
    +    
         inputs = bert_tokenizer(text, return_tensors="pt")
         with torch.no_grad():
             outputs = bert_model(**inputs)
         return outputs.last_hidden_state.mean(dim=1)  # Sentence embedding

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly adds validation to the classify_text function to ensure the input is a non-empty string. This is a good practice that prevents potential runtime errors from the tokenizer if the input is None or not a string, improving the function's reliability.

    Medium
    Add input validation and error handling

    The method lacks input validation and error handling. Add checks for empty
    prompts and handle potential CUDA memory errors or model generation failures to
    prevent crashes.

    examples/cookbooks/MistralTechAgent.ipynb [539-551]

     def chat(self, prompt: str, max_new_tokens=256) -> str:
    -    inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
    -    with torch.no_grad():
    -        outputs = self.model.generate(
    -            **inputs,
    -            max_new_tokens=max_new_tokens,
    -            do_sample=False,  # DETERMINISTIC output
    -            temperature=1.0,
    -            top_p=1.0,
    -            pad_token_id=self.tokenizer.eos_token_id
    -        )
    -    full_output = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
    -    return full_output[len(prompt):].strip()
    +    if not prompt or not prompt.strip():
    +        return "Please provide a valid prompt."
    +    
    +    try:
    +        inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
    +        with torch.no_grad():
    +            outputs = self.model.generate(
    +                **inputs,
    +                max_new_tokens=max_new_tokens,
    +                do_sample=False,  # DETERMINISTIC output
    +                temperature=1.0,
    +                top_p=1.0,
    +                pad_token_id=self.tokenizer.eos_token_id
    +            )
    +        full_output = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
    +        return full_output[len(prompt):].strip()
    +    except Exception as e:
    +        return f"Error generating response: {str(e)}"

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly points out the lack of input validation and error handling. Adding a try-except block and a check for empty prompts makes the chat method more robust, which is a valuable improvement for the example code.

    Medium
    Security
    Secure API key handling

    Hardcoding API keys directly in code is a security risk. Use environment
    variables or secure configuration files instead. Consider using getpass or
    reading from a .env file to avoid exposing sensitive credentials in the
    notebook.

    examples/cookbooks/MistralTechAgent.ipynb [108]

    -os.environ["HF_TOKEN"] = "Enter your hugging api key"
    +import getpass
    +os.environ["HF_TOKEN"] = getpass.getpass("Enter your Hugging Face API key: ")

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies a security best-practice issue. While the code uses a placeholder, prompting the user to paste a key is insecure. Using getpass is a much better pattern for an example notebook as it prevents the key from being stored in the notebook's code or output.

    Medium
    • Update

    @gitguardian
    Copy link

    gitguardian bot commented Jun 10, 2025

    ⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

    Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

    Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
    Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

    🔎 Detected hardcoded secret in your pull request
    GitGuardian id GitGuardian status Secret Commit Filename
    17682666 Triggered Generic High Entropy Secret 9ff2180 src/praisonai-agents/test_posthog_import.py View secret
    🛠 Guidelines to remediate hardcoded secrets
    1. Understand the implications of revoking this secret by investigating where it is used in your code.
    2. Replace and store your secret safely. Learn here the best practices.
    3. Revoke and rotate this secret.
    4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

    To avoid such incidents in the future consider


    🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

    @codecov
    Copy link

    codecov bot commented Jun 10, 2025

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 0.00%. Comparing base (6fcf84e) to head (9ff2180).
    Report is 59 commits behind head on main.

    Additional details and impacted files
    @@          Coverage Diff          @@
    ##            main    #633   +/-   ##
    =====================================
      Coverage   0.00%   0.00%           
    =====================================
      Files         22      22           
      Lines       1980    1980           
    =====================================
      Misses      1980    1980           
    Flag Coverage Δ
    quick-validation 0.00% <ø> (ø)

    Flags with carried forward coverage won't be shown. Click here to find out more.

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    🚀 New features to boost your workflow:
    • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
    • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

    @MervinPraison MervinPraison merged commit a4be556 into MervinPraison:main Jun 10, 2025
    6 of 9 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants