File size: 2,576 Bytes
acd8e16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Manual model testing script for Hugging Face Inference API
"""

import requests
import os
import json

def test_model(model_id, prompt="Hello, how are you?"):
    """Test a model on the Hugging Face Inference API."""
    token = os.getenv("HF_TOKEN")
    if not token:
        print("❌ No HF_TOKEN found")
        return False
    
    headers = {"Authorization": f"Bearer {token}"}
    url = f"https://api-inference.huggingface.co/models/{model_id}"
    
    payload = {
        "inputs": prompt,
        "parameters": {
            "max_new_tokens": 50,
            "temperature": 0.1
        }
    }
    
    try:
        print(f"🧪 Testing {model_id}...")
        response = requests.post(url, headers=headers, json=payload, timeout=30)
        
        print(f"   Status: {response.status_code}")
        
        if response.status_code == 200:
            result = response.json()
            print(f"   ✅ Success: {str(result)[:100]}...")
            return True
        else:
            print(f"   ❌ Error: {response.text[:200]}...")
            return False
            
    except Exception as e:
        print(f"   ❌ Exception: {str(e)}")
        return False

def main():
    """Test various models to find working ones."""
    print("🔍 Testing Hugging Face Models")
    print("=" * 50)
    
    # Test models that are commonly available
    models_to_test = [
        "microsoft/DialoGPT-medium",
        "gpt2",
        "distilgpt2", 
        "microsoft/DialoGPT-small",
        "facebook/blenderbot-400M-distill",
        "Salesforce/codet5-small",
        "microsoft/codebert-base",
        "bigcode/starcoder",
        "codellama/CodeLlama-7b-Instruct-hf",
        "defog/sqlcoder-7b-2"
    ]
    
    working_models = []
    
    for model_id in models_to_test:
        if test_model(model_id):
            working_models.append(model_id)
        print()
    
    print("=" * 50)
    print(f"✅ Working models: {len(working_models)}")
    for model in working_models:
        print(f"   - {model}")
    
    if working_models:
        print("\n📝 Suggested config/models.yaml:")
        print("models:")
        for i, model_id in enumerate(working_models[:4], 1):
            name = model_id.split("/")[-1].replace("-", "_").replace(".", "_")
            print(f"""  - name: "{name}"
    provider: "huggingface"
    model_id: "{model_id}"
    params:
      max_new_tokens: 512
      temperature: 0.1
      top_p: 0.9
    description: "Working model from Hugging Face"
""")

if __name__ == "__main__":
    main()