|
|
|
""" |
|
Test script for hybrid model loading |
|
""" |
|
|
|
import requests |
|
import json |
|
import time |
|
|
|
def test_hybrid_api(base_url="https://aurasystems-spanish-embeddings-api.hf.space"): |
|
"""Test the hybrid API""" |
|
|
|
print(f"Testing hybrid API at {base_url}") |
|
|
|
|
|
try: |
|
response = requests.get(f"{base_url}/health") |
|
print(f"✓ Health endpoint: {response.status_code}") |
|
if response.status_code == 200: |
|
health_data = response.json() |
|
print(f" Startup models loaded: {health_data.get('startup_models_loaded', False)}") |
|
print(f" Available models: {health_data.get('available_models', [])}") |
|
print(f" Note: {health_data.get('note', 'N/A')}") |
|
else: |
|
print(f" Error: {response.text}") |
|
except Exception as e: |
|
print(f"✗ Health endpoint failed: {e}") |
|
return False |
|
|
|
|
|
try: |
|
payload = { |
|
"texts": ["Hola mundo", "Bonjour le monde"], |
|
"model": "jina-v3", |
|
"normalize": True |
|
} |
|
response = requests.post(f"{base_url}/embed", json=payload) |
|
print(f"✓ Startup model (jina-v3): {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"✗ Startup model test failed: {e}") |
|
|
|
|
|
try: |
|
payload = { |
|
"texts": ["Bon dia", "Com estàs?"], |
|
"model": "roberta-ca", |
|
"normalize": True |
|
} |
|
response = requests.post(f"{base_url}/embed", json=payload) |
|
print(f"✓ Startup model (roberta-ca): {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"✗ Startup model test failed: {e}") |
|
|
|
|
|
try: |
|
payload = { |
|
"texts": ["Texto en español"], |
|
"model": "jina", |
|
"normalize": True |
|
} |
|
response = requests.post(f"{base_url}/embed", json=payload) |
|
print(f"✓ On-demand model (jina): {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"✗ On-demand model test failed: {e}") |
|
|
|
|
|
try: |
|
response = requests.get(f"{base_url}/health") |
|
if response.status_code == 200: |
|
health_data = response.json() |
|
print(f"✓ Final health check:") |
|
print(f" All models loaded: {health_data.get('all_models_loaded', False)}") |
|
print(f" Available models: {health_data.get('available_models', [])}") |
|
except Exception as e: |
|
print(f"✗ Final health check failed: {e}") |
|
|
|
return True |
|
|
|
if __name__ == "__main__": |
|
test_hybrid_api() |