agentbee / test /test_smoke_hf_vision.py
mangubee's picture
fix: correct author name formatting in multiple files
e7b4937
#!/usr/bin/env python3
"""
Phase 2: Smoke Tests for HF Vision Integration
Author: @mangubee
Date: 2026-01-11
Quick validation that HF vision works before GAIA evaluation.
"""
import os
import sys
import logging
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from dotenv import load_dotenv
load_dotenv()
# Set HF provider for testing
os.environ["LLM_PROVIDER"] = "huggingface"
from src.tools.vision import analyze_image
# ============================================================================
# CONFIG
# ============================================================================
TEST_IMAGE = "test/fixtures/test_image_red_square.jpg"
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
# ============================================================================
# Smoke Test
# ============================================================================
def run_smoke_test():
"""Run single smoke test: simple image description."""
logger.info("=" * 60)
logger.info("PHASE 2: SMOKE TEST - HF Vision Integration")
logger.info("=" * 60)
logger.info(f"Test image: {TEST_IMAGE}")
logger.info(f"Provider: {os.getenv('LLM_PROVIDER')}")
logger.info(f"Model: {os.getenv('HF_VISION_MODEL', 'google/gemma-3-27b-it:scaleway')}")
logger.info("=" * 60)
try:
result = analyze_image(TEST_IMAGE, "What is in this image?")
logger.info("\n✅ SMOKE TEST PASSED")
logger.info("-" * 60)
logger.info(f"Model used: {result['model']}")
logger.info(f"Answer: {result['answer'][:200]}...")
logger.info("-" * 60)
return True
except Exception as e:
logger.error(f"\n❌ SMOKE TEST FAILED: {e}")
return False
if __name__ == "__main__":
success = run_smoke_test()
sys.exit(0 if success else 1)