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

Added examples #80

Merged
merged 3 commits into from
May 31, 2024
Merged

Added examples #80

merged 3 commits into from
May 31, 2024

Conversation

theyashwanthsai
Copy link
Contributor

@theyashwanthsai theyashwanthsai commented May 31, 2024

User description

Added examples from guides done by me, prathit and pranav


PR Type

Enhancement


Description

  • Added multiple example scripts demonstrating the use of CrewAI and ComposioToolSet for various applications.
  • Examples include Competitor Researcher, GitHub to Trello integration, Investment Analysis, News Summary, Research Assistant, and Todo to Calendar.
  • Integrated various AI models and APIs including OpenAI, Google Generative AI, and HuggingFace.
  • Utilized Flask for web server setup and BeautifulSoup for HTML parsing.

Changes walkthrough 📝

Relevant files
Enhancement
CompetitiorResearcher.py
Add Competitor Researcher script for web scraping and Notion
integration

examples/CompetitiorResearcher/CompetitiorResearcher.py

  • Added a script to scrape competitor websites and create pages in
    Notion.
  • Utilized BeautifulSoup for HTML parsing and Flask for web server.
  • Integrated OpenAI and ComposioToolSet for AI functionalities.
  • +61/-0   
    GithubToTrello.py
    Add GitHub to Trello integration for task management         

    examples/GithubToTrello/GithubToTrello.py

  • Added a Flask application to handle GitHub webhooks.
  • Integrated CrewAI and ComposioToolSet for creating Trello cards based
    on GitHub patches.
  • Defined tasks for creating TODO and Done cards in Trello.
  • +48/-0   
    InvestmentAnalysis.py
    Add Investment Analysis script with multi-agent setup       

    examples/InvestmentAnalysis/InvestmentAnalysis.py

  • Added agents for investment research, analysis, and recommendation.
  • Utilized CrewAI and ComposioToolSet for task execution.
  • Integrated Google Generative AI for language modeling.
  • +78/-0   
    NewsSummary.py
    Add News Summary script for retrieving and summarizing AI news

    examples/NewsSummary/NewsSummary.py

  • Added a script to retrieve and summarize AI news.
  • Utilized HuggingFace and ComposioToolSet for AI functionalities.
  • Implemented ReAct style prompt template for agent execution.
  • +47/-0   
    ResearchAssistant.py
    Add Research Assistant script for LLM comparison                 

    examples/ResearchAssistant/ResearchAssistant.py

  • Added a script for researching open source vs closed source LLMs.
  • Utilized CrewAI and ComposioToolSet for task execution.
  • Integrated Google Generative AI for language modeling.
  • +38/-0   
    TodoToCalendar.py
    Add Todo to Calendar script for scheduling tasks                 

    examples/TodoToCalendar/TodoToCalendar.py

  • Added a script to convert TODO tasks into Google Calendar events.
  • Utilized CrewAI and ComposioToolSet for task execution.
  • Integrated OpenAI for language modeling.
  • +46/-0   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @codiumai-pr-agent-pro codiumai-pr-agent-pro bot added the enhancement New feature or request label May 31, 2024
    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    4, because the PR introduces multiple new scripts with complex integrations involving various APIs and AI models. Each script appears to handle different functionalities and uses different sets of tools, which increases the complexity and the need for thorough testing and validation.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: Hardcoded API keys and sensitive information should be replaced with environment variables to avoid security risks.

    Performance Concern: The use of synchronous requests in web scraping without handling potential delays or failures could lead to performance bottlenecks.

    Error Handling: Lack of error handling in API responses and external service interactions could lead to unhandled exceptions and application crashes.

    🔒 Security concerns

    Sensitive information exposure: The scripts include hardcoded placeholders for API keys and other sensitive information, which should be managed securely using environment variables or secure vault solutions.

    Copy link
    Contributor

    @ellipsis-dev ellipsis-dev bot left a comment

    Choose a reason for hiding this comment

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

    👍 Looks good to me! Reviewed everything up to 4decf38 in 49 seconds

    More details
    • Looked at 361 lines of code in 6 files
    • Skipped 0 files when reviewing.
    • Skipped posting 1 drafted comments based on config settings.
    1. examples/TodoToCalendar/TodoToCalendar.py:10
    • Draft comment:
      The dotenv module is used here but not imported. Ensure to import it to avoid runtime errors.
    import dotenv
    
    • Reason this comment was not posted:
      Confidence of 0% on close inspection, compared to threshold of 50%.

    Workflow ID: wflow_oH7OtahgUpUn0IfC


    You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

    6 days left in your free trial, upgrade for $20/seat/month or contact us.

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Use os.getenv to safely access environment variables

    Instead of using os.environ["OPENAI_API_KEY"] directly, use os.getenv("OPENAI_API_KEY") to
    avoid potential KeyError if the environment variable is not set.

    examples/CompetitiorResearcher/CompetitiorResearcher.py [11]

    -llm = ChatOpenAI(openai_api_key=os.environ["OPENAI_API_KEY"], model_name="gpt-4-turbo-preview")
    +llm = ChatOpenAI(openai_api_key=os.getenv("OPENAI_API_KEY"), model_name="gpt-4-turbo-preview")
     
    Suggestion importance[1-10]: 8

    Why: Using os.getenv instead of os.environ prevents potential crashes due to missing environment variables, which is a significant improvement in robustness.

    8
    Possible issue
    Add error handling for the request.json call in the webhook function

    Add error handling for the requests.json call in the webhook function to manage potential
    issues with the incoming data.

    examples/GithubToTrello/GithubToTrello.py [29-33]

    +try:
    +    github_patch = request.json
    +except Exception as e:
    +    return f"Error processing request: {e}", 400
    +
     task1 = Task(
    -    description=f"""Given the following Github patch: {request.json}, create a TRELLO card (trello_create_trello_card) for the TODOs from code comments in the patch. TRELLO list (id:{t_id}).
    +    description=f"""Given the following Github patch: {github_patch}, create a TRELLO card (trello_create_trello_card) for the TODOs from code comments in the patch. TRELLO list (id:{t_id}).
         Please read the patch carefully and create cards for the new TODOs only, avoid removed/old TODOs. Card name should reflect the todo comment present in code""",
         expected_output="A TRELLO card created for the commit",
         agent=crewai_agent,
     )
     
    Suggestion importance[1-10]: 7

    Why: Adding error handling for request.json is important to prevent server errors due to malformed or unexpected input, which enhances the reliability of the webhook.

    7
    Add a check to ensure user_input is not empty before creating the task

    Add a check to ensure user_input is not empty before proceeding with the task creation.

    examples/InvestmentAnalysis/InvestmentAnalysis.py [59-66]

     user_input = input("Please provide a topic: ")
    +if not user_input.strip():
    +    raise ValueError("Topic cannot be empty.")
    +
     analyst_task = Task(
         description=f'Research on {user_input}',
         agent=analyser,
         expected_output="When the input is well researched, thoroughly analysed and recommendation is offered"
     )
     
    Suggestion importance[1-10]: 6

    Why: Ensuring user_input is not empty before proceeding prevents the creation of meaningless tasks, improving the functionality of the application.

    6
    Enhancement
    Use a structured data format for the todo list to improve robustness

    Use a more robust method to parse the todo string into structured data to avoid potential
    issues with formatting.

    examples/TodoToCalendar/TodoToCalendar.py [20-24]

    -todo = '''
    -    1PM - 3PM -> Code,
    -    5PM - 7PM -> Meeting,
    -    9AM - 12AM -> Learn something,
    -    8PM - 10PM -> Game
    -'''
    +todo = [
    +    {"start": "1PM", "end": "3PM", "task": "Code"},
    +    {"start": "5PM", "end": "7PM", "task": "Meeting"},
    +    {"start": "9AM", "end": "12AM", "task": "Learn something"},
    +    {"start": "8PM", "end": "10PM", "task": "Game"}
    +]
     
    Suggestion importance[1-10]: 5

    Why: Converting the todo string into structured data can help in managing and processing the data more effectively, though it's a moderate improvement depending on further use cases.

    5

    @utkarsh-dixit utkarsh-dixit merged commit 60f950b into ComposioHQ:master May 31, 2024
    2 of 3 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants