File size: 4,125 Bytes
3239c69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python3
"""
Debug script to test HuggingFace Inference API directly
"""

import os
import sys
from huggingface_hub import InferenceClient
import traceback

def test_model(model_name, prompt="Hello, how are you?"):
    """Test a specific model with the HuggingFace Inference API"""
    print(f"\nπŸ” Testing model: {model_name}")
    print("=" * 50)
    
    try:
        # Initialize client
        client = InferenceClient(model=model_name)
        print(f"βœ… Client initialized successfully")
        
        # Test text generation with various parameter sets
        print(f"πŸ“ Testing prompt: '{prompt}'")
        
        # Method 1: Full parameters (same as backend_service.py)
        try:
            print("\nπŸ”¬ Method 1: Full parameters")
            response = client.text_generation(
                prompt=prompt,
                max_new_tokens=50,
                temperature=0.7,
                top_p=0.95,
                return_full_text=False,
                stop=["Human:", "System:"]
            )
            print(f"βœ… Success: {response}")
            return True
            
        except Exception as e:
            print(f"❌ Method 1 failed: {e}")
            print(f"Error type: {type(e).__name__}")
            
        # Method 2: Minimal parameters
        try:
            print("\nπŸ”¬ Method 2: Minimal parameters")
            response = client.text_generation(
                prompt=prompt,
                max_new_tokens=50,
                temperature=0.7,
                return_full_text=False
            )
            print(f"βœ… Success: {response}")
            return True
            
        except Exception as e:
            print(f"❌ Method 2 failed: {e}")
            print(f"Error type: {type(e).__name__}")
            
        # Method 3: Basic parameters only
        try:
            print("\nπŸ”¬ Method 3: Basic parameters")
            response = client.text_generation(
                prompt=prompt,
                max_new_tokens=30
            )
            print(f"βœ… Success: {response}")
            return True
            
        except Exception as e:
            print(f"❌ Method 3 failed: {e}")
            print(f"Error type: {type(e).__name__}")
            print(f"Full traceback:")
            traceback.print_exc()
            
        return False
        
    except Exception as e:
        print(f"❌ Failed to initialize client: {e}")
        print(f"Error type: {type(e).__name__}")
        traceback.print_exc()
        return False

def test_model_info(model_name):
    """Test getting model information"""
    try:
        print(f"\nπŸ“Š Getting model info for: {model_name}")
        client = InferenceClient()
        # Try to get model info (this might not work for all models)
        print("βœ… Model appears to be accessible")
        return True
    except Exception as e:
        print(f"❌ Model info failed: {e}")
        return False

if __name__ == "__main__":
    # Set HuggingFace token if available
    hf_token = os.environ.get("HF_TOKEN")
    if hf_token:
        print(f"πŸ”‘ Using HF_TOKEN: {hf_token[:10]}...")
    else:
        print("⚠️  No HF_TOKEN found, using anonymous access")
    
    # Test models
    models_to_test = [
        "unsloth/DeepSeek-R1-0528-Qwen3-8B-GGUF",  # Current problematic model
        "microsoft/DialoGPT-medium",               # Known working model
        "meta-llama/Llama-2-7b-chat-hf",          # Popular model
        "HuggingFaceH4/zephyr-7b-beta"           # Another good model
    ]
    
    results = {}
    
    for model in models_to_test:
        print(f"\n{'='*60}")
        test_result = test_model(model)
        results[model] = test_result
        
        # Also test model info
        info_result = test_model_info(model)
        
        print(f"\nResult for {model}: {'βœ… WORKING' if test_result else '❌ FAILED'}")
    
    print(f"\n{'='*60}")
    print("SUMMARY:")
    print("="*60)
    for model, result in results.items():
        status = "βœ… WORKING" if result else "❌ FAILED"
        print(f"{model}: {status}")