The RexiaAIYoutubeVideoAnalysis
class is a specialized tool in the ReXia.AI framework designed to analyze YouTube videos. It uses OpenAI's Whisper for audio transcription and a multimodal model to analyze video frames and transcripts, providing comprehensive insights based on user queries.
openai_api_key
: OpenAI API key for accessing the models.vision_model_base_url
: Base URL for the vision model.vision_model
: Name of the vision model to use.whisper_model
: Name of the Whisper model to use for transcription (default: "base").
__init__(self, vision_model_base_url: str, vision_model: str, openai_api_key: str, whisper_model: str = "base") -> None
Initializes a RexiaAIYoutubeVideoAnalysis instance.
Analyzes the video and extracts insights based on the given query.
Parameters:
query
: The query or question about the video.video_url
: The URL of the YouTube video to analyze.
Returns:
- The analysis and insights extracted from the video.
Extracts frames and audio from a video file.
Generates a transcription of the audio file.
Returns the tool as a JSON object for ReXia.AI.
Returns the tool as a dictionary object for ReXia.AI.
Here's an example of how to use the RexiaAIYoutubeVideoAnalysis
class:
from rexia_ai.tools import RexiaAIYoutubeVideoAnalysis
from rexia_ai.agent import Agent
from rexia_ai.workflows import SimpleToolWorkflow
# Initialize the RexiaAIYoutubeVideoAnalysis instance
video_analysis_tool = RexiaAIYoutubeVideoAnalysis(
vision_model_base_url="https://api.openai.com/v1",
vision_model="gpt-4-vision-preview",
openai_api_key="your-openai-api-key"
)
# Create an Agent instance with SimpleToolWorkflow and the video analysis tool
agent = Agent(
llm=..., # Your language model instance
task="Analyze the content of this YouTube video",
workflow=SimpleToolWorkflow,
verbose=True,
tools={"analyse_video": video_analysis_tool}
)
# Run the agent
result = agent.invoke(
"What is the main topic of this video?",
video_url="https://www.youtube.com/watch?v=example"
)
print(result)
uuid
os
base64
typing
pytube
cv2
moviepy
openai
- ReXia.AI components (
BaseTool
,LLMOutput
)
Ensure all dependencies are installed and properly imported.
We welcome contributions to improve the ReXia.AI framework. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.