Commit
·
fba8c96
1
Parent(s):
aa94df3
Update agent prompt
Browse files
agent.py
CHANGED
|
@@ -9,8 +9,9 @@ from tools import (
|
|
| 9 |
excel_reader,
|
| 10 |
math_calculator,
|
| 11 |
search_engine,
|
| 12 |
-
|
| 13 |
YoutubeTranscriberTool,
|
|
|
|
| 14 |
)
|
| 15 |
from utils import OPENAI_MODEL_ID
|
| 16 |
|
|
@@ -29,6 +30,12 @@ Each question will contain the question, the task ID, and if available, a file n
|
|
| 29 |
Key points:
|
| 30 |
- Do not add any prefix or suffix to YOUR FINAL ANSWER.
|
| 31 |
- Answer shortly and concisely, following the template strictly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
"""
|
| 33 |
|
| 34 |
|
|
@@ -47,8 +54,9 @@ class MainAgent:
|
|
| 47 |
txt_reader,
|
| 48 |
pdf_reader,
|
| 49 |
excel_reader,
|
| 50 |
-
|
| 51 |
YoutubeTranscriberTool(),
|
|
|
|
| 52 |
],
|
| 53 |
max_steps=5,
|
| 54 |
model=model,
|
|
|
|
| 9 |
excel_reader,
|
| 10 |
math_calculator,
|
| 11 |
search_engine,
|
| 12 |
+
image_analyzer,
|
| 13 |
YoutubeTranscriberTool,
|
| 14 |
+
YoutubeVideoDescriptorTool,
|
| 15 |
)
|
| 16 |
from utils import OPENAI_MODEL_ID
|
| 17 |
|
|
|
|
| 30 |
Key points:
|
| 31 |
- Do not add any prefix or suffix to YOUR FINAL ANSWER.
|
| 32 |
- Answer shortly and concisely, following the template strictly.
|
| 33 |
+
- Again, YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 34 |
+
|
| 35 |
+
Example:
|
| 36 |
+
[Final Answer: 42]
|
| 37 |
+
Good example: "42"
|
| 38 |
+
Bad example: "The answer is 42"
|
| 39 |
"""
|
| 40 |
|
| 41 |
|
|
|
|
| 54 |
txt_reader,
|
| 55 |
pdf_reader,
|
| 56 |
excel_reader,
|
| 57 |
+
image_analyzer,
|
| 58 |
YoutubeTranscriberTool(),
|
| 59 |
+
YoutubeVideoDescriptorTool(),
|
| 60 |
],
|
| 61 |
max_steps=5,
|
| 62 |
model=model,
|
tools.py
CHANGED
|
@@ -308,9 +308,8 @@ class YoutubeVideoDescriptorTool(Tool): # pylint: disable=C0115
|
|
| 308 |
if not ret:
|
| 309 |
break
|
| 310 |
|
| 311 |
-
# Keep every Nth frame to reduce to target_fps
|
| 312 |
if i % frame_interval == 0:
|
| 313 |
-
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
| 314 |
|
| 315 |
i += 1
|
| 316 |
|
|
@@ -321,9 +320,13 @@ class YoutubeVideoDescriptorTool(Tool): # pylint: disable=C0115
|
|
| 321 |
_, buffer = cv2.imencode(".jpg", frame)
|
| 322 |
encoded_buffer = base64.b64encode(buffer).decode("utf-8")
|
| 323 |
base64_frames.append(encoded_buffer)
|
| 324 |
-
if len(base64_frames) == 20:
|
|
|
|
| 325 |
yield base64_frames
|
| 326 |
base64_frames = []
|
|
|
|
|
|
|
|
|
|
| 327 |
|
| 328 |
def forward(self, task: str, youtube_url: str) -> str: # pylint: disable=W0221
|
| 329 |
file_name = f"{uuid4()}.mp4"
|
|
|
|
| 308 |
if not ret:
|
| 309 |
break
|
| 310 |
|
|
|
|
| 311 |
if i % frame_interval == 0:
|
| 312 |
+
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
| 313 |
|
| 314 |
i += 1
|
| 315 |
|
|
|
|
| 320 |
_, buffer = cv2.imencode(".jpg", frame)
|
| 321 |
encoded_buffer = base64.b64encode(buffer).decode("utf-8")
|
| 322 |
base64_frames.append(encoded_buffer)
|
| 323 |
+
if len(base64_frames) == 20:
|
| 324 |
+
# yield every 20 frames
|
| 325 |
yield base64_frames
|
| 326 |
base64_frames = []
|
| 327 |
+
# yield any remaining frames
|
| 328 |
+
if len(frames) < 20:
|
| 329 |
+
yield base64_frames
|
| 330 |
|
| 331 |
def forward(self, task: str, youtube_url: str) -> str: # pylint: disable=W0221
|
| 332 |
file_name = f"{uuid4()}.mp4"
|