-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·79 lines (62 loc) · 2.1 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·79 lines (62 loc) · 2.1 KB
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
#!/bin/bash
# Configuration
FOLDER="./tests"
BASE_URL="http://localhost:8040" # Serve files from 8040
ENDPOINT="http://localhost:8000/api/v1/rag/query"
AUTH_TOKEN="febc0daceda23ebce03d324301d34ad3768494f0b52a39ffb4adaf083d8f9c5c"
MINISERVE_PORT=8040
# Supported extensions
EXTENSIONS=("pdf" "docx" "xlsx" "pptx")
# Start miniserve in the background
echo "Starting miniserve on port $MINISERVE_PORT..."
miniserve "$FOLDER" --port $MINISERVE_PORT &
MINISERVE_PID=$!
# Wait for miniserve to be ready
sleep 1
PASS=0
FAIL=0
for ext in "${EXTENSIONS[@]}"; do
for doc in "$FOLDER"/*."$ext"; do
[ -f "$doc" ] || continue
base=$(basename "$doc" ".$ext")
txt="$FOLDER/${base}_${ext}.txt"
echo ""
echo "=========================================="
echo "Testing: $base.$ext"
echo "=========================================="
if [ ! -f "$txt" ]; then
echo "Warning: Missing $txt, skipping..."
continue
fi
questions=$(jq -Rs '[split("\n")[] | select(length > 0)]' < "$txt")
payload=$(jq -n \
--arg doc_path "$BASE_URL/$base.$ext" \
--argjson questions "$questions" \
'{documents: $doc_path, questions: $questions}'
)
echo "Payload: $payload"
response=$(curl -s -X POST "$ENDPOINT" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "$payload")
echo "Response: $response"
if echo "$response" | grep -q '"answers"'; then
echo "--- $base.$ext processed successfully ---"
PASS=$((PASS + 1))
else
echo "WARNING: $base.$ext may not have been processed successfully."
FAIL=$((FAIL + 1))
fi
done
done
echo ""
echo "=========================================="
echo "Results: $PASS passed, $FAIL failed"
echo "=========================================="
# Kill miniserve
echo "Killing miniserve (PID $MINISERVE_PID)..."
kill $MINISERVE_PID
if [ $FAIL -gt 0 ]; then
exit 1
fi