Spaces:
Build error
Build error
File size: 1,732 Bytes
35e36f1 |
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 |
#!/usr/bin/env python3
"""
Script de teste rápido para verificar conexão com API
"""
import requests
import json
API_URL = "http://localhost:7860"
print("🔍 Testando conexão com API...")
print("="*60)
# Teste 1: Status
print("\n1. Verificando status...")
try:
r = requests.get(f"{API_URL}/")
print(f" ✅ Status: {r.status_code}")
data = r.json()
print(f" RAG Ready: {data.get('rag_ready', False)}")
print(f" Setup: {data.get('setup', {}).get('status', 'N/A')}")
except Exception as e:
print(f" ❌ Erro: {e}")
# Teste 2: Setup status
print("\n2. Verificando setup...")
try:
r = requests.get(f"{API_URL}/setup/status")
print(f" ✅ Status: {r.status_code}")
data = r.json()
print(f" Progresso: {data.get('progress', 0)}%")
print(f" Mensagem: {data.get('message', 'N/A')}")
except Exception as e:
print(f" ❌ Erro: {e}")
# Teste 3: Busca (se pronto)
print("\n3. Testando busca semântica...")
try:
payload = {
"query": "teste",
"top_k": 3,
"return_embeddings": False
}
r = requests.post(
f"{API_URL}/search/embedding",
json=payload,
timeout=10
)
if r.status_code == 200:
data = r.json()
print(f" ✅ Busca OK!")
print(f" Total: {data.get('total_results', 0)} resultados")
print(f" Tempo: {data.get('query_time_ms', 0)}ms")
elif r.status_code == 503:
print(f" ⏳ RAG ainda não pronto (503)")
else:
print(f" ❌ Erro: {r.status_code}")
except Exception as e:
print(f" ❌ Erro: {e}")
print("\n" + "="*60)
print("✅ Testes completos!")
print("\nSe todos os testes passaram, rode:")
print(" python app_gradio.py")
|