Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -163,34 +163,7 @@ if prompt := st.chat_input("ใกใใปใผใธใๅ
ฅๅใใฆใใ ใใ"):
|
|
| 163 |
full_response = chain.invoke({"text": text_to_summarize})["text"]
|
| 164 |
message_placeholder.markdown(full_response)
|
| 165 |
|
| 166 |
-
|
| 167 |
-
elif mode == "video":
|
| 168 |
-
search_results = tavily_client.search(f"{prompt} site:youtube.com", search_depth="basic", include_images=True)
|
| 169 |
-
videos = [result for result in search_results["results"]
|
| 170 |
-
if "youtube.com" in result["url"]]
|
| 171 |
-
if videos:
|
| 172 |
-
for video in videos[:4]:
|
| 173 |
-
video_url = video['url']
|
| 174 |
-
video_id = None
|
| 175 |
-
youtube_patterns = [
|
| 176 |
-
r"(?<=v=)[^]+",
|
| 177 |
-
r"(?<=be/)[^]+",
|
| 178 |
-
r"(?<=embed/)[^]+"
|
| 179 |
-
]
|
| 180 |
-
for pattern in youtube_patterns:
|
| 181 |
-
match = re.search(pattern, video_url)
|
| 182 |
-
if match:
|
| 183 |
-
video_id = match.group()
|
| 184 |
-
break
|
| 185 |
-
if video_id:
|
| 186 |
-
st.markdown(f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>', unsafe_allow_html=True)
|
| 187 |
-
st.markdown(f"้ข้ฃๅ็ป: {video['title']}")
|
| 188 |
-
else:
|
| 189 |
-
st.warning(f"ๅ็ปIDใๆฝๅบใงใใพใใใงใใ: {video_url}")
|
| 190 |
-
else:
|
| 191 |
-
full_response = "้ข้ฃๅ็ปใ่ฆใคใใใพใใใงใใใ"
|
| 192 |
-
message_placeholder.markdown(full_response)
|
| 193 |
-
|
| 194 |
|
| 195 |
# ใณใใผๆฉ่ฝใฎ่ฟฝๅ
|
| 196 |
if st.button("๐ ็ๆใใใใใญในใใใณใใผ"):
|
|
|
|
| 163 |
full_response = chain.invoke({"text": text_to_summarize})["text"]
|
| 164 |
message_placeholder.markdown(full_response)
|
| 165 |
|
| 166 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
# ใณใใผๆฉ่ฝใฎ่ฟฝๅ
|
| 169 |
if st.button("๐ ็ๆใใใใใญในใใใณใใผ"):
|