Commit
·
553f789
1
Parent(s):
3d14850
fix youtube in production and add more recursion limit
Browse files- .gitattributes +3 -0
- app.py +7 -12
- data/1f975693-876d-457b-a649-393859e79bf3.mp3 +3 -0
- data/7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx +3 -0
- data/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3 +3 -0
- data/9d191bce-651d-4746-be2d-7ef8ecadb9c2.mp4 +3 -0
- data/a1e91b78-d3d8-4675-bb8d-62741b4b68a6.mp4 +3 -0
- data/cca530fc-4052-43b2-b130-b30968d8aa44.png +0 -0
- data/f918266a-b3e0-4914-865d-4faa564f1aef.py +35 -0
- graph.py +5 -1
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.xlsx filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -16,15 +16,6 @@ import re
|
|
16 |
# --- Constants ---
|
17 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
18 |
|
19 |
-
import requests, logging, os
|
20 |
-
TEST_URL = "https://www.youtube.com/watch?v=L1vXCYZAYYM"
|
21 |
-
def test_youtube():
|
22 |
-
try:
|
23 |
-
r = requests.head(TEST_URL, timeout=8, allow_redirects=True)
|
24 |
-
logging.warning("YT status %s %s", r.status_code, r.url)
|
25 |
-
except Exception as e:
|
26 |
-
logging.error("YT check failed: %s", e)
|
27 |
-
|
28 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
29 |
"""
|
30 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
@@ -104,7 +95,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
104 |
for chunk in r.iter_content(chunk_size=8192):
|
105 |
if chunk: # evita keep-alives vacíos
|
106 |
f.write(chunk)
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
108 |
gcp_uri_file = upload_file_to_bucket(path_filename)
|
109 |
|
110 |
#submitted_answer = agent(question_text)
|
@@ -113,7 +109,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
113 |
"check_final_answer": False,
|
114 |
"path_filename": path_filename,
|
115 |
"gcp_path": gcp_uri_file},
|
116 |
-
{"recursion_limit":
|
117 |
|
118 |
submitted_answer = result['final_answer']
|
119 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
@@ -207,7 +203,6 @@ with gr.Blocks() as demo:
|
|
207 |
)
|
208 |
|
209 |
if __name__ == "__main__":
|
210 |
-
test_youtube()
|
211 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
212 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
213 |
space_host_startup = os.getenv("SPACE_HOST")
|
|
|
16 |
# --- Constants ---
|
17 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
20 |
"""
|
21 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
95 |
for chunk in r.iter_content(chunk_size=8192):
|
96 |
if chunk: # evita keep-alives vacíos
|
97 |
f.write(chunk)
|
98 |
+
|
99 |
+
#use youtube from data/ directory as scrapping doesn't work in spaces
|
100 |
+
if os.exists(f"data/{task_id}.mp4"):
|
101 |
+
path_filename = f"data/{task_id}.mp4"
|
102 |
+
|
103 |
+
if path_filename is not None:
|
104 |
gcp_uri_file = upload_file_to_bucket(path_filename)
|
105 |
|
106 |
#submitted_answer = agent(question_text)
|
|
|
109 |
"check_final_answer": False,
|
110 |
"path_filename": path_filename,
|
111 |
"gcp_path": gcp_uri_file},
|
112 |
+
{"recursion_limit": 30})
|
113 |
|
114 |
submitted_answer = result['final_answer']
|
115 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
|
|
203 |
)
|
204 |
|
205 |
if __name__ == "__main__":
|
|
|
206 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
207 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
208 |
space_host_startup = os.getenv("SPACE_HOST")
|
data/1f975693-876d-457b-a649-393859e79bf3.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:200f767e732b49efef5c05d128903ee4d2c34e66fdce7f5593ac123b2e637673
|
3 |
+
size 280868
|
data/7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:196b64ea8f72841cb0c4fc972ca82a28e74de926c402bb043305e12e05e012b7
|
3 |
+
size 5285
|
data/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b218c951c1f888f0bbe6f46c080f57afc7c9348fffc7ba4da35749ff1e2ac40f
|
3 |
+
size 179304
|
data/9d191bce-651d-4746-be2d-7ef8ecadb9c2.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dbd1ad3d2a2da43173c26d14bef4591b585fa1d541d6622c37d785e826d52a6b
|
3 |
+
size 1247103
|
data/a1e91b78-d3d8-4675-bb8d-62741b4b68a6.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2c52beb9924f94949983450a758f9fe8bd3e5c099c09eb2595934e02b31a4aae
|
3 |
+
size 8141554
|
data/cca530fc-4052-43b2-b130-b30968d8aa44.png
ADDED
![]() |
data/f918266a-b3e0-4914-865d-4faa564f1aef.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from random import randint
|
2 |
+
import time
|
3 |
+
|
4 |
+
class UhOh(Exception):
|
5 |
+
pass
|
6 |
+
|
7 |
+
class Hmm:
|
8 |
+
def __init__(self):
|
9 |
+
self.value = randint(-100, 100)
|
10 |
+
|
11 |
+
def Yeah(self):
|
12 |
+
if self.value == 0:
|
13 |
+
return True
|
14 |
+
else:
|
15 |
+
raise UhOh()
|
16 |
+
|
17 |
+
def Okay():
|
18 |
+
while True:
|
19 |
+
yield Hmm()
|
20 |
+
|
21 |
+
def keep_trying(go, first_try=True):
|
22 |
+
maybe = next(go)
|
23 |
+
try:
|
24 |
+
if maybe.Yeah():
|
25 |
+
return maybe.value
|
26 |
+
except UhOh:
|
27 |
+
if first_try:
|
28 |
+
print("Working...")
|
29 |
+
print("Please wait patiently...")
|
30 |
+
time.sleep(0.1)
|
31 |
+
return keep_trying(go, first_try=False)
|
32 |
+
|
33 |
+
if __name__ == "__main__":
|
34 |
+
go = Okay()
|
35 |
+
print(f"{keep_trying(go)}")
|
graph.py
CHANGED
@@ -79,7 +79,11 @@ def attach_data(state: TaskState) -> dict:
|
|
79 |
response = f"Path of the attached file: {path_filename}"
|
80 |
|
81 |
elif filename_type == 'youtube':
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
response = f"video GCP uri: {gcp_path}"
|
84 |
|
85 |
elif filename_type == 'audio':
|
|
|
79 |
response = f"Path of the attached file: {path_filename}"
|
80 |
|
81 |
elif filename_type == 'youtube':
|
82 |
+
if state.get('gcp_path'):
|
83 |
+
gcp_path = state["gcp_path"]
|
84 |
+
else:
|
85 |
+
_, gcp_path = download_youtube_video(router_decision.youtube_url, "video")
|
86 |
+
|
87 |
response = f"video GCP uri: {gcp_path}"
|
88 |
|
89 |
elif filename_type == 'audio':
|