Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -71,36 +71,7 @@ with video_tab:
|
|
71 |
help="Upload a video for AI analysis"
|
72 |
)
|
73 |
|
74 |
-
|
75 |
-
with youtube_tab:
|
76 |
-
youtube_query = st.text_area(
|
77 |
-
"What would you like to know about the YouTube video?",
|
78 |
-
placeholder="Ask specific questions about the video or leave empty for a general summary.",
|
79 |
-
help="Enter your question about the YouTube video or leave blank for a general summary.",
|
80 |
-
key="youtube_query"
|
81 |
-
)
|
82 |
-
|
83 |
-
youtube_url = st.text_input(
|
84 |
-
"Paste a YouTube URL:",
|
85 |
-
placeholder="https://www.youtube.com/watch?v=..."
|
86 |
-
)
|
87 |
-
|
88 |
-
|
89 |
-
def generate_analysis_prompt(query, video_source):
|
90 |
-
return f"""
|
91 |
-
Analyze the {video_source} for content and context.
|
92 |
-
Key areas to address:
|
93 |
-
1. Main topics and themes
|
94 |
-
2. Key points and insights
|
95 |
-
3. Specific answer to user query: {query}
|
96 |
-
4. Supporting context from web research
|
97 |
-
|
98 |
-
Provide a structured, detailed response with clear sections and actionable insights.
|
99 |
-
"""
|
100 |
-
|
101 |
-
# Process uploaded video
|
102 |
-
if video_file:
|
103 |
-
with video_tab:
|
104 |
st.video(video_file, format="video/mp4", start_time=0)
|
105 |
|
106 |
if st.button("π Analyze Uploaded Video", use_container_width=True):
|
@@ -142,8 +113,9 @@ if video_file:
|
|
142 |
finally:
|
143 |
# Clean up temporary file
|
144 |
Path(video_path).unlink(missing_ok=True)
|
|
|
|
|
145 |
|
146 |
-
# Process YouTube URL
|
147 |
# YouTube URL Tab
|
148 |
with youtube_tab:
|
149 |
youtube_query = st.text_area(
|
@@ -158,7 +130,6 @@ with youtube_tab:
|
|
158 |
placeholder="https://www.youtube.com/watch?v=..."
|
159 |
)
|
160 |
|
161 |
-
# Process YouTube URL within the tab
|
162 |
if youtube_url:
|
163 |
if st.button("π Analyze YouTube Video", use_container_width=True):
|
164 |
try:
|
@@ -178,7 +149,24 @@ with youtube_tab:
|
|
178 |
st.error(f"An error occurred: {str(error)}")
|
179 |
else:
|
180 |
st.info("Please enter a YouTube URL to begin analysis.")
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
# Custom styling
|
183 |
st.markdown(
|
184 |
"""
|
|
|
71 |
help="Upload a video for AI analysis"
|
72 |
)
|
73 |
|
74 |
+
if video_file:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
st.video(video_file, format="video/mp4", start_time=0)
|
76 |
|
77 |
if st.button("π Analyze Uploaded Video", use_container_width=True):
|
|
|
113 |
finally:
|
114 |
# Clean up temporary file
|
115 |
Path(video_path).unlink(missing_ok=True)
|
116 |
+
else:
|
117 |
+
st.info("Please upload a video file to begin analysis.")
|
118 |
|
|
|
119 |
# YouTube URL Tab
|
120 |
with youtube_tab:
|
121 |
youtube_query = st.text_area(
|
|
|
130 |
placeholder="https://www.youtube.com/watch?v=..."
|
131 |
)
|
132 |
|
|
|
133 |
if youtube_url:
|
134 |
if st.button("π Analyze YouTube Video", use_container_width=True):
|
135 |
try:
|
|
|
149 |
st.error(f"An error occurred: {str(error)}")
|
150 |
else:
|
151 |
st.info("Please enter a YouTube URL to begin analysis.")
|
152 |
+
|
153 |
+
def generate_youtube_prompt(youtube_query, youtube_url):
|
154 |
+
if youtube_query:
|
155 |
+
return f"Watch this video {youtube_url} and answer the following question: {youtube_query}"
|
156 |
+
return f"Summarize this video {youtube_url}"
|
157 |
+
|
158 |
+
def generate_analysis_prompt(query, video_source):
|
159 |
+
return f"""
|
160 |
+
Analyze the {video_source} for content and context.
|
161 |
+
Key areas to address:
|
162 |
+
1. Main topics and themes
|
163 |
+
2. Key points and insights
|
164 |
+
3. Specific answer to user query: {query}
|
165 |
+
4. Supporting context from web research
|
166 |
+
|
167 |
+
Provide a structured, detailed response with clear sections and actionable insights.
|
168 |
+
"""
|
169 |
+
|
170 |
# Custom styling
|
171 |
st.markdown(
|
172 |
"""
|