File size: 1,043 Bytes
997480e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest
from gaia_agent import ModularGAIAAgent

@pytest.fixture
def agent():
    return ModularGAIAAgent()

def test_youtube_video_qa(monkeypatch, agent):
    # Mock subprocess, ASR, YOLO, BLIP, and extractive_qa
    monkeypatch.setattr("subprocess.run", lambda *a, **k: None)
    monkeypatch.setattr("cv2.VideoCapture", lambda *a, **k: type("C", (), {
        "get": lambda self, x: 10 if x == 7 else 1,  # 10 frames, 1 fps
        "set": lambda self, x, y: None,
        "read": lambda self: (True, __import__('numpy').zeros((10,10,3), dtype='uint8')),
        "release": lambda self: None
    })())
    monkeypatch.setattr("PIL.Image.fromarray", lambda arr: arr)
    agent.tools['extractive_qa'] = lambda q, c: "bird species: 5"
    # Simulate a YouTube question
    qobj = {"task_id": "yt1", "question": "In the video https://youtube.com/watch?v=abc123, what is the highest number of bird species to be on camera simultaneously?", "file_name": ""}
    answer, trace = agent.answer_question(qobj)
    assert "bird species" in answer