ComposioHQ / composio

Composio equips agents with well-crafted tools empowering them to tackle complex tasks
https://docs.composio.dev
Other
1.3k stars 427 forks source link

Adding Podcast summarizer Agent #240

Open siddartha-10 opened 1 week ago

siddartha-10 commented 1 week ago

User description

Summarizing a whole podcast form youtube and send it as a slack message to a channel using composio and crewai. Simply input the YouTube podcast URL and your preferred Slack channel—The Crew handles the rest, summarizing the content and delivering it seamlessly.


PR Type

Enhancement, Documentation


Description


Changes walkthrough 📝

Relevant files
Enhancement
4 files
Podcast_Summarizer_AI_Agent.py
Implement podcast summarization and Slack messaging agents

cookbook/Podcast_summarizer_Agents/Podcast_Summarizer_AI_Agent.py
  • Added PodSumCrew class to handle podcast summarization and Slack
    messaging.
  • Configured agents and tasks for summarizing podcasts and sending
    messages.
  • Integrated OpenAI and AzureChatOpenAI for language model processing.
  • +64/-0   
    audio_trancriber.py
    Add audio transcriber tool for YouTube videos                       

    cookbook/Podcast_summarizer_Agents/Tools/audio_trancriber.py
  • Added audio_transcriber_tool to extract and transcribe audio from
    YouTube videos.
  • Utilized pytube for downloading audio and whisper for transcription.
  • +24/-0   
    composio_slack.py
    Integrate Slack messaging tool using ComposioToolSet         

    cookbook/Podcast_summarizer_Agents/Tools/composio_slack.py
  • Added composio_slack_tool to integrate Slack messaging using
    ComposioToolSet.
  • +5/-0     
    main.py
    Create Streamlit app for podcast summarization                     

    cookbook/Podcast_summarizer_Agents/main.py
  • Created Streamlit app for user input and triggering podcast
    summarization.
  • Integrated PodSumCrew for processing inputs and displaying results.
  • +21/-0   
    Documentation
    2 files
    LICENSE
    Add MIT License                                                                                   

    cookbook/Podcast_summarizer_Agents/LICENSE - Added MIT License for the project.
    +21/-0   
    README.md
    Add README with project description and setup instructions

    cookbook/Podcast_summarizer_Agents/README.md
  • Added project description and setup instructions.
  • Included images and sample run video.
  • +43/-0   
    Configuration changes
    2 files
    agents.yaml
    Configure agents for summarization and messaging                 

    cookbook/Podcast_summarizer_Agents/config/agents.yaml - Configured agents for podcast summarization and Slack messaging.
    +15/-0   
    tasks.yaml
    Configure tasks for summarization and messaging                   

    cookbook/Podcast_summarizer_Agents/config/tasks.yaml
  • Configured tasks for summarizing podcasts and sending messages to
    Slack.
  • +11/-0   
    Dependencies
    1 files
    requirements.txt
    Add project dependencies                                                                 

    cookbook/Podcast_summarizer_Agents/requirements.txt - Added required dependencies for the project.
    +7/-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[bot] commented 1 week ago

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5] 4
    🧪 Relevant tests No
    🔒 Security concerns No
    ⚡ Key issues to review Possible Bug:
    The PodSumCrew class does not define self.agents or self.tasks which are referenced in the crew method. This might cause runtime errors when trying to create a Crew instance.
    Performance Concern:
    The transcription and summarization process might be resource-intensive and could benefit from asynchronous execution or other performance optimizations.
    Error Handling:
    There is no error handling for failures in the transcription, summarization, or Slack messaging processes.
    codiumai-pr-agent-pro[bot] commented 1 week ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Move the instantiation of AzureChatOpenAI into an __init__ method to ensure proper loading of environment variables and manage instantiation timing ___ **The instantiation of AzureChatOpenAI is done directly within the class attribute
    definition. This could lead to issues with environment variables not being loaded in time
    or errors during the class definition phase. It's recommended to move this to a method or
    inside an __init__ method.** [cookbook/Podcast_summarizer_Agents/Podcast_Summarizer_AI_Agent.py [18-21]](https://github.com/ComposioHQ/composio/pull/240/files#diff-ef19ce3b5c5e128db0b50564646c2005f333fb2aadabd4ce7a5fb79e91b40da2R18-R21) ```diff -llm_model = AzureChatOpenAI(openai_api_version=os.getenv("AZURE_OPENAI_VERSION", "2023-07-01-preview"), - azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT", "gpt4chat"), - azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT", "https://gpt-4-trails.openai.azure.com/"), - api_key=os.getenv("AZURE_OPENAI_KEY")) +def __init__(self): + self.llm_model = AzureChatOpenAI( + openai_api_version=os.getenv("AZURE_OPENAI_VERSION", "2023-07-01-preview"), + azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT", "gpt4chat"), + azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT", "https://gpt-4-trails.openai.azure.com/"), + api_key=os.getenv("AZURE_OPENAI_KEY") + ) ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: This suggestion significantly improves maintainability and ensures that environment variables are properly loaded before instantiation, which can prevent runtime errors.
    9
    Best practice
    Use the get method for dictionary access to avoid potential KeyErrors ___ **The agents_config dictionary keys are accessed directly which could raise a KeyError if
    the keys do not exist. It's safer to use the get method which will return None if the key
    is not found, or provide a default value.** [cookbook/Podcast_summarizer_Agents/Podcast_Summarizer_AI_Agent.py [26]](https://github.com/ComposioHQ/composio/pull/240/files#diff-ef19ce3b5c5e128db0b50564646c2005f333fb2aadabd4ce7a5fb79e91b40da2R26-R26) ```diff -config = self.agents_config['Transcriber_summarizer'] +config = self.agents_config.get('Transcriber_summarizer', {}) ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: This suggestion enhances the robustness of the code by preventing potential `KeyError` exceptions, making the code more fault-tolerant.
    8
    Performance
    Cache the slack_tool by instantiating it once during class initialization to improve efficiency ___ **The slack_tool is being instantiated every time the slack_agent method is called, which
    could be inefficient if the method is called multiple times. Consider caching the result
    or instantiating it once during class initialization.** [cookbook/Podcast_summarizer_Agents/Podcast_Summarizer_AI_Agent.py [16]](https://github.com/ComposioHQ/composio/pull/240/files#diff-ef19ce3b5c5e128db0b50564646c2005f333fb2aadabd4ce7a5fb79e91b40da2R16-R16) ```diff -slack_tool = composio_slack_tool() +def __init__(self): + self.slack_tool = composio_slack_tool() ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: This suggestion enhances performance by avoiding repeated instantiation of `slack_tool`, which can be inefficient if the method is called multiple times.
    8
    Possible issue
    Convert the audio_tool attribute from a list to a single instance if only one tool is required ___ **The audio_tool attribute is defined as a list containing a single tool, which might be a
    mistake if the intention was to assign a single tool. If only one tool is required, it
    should not be wrapped in a list.** [cookbook/Podcast_summarizer_Agents/Podcast_Summarizer_AI_Agent.py [15]](https://github.com/ComposioHQ/composio/pull/240/files#diff-ef19ce3b5c5e128db0b50564646c2005f333fb2aadabd4ce7a5fb79e91b40da2R15-R15) ```diff -audio_tool = [audio_transcriber_tool] +audio_tool = audio_transcriber_tool ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: This suggestion improves code clarity by ensuring that `audio_tool` is correctly represented as a single instance rather than a list, which is more appropriate given the context.
    7