File size: 1,378 Bytes
99dbc46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Configure bash error handling
set -euo pipefail

# Configuration
API_HOST="localhost"
API_PORT="8000"
API_VERSION="v1"
BASE_URL="http://${API_HOST}:${API_PORT}/api/${API_VERSION}"

# Function to generate test embedding data
generate_test_embedding() {
    python3 - <<EOF
import numpy as np
import json

# Generate a 4096-dimensional embedding vector (correct dimension for model)
embedding = np.random.randn(4096).astype(np.float32)
# Normalize the embedding
embedding = embedding / np.linalg.norm(embedding)
print(json.dumps(embedding.tolist()), end="")
EOF
}

# Function to test health endpoint
test_health() {
    echo "Testing health endpoint..."
    curl -s "${BASE_URL}/health" || {
        echo "Health check failed"
        exit 1
    }
}

# Function to test inference endpoint
test_inference() {
    echo
    start_time=$(date +%s)
    echo "Testing inference endpoint..."
    local embedding_data=$(generate_test_embedding)
    
    curl -X POST "${BASE_URL}/inference" \
        -H "Content-Type: application/json" \
        -d "{
            \"embedding\": ${embedding_data}
        }" || {
            echo "Inference request failed"
            exit 1
        }
    end_time=$(date +%s)
    duration=$((end_time - start_time))
    echo "Inference request completed in ${duration} seconds"
}

main() {
    test_health
    test_inference
}

main "$@"