File size: 2,931 Bytes
033e4ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
"""
Simple test script for Gemini wrapper functionality
"""
import sys
from pathlib import Path

# Add project root to path
sys.path.append(str(Path(__file__).parent))

def test_gemini_wrapper():
    """Test Gemini wrapper without API key"""
    print("Testing Gemini wrapper structure...")
    
    try:
        from src.core.gemini_client_wrapper import (
            GeminiClientWrapper, 
            GeminiChatCompletions, 
            GeminiResponse,
            HAS_GEMINI,
            create_gemini_client_for_markitdown
        )
        print("βœ… All classes imported successfully")
        print(f"βœ… HAS_GEMINI: {HAS_GEMINI}")
        
        # Test response structure
        test_response = GeminiResponse("Test image description")
        print(f"βœ… Response choices: {len(test_response.choices)}")
        print(f"βœ… Message content: {test_response.choices[0].message.content}")
        
        # Test client creation (should fail gracefully without API key)
        client = create_gemini_client_for_markitdown()
        print(f"βœ… Client creation (no API key): {client is None}")
        
    except Exception as e:
        print(f"❌ Error: {e}")
        import traceback
        traceback.print_exc()
        return False
    
    return True

def test_markitdown_availability():
    """Test MarkItDown availability"""
    print("\nTesting MarkItDown availability...")
    
    try:
        from markitdown import MarkItDown
        print("βœ… MarkItDown imported successfully")
        
        # Test basic initialization
        md = MarkItDown()
        print("βœ… MarkItDown initialized without LLM client")
        
    except Exception as e:
        print(f"❌ MarkItDown error: {e}")
        return False
    
    return True

def test_integration_structure():
    """Test the overall integration structure"""
    print("\nTesting integration structure...")
    
    try:
        # Test that our wrapper can theoretically work with MarkItDown
        from src.core.gemini_client_wrapper import GeminiClientWrapper, HAS_GEMINI
        from markitdown import MarkItDown
        
        print("βœ… Both components available for integration")
        
        # Test interface compatibility (structure only)
        if HAS_GEMINI:
            print("βœ… Gemini dependency available")
        else:
            print("⚠️  Gemini dependency not available")
            
        print("βœ… Integration structure test passed")
        
    except Exception as e:
        print(f"❌ Integration error: {e}")
        return False
    
    return True

if __name__ == "__main__":
    print("=== Testing Gemini-MarkItDown Integration ===\n")
    
    success = True
    success &= test_gemini_wrapper()
    success &= test_markitdown_availability() 
    success &= test_integration_structure()
    
    print(f"\n=== Overall Result: {'βœ… PASS' if success else '❌ FAIL'} ===")