File size: 1,548 Bytes
d0d0769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c093af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail

if [ $# -lt 2 ]; then
  echo "Usage: $0 <base_url> <api_bearer_token>" >&2
  echo "Example: $0 https://dromerosm-ddgs.hf.space <token>" >&2
  exit 1
fi

BASE_URL="$1"
TOKEN="$2"

curl -s -X POST "$BASE_URL/search" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"openai","max_results":1,"region":"us-en","safesearch":"moderate","timelimit":"m","backend":"auto","timeout":30,"verify":true}' \
  | python -c 'import json,sys; payload=json.load(sys.stdin); print("OK", payload.get("count"))'

echo "Running 10 concurrent requests..."
VENDORS=(
  "OpenAI"
  "Anthropic"
  "Google"
  "Meta"
  "Microsoft"
  "Cohere"
  "Mistral"
  "AI21"
  "Perplexity"
  "xAI"
)

RESULTS_FILE="$(mktemp)"
for vendor in "${VENDORS[@]}"; do
  (
    curl -s -X POST "$BASE_URL/search" \
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json" \
      -d "{\"query\":\"$vendor LLM\",\"max_results\":1,\"region\":\"us-en\",\"safesearch\":\"moderate\",\"timelimit\":\"m\",\"backend\":\"auto\",\"timeout\":30,\"verify\":true}" \
      | python -c 'import json,sys; payload=json.load(sys.stdin); print(payload.get("count"))' \
      >> "$RESULTS_FILE"
  ) &
done
wait
RESULTS=$(cat "$RESULTS_FILE")
rm -f "$RESULTS_FILE"

if command -v rg >/dev/null 2>&1; then
  SUCCESS=$(printf "%s\n" "$RESULTS" | rg -c "^[0-9]+$")
else
  SUCCESS=$(printf "%s\n" "$RESULTS" | grep -E -c "^[0-9]+$")
fi
FAIL=$((10 - SUCCESS))
echo "Summary: total=10 success=$SUCCESS fail=$FAIL"