I find it very hard to get proper tags, or descriptions when uploading my videos on YouTube. There is an option to use ChatGPT but I want to check it more exclusively in a particular niche.
I thought let’s build an AI agent that will analyze 100s of videos in the AI niche and suggest metadata, tags, and description for me. Therefore I built an AI agent to do these tasks for me.
I will be using NebiusAI for LLM integration and CrewAI for agent handling. I have written a simpler version on how to build an AI agent using these in my previous article.
Here is the link : https://dev.to/indraphoton/how-to-build-a-simple-ai-agent-using-crewai-and-nebiusai-22mk
So let’s get started
Installation
At the very first step, you need to install crewai tools for this. We will be using some custom tools built by CrewAI to scrap the youtube data and write an analysis.
pip install 'crewai[tools]'
LLM Integration
Next we have to bring the LLM for our work. We will be using Nebius AI studio for this purpose. You will also need to have NEBIUS_API_KEY
from Nebius to use the LLM model. You need to signup first and create an API key there. Don’t forget to put your API key in the environment variable (.env)
import os
from dotenv import load_dotenv
load_dotenv()
default_llm=LLM(
model="openai/meta-llama/Meta-Llama-3.1-70B-Instruct",
base_url="https://api.studio.nebius.com/v1/",
api_key=os.getenv("NEBIUS_API_KEY")
)
Agent Building
After integrating the LLM model, we need to create the agent for data handling and its analysis. We will build two agent here one will bring the data and the other one will write the report for me. For this we will use YoutubeVideoSearchTool
and YoutubeChannelSearchTool
from crewAI tool here.
from crewai import Agent, Task, LLM
from crewai import Crew, Process
from crewai_tools import SerperDevTool, YoutubeVideoSearchTool, YoutubeChannelSearchTool
#agent 1
researcher = Agent(
role="youtube video details e.g. tiltle, description, tags, channel analysis",
goal="Uncover the hidden tags, title, description, and channel analysis of YouTube videos in a specific niche.",
backstory="You are an expert in YouTube video analysis, specializing in extracting detailed metadata and insights from videos.",
tools=[YoutubeVideoSearchTool(), YoutubeChannelSearchTool()],
llm=default_llm
)
#agent 2
writer = Agent(
role="Report Writer",
goal="Write a compelling report on the YouTube video analysis findings focusing on numbers views tags title, description, and channel "
"analysis. Try to find the most popular videos in the niche and its success factors. write in a professional tone, to the point, "
"and with a focus on actionable insights. Use bullet points for clarity. focus on numbers.",
verbose=True,
llm=default_llm,
backstory="You excel at translating complex data into readable content, focusing on actionable insights and clarity.",
tools=[]
)
Assign the task for each agent
Once the agent is built we need to assign the task to each agent. Here is the step
research_task = Task(
description="Research the successful YouTube videos in the niche of AI agents, focusing on their tags, titles, descriptions, and channel analysis.",
expected_output="A report summarizing key insights from the YouTube videos, including tags, titles, descriptions, and channel analysis.",
agent=researcher # Assign the researcher agent
)
write_task = Task(
description="Write a detailed report based on the YouTube video analysis findings, focusing on numbers views tags title, description, and channel analysis.",
expected_output="An engaging report on the YouTube video analysis findings, highlighting key metrics and insights.",
agent=writer, # Assign the writer agent
context=[research_task] # Use research task output as context
)
Instantiate the agent crew
We have everything set up. This is time to create the agent instance so that it starts to give answer when asked. The process can be sequential or Hierarchical.
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process=Process.sequential # The agents work in sequence
)
# Execute the crew and capture the result
result = crew.kickoff(inputs={"topic": "AI agents in YouTube videos"})
You are done. Here is the output.
You will get the full code here,
Today we have built the most simple AI agent using crewAI and NebiusAI. You can use this idea to build some other applications. Let me know what ideas you are building, share your experience here.