Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved prompts of the system and agents #94

Merged
merged 3 commits into from
Dec 3, 2024
Merged

Conversation

codeAshu
Copy link
Member

@codeAshu codeAshu commented Dec 3, 2024

Changed system prompt :

  • fixes many reasoning engine misses seen during testing
  • Attached version to reasoning engine
  • Showcases agents in a informative way to new users.

Changed summary prompt to reach out on Discord in case of issues and error.

Changed other agent prompts to perform better with queries.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced descriptions for various agents to clarify their functionalities, including video editing, image generation, pricing analysis, profanity removal, prompt clipping, searching, and streaming.
  • Bug Fixes

    • Improved error handling and messaging across multiple agents, providing clearer guidance for users when issues arise.
  • Documentation

    • Updated internal documentation and comments to reflect changes in logic and error handling for better clarity and maintainability.

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Warning

Rate limit exceeded

@codeAshu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 64bf907 and 90ed2d0.

Walkthrough

The pull request introduces several descriptive updates across multiple agent classes in the backend, primarily focusing on clarifying the purpose and functionality of each agent. Changes include modifications to the description attributes in various classes, restructuring of prompts for improved clarity, and enhancements to error handling in several methods. While the overall functionality and method signatures remain unchanged, the updates aim to streamline communication and improve user guidance during interactions with the agents.

Changes

File Path Change Summary
backend/director/agents/editing.py Updated self.description in EditingAgent for clarity regarding media editing context.
backend/director/agents/image_generation.py Corrected formatting of self.description in ImageGenerationAgent from "Gen AI" to "GenAI".
backend/director/agents/pricing.py Restructured PRICING_AGENT_PROMPT for clarity; updated self.description in PricingAgent.
backend/director/agents/profanity_remover.py Updated self.description and improved error handling in run method of ProfanityRemoverAgent.
backend/director/agents/prompt_clip.py Enhanced PromptClipAgent with improved error handling in _get_transcript and structured run method.
backend/director/agents/search.py Updated self.description in SearchAgent and refined error handling in run method.
backend/director/agents/stream_video.py Updated self.description in StreamVideoAgent and refined logic and error handling in run method.
backend/director/core/reasoning.py Restructured REASONING_SYSTEM_PROMPT and SUMMARIZATION_PROMPT for clarity and organization.

Poem

🐰 In the land of code where agents play,
Descriptions refined to brighten the day.
From editing clips to searching with glee,
Each change a hop, as clear as can be!
With prompts now polished and errors in sight,
Our agents are ready to take flight! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@codeAshu codeAshu requested a review from ashish-spext December 3, 2024 05:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
backend/director/agents/prompt_clip.py (1)

47-47: Address the TODO comment: 'Improve this'

There's a TODO comment indicating that the description needs enhancement.

Would you like assistance in improving the agent's description? I can help draft a more informative description or open a GitHub issue to track this task.

backend/director/agents/stream_video.py (1)

Line range hint 49-49: Incorrect error message in exception handling

In the exception handling block, the status_message is set to "Error in calculating pricing," which is unrelated to streaming video and may confuse users.

Apply this diff to correct the error message:

-    video_content.status_message = "Error in calculating pricing."
+    video_content.status_message = "Error in streaming video."
backend/director/agents/search.py (2)

63-63: Consider enhancing the description further.

While the updated description is more informative, consider adding details about supported search types (semantic/keyword) and index types (spoken_word/scene) to better align with the agent's capabilities.

-        self.description = "Agent to search information from VideoDB collections. Mainly used with a collection of videos."
+        self.description = "Agent to perform semantic and keyword searches across VideoDB collections, supporting both spoken word and scene-based indexing. Primarily used with video collections."

Line range hint 76-267: Consider refactoring the run method for improved maintainability.

The method could benefit from several improvements:

  1. Split the long method into smaller, focused functions:

    • _perform_search
    • _process_search_results
    • _generate_compilation
    • _generate_summary
  2. Update the docstring:

    • Fix typo: "Retreive" → "Retrieve"
    • Add type hints for parameters
    • Document return values and exceptions
  3. Standardize error handling:

    • Create constants for common error messages
    • Add specific error types for different failure scenarios

Here's a suggested structure:

from typing import Optional, List, Dict, Any

