Update crew.py
Browse files
crew.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
from crewai import Agent, Crew, Process, Task
|
| 3 |
from crewai.tools import tool
|
| 4 |
from crewai_tools import (
|
|
@@ -10,7 +10,7 @@ from openai import OpenAI
|
|
| 10 |
from openinference.instrumentation.crewai import CrewAIInstrumentor
|
| 11 |
from phoenix.otel import register
|
| 12 |
from pytubefix import YouTube
|
| 13 |
-
from util import get_final_answer, get_img_b64
|
| 14 |
|
| 15 |
## LLMs
|
| 16 |
|
|
@@ -171,23 +171,9 @@ def run_crew(question, file_path):
|
|
| 171 |
#stream = yt.streams.get_highest_resolution()
|
| 172 |
#stream.download(filename=file_path)
|
| 173 |
|
| 174 |
-
# Get
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
base64Frames = []
|
| 179 |
-
|
| 180 |
-
while video.isOpened():
|
| 181 |
-
success, frame = video.read()
|
| 182 |
-
|
| 183 |
-
if not success:
|
| 184 |
-
break
|
| 185 |
-
|
| 186 |
-
_, buffer = cv2.imencode(".jpg", frame)
|
| 187 |
-
|
| 188 |
-
base64Frames.append(base64.b64encode(buffer).decode("utf-8"))
|
| 189 |
-
|
| 190 |
-
video.release()
|
| 191 |
|
| 192 |
# OpenAI
|
| 193 |
|
|
@@ -196,7 +182,7 @@ def run_crew(question, file_path):
|
|
| 196 |
response = client.responses.create(
|
| 197 |
input=[{"role": "user",
|
| 198 |
"content": [{"type": "input_text", "text": (question)},
|
| 199 |
-
*[{"type": "input_image", "image_url": f"data:image/jpeg;base64,{
|
| 200 |
model=VIDEO_MODEL
|
| 201 |
)
|
| 202 |
|
|
|
|
| 1 |
+
import os
|
| 2 |
from crewai import Agent, Crew, Process, Task
|
| 3 |
from crewai.tools import tool
|
| 4 |
from crewai_tools import (
|
|
|
|
| 10 |
from openinference.instrumentation.crewai import CrewAIInstrumentor
|
| 11 |
from phoenix.otel import register
|
| 12 |
from pytubefix import YouTube
|
| 13 |
+
from util import get_final_answer, get_img_b64, get_imgs_b64
|
| 14 |
|
| 15 |
## LLMs
|
| 16 |
|
|
|
|
| 171 |
#stream = yt.streams.get_highest_resolution()
|
| 172 |
#stream.download(filename=file_path)
|
| 173 |
|
| 174 |
+
# Get images
|
| 175 |
+
|
| 176 |
+
imgs_b64 = get_imgs_b64(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
# OpenAI
|
| 179 |
|
|
|
|
| 182 |
response = client.responses.create(
|
| 183 |
input=[{"role": "user",
|
| 184 |
"content": [{"type": "input_text", "text": (question)},
|
| 185 |
+
*[{"type": "input_image", "image_url": f"data:image/jpeg;base64,{img_b64}"} for img_b64 in imgs_b64]]}],
|
| 186 |
model=VIDEO_MODEL
|
| 187 |
)
|
| 188 |
|