| | #!/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" |
| |
|