Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -269,51 +269,7 @@ def ask_groq(context, question):
|
|
| 269 |
)
|
| 270 |
return chat_completion.choices[0].message.content.strip()
|
| 271 |
|
| 272 |
-
|
| 273 |
-
# def main():
|
| 274 |
-
# st.set_page_config(page_title="EduBot for iCodeGuru", layout="wide")
|
| 275 |
-
# st.title("π EduBot for @icodeguru0")
|
| 276 |
-
# st.markdown("Ask anything based on the latest YouTube videos and website content of [icode.guru](https://icode.guru).")
|
| 277 |
-
|
| 278 |
-
# question = st.text_input("π¬ Ask your question:")
|
| 279 |
-
# if question:
|
| 280 |
-
# with st.spinner("πΊ Fetching YouTube videos..."):
|
| 281 |
-
# video_info = get_latest_video_ids(channel_id, max_results=5)
|
| 282 |
-
# transcripts = get_video_transcripts(video_info)
|
| 283 |
-
|
| 284 |
-
# yt_context = ""
|
| 285 |
-
# relevant_links = []
|
| 286 |
-
# for vid in transcripts:
|
| 287 |
-
# yt_context += f"\n\n[Video: {vid['title']}]({vid['link']}):\n{vid['transcript'][:1500]}"
|
| 288 |
-
# if question.lower() in vid['transcript'].lower():
|
| 289 |
-
# relevant_links.append(vid['link'])
|
| 290 |
-
|
| 291 |
-
# with st.spinner("π Scraping icode.guru..."):
|
| 292 |
-
# site_blocks = scrape_icodeguru(BASE_URL, max_pages=5)
|
| 293 |
-
# site_context = "\n\n".join(site_blocks)
|
| 294 |
-
|
| 295 |
-
# full_context = yt_context + "\n\n" + site_context
|
| 296 |
-
|
| 297 |
-
# with st.spinner("π§ Thinking..."):
|
| 298 |
-
# answer = ask_groq(full_context, question)
|
| 299 |
-
|
| 300 |
-
# st.success(answer)
|
| 301 |
-
|
| 302 |
-
# if relevant_links:
|
| 303 |
-
# st.markdown("### π Related YouTube Links")
|
| 304 |
-
# for link in relevant_links:
|
| 305 |
-
# st.markdown(f"- [Watch Video]({link})")
|
| 306 |
-
|
| 307 |
-
# st.markdown("---")
|
| 308 |
-
# st.caption("Powered by YouTube, iCodeGuru, and Groq")
|
| 309 |
-
|
| 310 |
-
# if __name__ == "__main__":
|
| 311 |
-
# main()
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
# --- STREAMLIT APP ---
|
| 317 |
def main():
|
| 318 |
st.set_page_config(page_title="EduBot for iCodeGuru", layout="wide")
|
| 319 |
st.title("π EduBot for @icodeguru0")
|
|
@@ -327,18 +283,10 @@ def main():
|
|
| 327 |
|
| 328 |
yt_context = ""
|
| 329 |
relevant_links = []
|
| 330 |
-
question_keywords = question.lower().split()
|
| 331 |
-
|
| 332 |
for vid in transcripts:
|
| 333 |
-
content = f"{vid['title']} {vid['transcript']}".lower()
|
| 334 |
yt_context += f"\n\n[Video: {vid['title']}]({vid['link']}):\n{vid['transcript'][:1500]}"
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
if any(kw in content for kw in question_keywords):
|
| 338 |
-
relevant_links.append({
|
| 339 |
-
"title": vid["title"],
|
| 340 |
-
"link": vid["link"]
|
| 341 |
-
})
|
| 342 |
|
| 343 |
with st.spinner("π Scraping icode.guru..."):
|
| 344 |
site_blocks = scrape_icodeguru(BASE_URL, max_pages=5)
|
|
@@ -352,9 +300,15 @@ def main():
|
|
| 352 |
st.success(answer)
|
| 353 |
|
| 354 |
if relevant_links:
|
| 355 |
-
st.markdown("### π
|
| 356 |
-
for
|
| 357 |
-
st.markdown(f"- [
|
| 358 |
|
| 359 |
st.markdown("---")
|
| 360 |
st.caption("Powered by YouTube, iCodeGuru, and Groq")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
)
|
| 270 |
return chat_completion.choices[0].message.content.strip()
|
| 271 |
|
| 272 |
+
--- STREAMLIT APP ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
def main():
|
| 274 |
st.set_page_config(page_title="EduBot for iCodeGuru", layout="wide")
|
| 275 |
st.title("π EduBot for @icodeguru0")
|
|
|
|
| 283 |
|
| 284 |
yt_context = ""
|
| 285 |
relevant_links = []
|
|
|
|
|
|
|
| 286 |
for vid in transcripts:
|
|
|
|
| 287 |
yt_context += f"\n\n[Video: {vid['title']}]({vid['link']}):\n{vid['transcript'][:1500]}"
|
| 288 |
+
if question.lower() in vid['transcript'].lower():
|
| 289 |
+
relevant_links.append(vid['link'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
with st.spinner("π Scraping icode.guru..."):
|
| 292 |
site_blocks = scrape_icodeguru(BASE_URL, max_pages=5)
|
|
|
|
| 300 |
st.success(answer)
|
| 301 |
|
| 302 |
if relevant_links:
|
| 303 |
+
st.markdown("### π Related YouTube Links")
|
| 304 |
+
for link in relevant_links:
|
| 305 |
+
st.markdown(f"- [Watch Video]({link})")
|
| 306 |
|
| 307 |
st.markdown("---")
|
| 308 |
st.caption("Powered by YouTube, iCodeGuru, and Groq")
|
| 309 |
+
|
| 310 |
+
if __name__ == "__main__":
|
| 311 |
+
main()
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
|