Update app.py
Browse files
app.py
CHANGED
@@ -102,16 +102,15 @@ with tab1:
|
|
102 |
# Tab 2: YouTube Video Analyzer with Groq
|
103 |
with tab2:
|
104 |
st.title("YouTube Video Analyzer")
|
105 |
-
st.header("Analyze
|
106 |
|
107 |
-
# Initialize the agent for YouTube analysis
|
108 |
try:
|
109 |
youtube_agent = Agent(
|
110 |
model=Groq(id="llama-3.3-70b-versatile", api_key=groq_api_key),
|
111 |
tools=[YouTubeTools(), DuckDuckGo()],
|
112 |
show_tool_calls=True,
|
113 |
get_video_captions=True,
|
114 |
-
description="You are a YouTube
|
115 |
)
|
116 |
except Exception as e:
|
117 |
st.error(f"Error initializing the agent: {e}")
|
@@ -124,27 +123,34 @@ with tab2:
|
|
124 |
if video_url:
|
125 |
with st.spinner("Analyzing..."):
|
126 |
try:
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
if user_query:
|
129 |
-
prompt = f"""
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
else:
|
135 |
-
prompt = f"""
|
136 |
-
|
137 |
-
Extract the captions, summarize the video, and provide detailed key points.
|
138 |
-
"""
|
139 |
|
140 |
-
# Run the agent
|
141 |
output = youtube_agent.run(prompt)
|
142 |
|
143 |
-
|
144 |
-
st.subheader("Analysis Result")
|
145 |
-
st.markdown("### Detailed Summary")
|
146 |
-
st.write(output.content) # The complete analysis
|
147 |
-
|
148 |
|
149 |
except Exception as e:
|
150 |
st.error(f"Error analyzing the video: {e}")
|
|
|
102 |
# Tab 2: YouTube Video Analyzer with Groq
|
103 |
with tab2:
|
104 |
st.title("YouTube Video Analyzer")
|
105 |
+
st.header("Analyze Youtube video using video link 🎬 🧷")
|
106 |
|
|
|
107 |
try:
|
108 |
youtube_agent = Agent(
|
109 |
model=Groq(id="llama-3.3-70b-versatile", api_key=groq_api_key),
|
110 |
tools=[YouTubeTools(), DuckDuckGo()],
|
111 |
show_tool_calls=True,
|
112 |
get_video_captions=True,
|
113 |
+
description="You are a YouTube agent. Obtain the captions of a YouTube video, analyze its content and context, provide detailed summaries with key points, conduct web research on similar topics, and answer user questions.",
|
114 |
)
|
115 |
except Exception as e:
|
116 |
st.error(f"Error initializing the agent: {e}")
|
|
|
123 |
if video_url:
|
124 |
with st.spinner("Analyzing..."):
|
125 |
try:
|
126 |
+
prompt_prefix = """Analyze the YouTube video provided by the URL. Provide a detailed summary of the video, including key points.
|
127 |
+
Structure the output as follows:
|
128 |
+
|
129 |
+
**Detailed Summary:**
|
130 |
+
[Detailed summary of the video content]
|
131 |
+
|
132 |
+
**Key Points:**
|
133 |
+
* [Key point 1]
|
134 |
+
* [Key point 2]
|
135 |
+
* [Key point 3]
|
136 |
+
... (and so on)
|
137 |
+
|
138 |
+
Conduct web research on similar topics discussed in the video to provide additional context.
|
139 |
+
"""
|
140 |
+
|
141 |
if user_query:
|
142 |
+
prompt = f"""{prompt_prefix}
|
143 |
+
Respond to the following query using video insights and supplementary web research:
|
144 |
+
{user_query}
|
145 |
+
Provide a detailed, user-friendly, and actionable response.
|
146 |
+
Video URL: {video_url}"""
|
147 |
else:
|
148 |
+
prompt = f"""{prompt_prefix}
|
149 |
+
Video URL: {video_url}"""
|
|
|
|
|
150 |
|
|
|
151 |
output = youtube_agent.run(prompt)
|
152 |
|
153 |
+
st.markdown(output.content)
|
|
|
|
|
|
|
|
|
154 |
|
155 |
except Exception as e:
|
156 |
st.error(f"Error analyzing the video: {e}")
|