class SearchAgent(BaseAgent):
    # ... existing code ...

    def run(
        self,
        query: str,
        search_type: str,
        index_type: str,
        collection_id: str,
        video_id: Optional[str] = None,
        result_threshold: int = 8,
        score_threshold: float = 0.2,
        dynamic_score_percentage: int = 20,
        *args: Any,
        **kwargs: Any,
    ) -> AgentResponse:
        """
        Retrieve data from VideoDB collections and videos.

        Args:
            query: Search query string
            search_type: Type of search ('semantic' or 'keyword')
            index_type: Type of indexing ('spoken_word' or 'scene')
            collection_id: ID of the collection to search
            video_id: Optional ID of specific video to search
            result_threshold: Initial filter for top N matching documents
            score_threshold: Absolute threshold filter for relevance scores
            dynamic_score_percentage: Percentage for adaptive filtering mechanism

        Returns:
            AgentResponse containing search results, text summary and compilation video

        Raises:
            ValueError: If search parameters are invalid
            SearchError: If search operation fails
        """
        try:
            search_results = self._perform_search(
                query, search_type, index_type, collection_id, video_id,
                result_threshold, score_threshold, dynamic_score_percentage
            )
            
            processed_results = self._process_search_results(search_results)
            if not processed_results:
                return self._create_error_response("No search results found", query)
                
            compilation_url = self._generate_compilation(processed_results)
            summary = self._generate_summary(query, processed_results)
            
            return self._create_success_response(compilation_url)
            
        except Exception as e:
            logger.exception(f"Error in {self.agent_name}")
            return self._create_error_response(str(e))

This structure would make the code more maintainable and easier to test.

backend/director/agents/pricing.py (1)

16-17: Fix typos and improve language clarity.

The prompt introduction needs minor refinements:

  1. Remove "brilliant" as it may set unrealistic expectations
  2. Fix the typo "to to" in line 17
  3. Restructure line 17 for better clarity
-    You are a brilliant pricing analyst working for VideoDB, a video database for AI apps. 
-    You can access information from internet and also reference this sheet to provide answers to to the task your user (executive) asks. 
+    You are a pricing analyst working for VideoDB, a video database for AI apps. 
+    You can access information from the internet and reference this pricing sheet to provide answers to your user's (executive's) questions.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2e5edd9 and 64bf907.

📒 Files selected for processing (8)
  • backend/director/agents/editing.py (1 hunks)
  • backend/director/agents/image_generation.py (1 hunks)
  • backend/director/agents/pricing.py (2 hunks)
  • backend/director/agents/profanity_remover.py (1 hunks)
  • backend/director/agents/prompt_clip.py (1 hunks)
  • backend/director/agents/search.py (1 hunks)
  • backend/director/agents/stream_video.py (1 hunks)
  • backend/director/core/reasoning.py (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • backend/director/agents/image_generation.py
  • backend/director/agents/editing.py
🔇 Additional comments (3)
backend/director/agents/pricing.py (3)

18-19: LGTM! Clear and accurate service description.

The description of VideoDB's core features and capabilities is well-structured and informative. The explanation of programmatic streams and indexing provides valuable context for pricing discussions.


98-98: LGTM! Improved description clarity.

The description is now more concise while maintaining clarity about the agent's purpose and capabilities. This change aligns well with the similar improvements made to other agent descriptions across the codebase.


Line range hint 41-83: Verify pricing consistency across the codebase.

Let's ensure the pricing information in this prompt matches other references in the codebase to maintain consistency.

✅ Verification successful

Let me search for any other pricing-related files or configurations to ensure we have a complete view.


Pricing information is consistent and self-contained

The pricing information is defined in a single source of truth within backend/director/agents/pricing.py. There are no conflicting pricing definitions or inconsistencies found across the codebase. All pricing-related logic and calculations reference this single pricing structure.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other pricing references in the codebase
rg -A 2 -B 2 '"data_storage"|"index_storage"|"spoken_index_creation"|"scene_index_creation"|"programmable_video_stream_generation"|"simple_streaming"|"search_queries"' --type py

Length of output: 3051


Script:

#!/bin/bash
# Search for pricing-related files
fd -e py -e json -e yaml -e yml pricing

# Search for any other price or cost references
rg -i "price|cost" --type py --type json --type yaml

Length of output: 3763

backend/director/core/reasoning.py Outdated Show resolved Hide resolved
backend/director/agents/profanity_remover.py Outdated Show resolved Hide resolved
codeAshu and others added 2 commits December 3, 2024 11:03
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@codeAshu codeAshu merged commit a2de5b8 into main Dec 3, 2024
1 check passed
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.

2 participants