Update app.py
Browse files
app.py
CHANGED
|
@@ -76,21 +76,47 @@ def generate_summary(trans):
|
|
| 76 |
trails -= 1
|
| 77 |
return None
|
| 78 |
|
|
|
|
|
|
|
| 79 |
def setter(link):
|
|
|
|
| 80 |
yield gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), "", ""
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), "", ""
|
| 93 |
-
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), summary, vectorstore
|
| 94 |
|
| 95 |
def execute(vec, query):
|
| 96 |
try:
|
|
|
|
| 76 |
trails -= 1
|
| 77 |
return None
|
| 78 |
|
| 79 |
+
import traceback
|
| 80 |
+
|
| 81 |
def setter(link):
|
| 82 |
+
print(f"[INFO] Received link: {link}")
|
| 83 |
yield gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), "", ""
|
| 84 |
+
|
| 85 |
+
try:
|
| 86 |
+
video_id = video_id_extractor(link)
|
| 87 |
+
print(f"[INFO] Extracted video ID: {video_id}")
|
| 88 |
+
if not video_id:
|
| 89 |
+
print("[ERROR] Invalid video link")
|
| 90 |
+
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), "", ""
|
| 91 |
+
return
|
| 92 |
+
|
| 93 |
+
transcript = generate_transcript(video_id)
|
| 94 |
+
print(f"[INFO] Transcript length: {len(transcript) if transcript else 0}")
|
| 95 |
+
if not transcript:
|
| 96 |
+
print("[ERROR] Transcript generation failed")
|
| 97 |
+
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), "", ""
|
| 98 |
+
return
|
| 99 |
+
|
| 100 |
+
vectorstore = create_and_save_vs(transcript)
|
| 101 |
+
print("[INFO] Vectorstore created")
|
| 102 |
+
if not vectorstore:
|
| 103 |
+
print("[ERROR] Vectorstore creation failed")
|
| 104 |
+
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), "", ""
|
| 105 |
+
return
|
| 106 |
+
|
| 107 |
+
summary = generate_summary(transcript)
|
| 108 |
+
print(f"[INFO] Summary generated: {summary[:80] if summary else None}")
|
| 109 |
+
if not summary:
|
| 110 |
+
print("[ERROR] Summary generation failed")
|
| 111 |
+
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), "", ""
|
| 112 |
+
return
|
| 113 |
+
|
| 114 |
+
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), summary, vectorstore
|
| 115 |
+
|
| 116 |
+
except Exception as e:
|
| 117 |
+
print("[EXCEPTION in setter]:", e)
|
| 118 |
+
traceback.print_exc()
|
| 119 |
yield gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), "", ""
|
|
|
|
| 120 |
|
| 121 |
def execute(vec, query):
|
| 122 |
try:
|