File size: 2,039 Bytes
dda5c3b
 
 
 
 
 
 
 
 
0610fdd
dda5c3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Simple test script for the embedding API
"""

import requests
import json
import time

def test_api(base_url="https://aurasystems-spanish-embeddings-api.hf.space"):
    """Test the API endpoints"""
    
    print(f"Testing API at {base_url}")
    
    # Test root endpoint
    try:
        response = requests.get(f"{base_url}/")
        print(f"✓ Root endpoint: {response.status_code}")
        print(f"  Response: {response.json()}")
    except Exception as e:
        print(f"✗ Root endpoint failed: {e}")
        return False
    
    # Test health endpoint
    try:
        response = requests.get(f"{base_url}/health")
        print(f"✓ Health endpoint: {response.status_code}")
        health_data = response.json()
        print(f"  Models loaded: {health_data.get('models_loaded', False)}")
        print(f"  Available models: {health_data.get('available_models', [])}")
    except Exception as e:
        print(f"✗ Health endpoint failed: {e}")
    
    # Test models endpoint
    try:
        response = requests.get(f"{base_url}/models")
        print(f"✓ Models endpoint: {response.status_code}")
        models = response.json()
        print(f"  Found {len(models)} model definitions")
    except Exception as e:
        print(f"✗ Models endpoint failed: {e}")
    
    # Test embedding endpoint
    try:
        payload = {
            "texts": ["Hello world", "Test text"],
            "model": "jina",
            "normalize": True
        }
        response = requests.post(f"{base_url}/embed", json=payload)
        print(f"✓ Embed endpoint: {response.status_code}")
        if response.status_code == 200:
            data = response.json()
            print(f"  Generated {data.get('num_texts', 0)} embeddings")
            print(f"  Dimensions: {data.get('dimensions', 0)}")
        else:
            print(f"  Error: {response.text}")
    except Exception as e:
        print(f"✗ Embed endpoint failed: {e}")
    
    return True

if __name__ == "__main__":
    test_api()