Talker / validate_deployment.sh
BolyosCsaba
fast api enabled
004ba20
#!/bin/bash
# Talker Deployment Validation Script
# Tests all OFP endpoints after deployment
BASE_URL="${1:-https://bladeszasza-talker.hf.space}"
echo "╔════════════════════════════════════════════════════════╗"
echo "β•‘ Talker OFP Endpoint Validation β•‘"
echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
echo ""
echo "Testing: $BASE_URL"
echo ""
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Test counter
PASSED=0
FAILED=0
# Function to test endpoint
test_endpoint() {
local test_name="$1"
local method="$2"
local endpoint="$3"
local data="$4"
echo -n "Testing: $test_name... "
if [ "$method" == "GET" ]; then
response=$(curl -s -w "\n%{http_code}" "$BASE_URL$endpoint")
else
response=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL$endpoint" \
-H "Content-Type: application/json" \
-d "$data")
fi
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | head -n-1)
if [ "$http_code" == "200" ]; then
echo -e "${GREEN}βœ“ PASSED${NC} (HTTP $http_code)"
((PASSED++))
return 0
else
echo -e "${RED}βœ— FAILED${NC} (HTTP $http_code)"
echo "Response: $body"
((FAILED++))
return 1
fi
}
# Test 1: Manifest Endpoint
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
test_endpoint "GET /manifest" "GET" "/manifest"
# Test 2: getManifests Event
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
test_endpoint "getManifests Event" "POST" "/ofp" '{
"openFloor": {
"schema": {"version": "1.0.0"},
"conversation": {"id": "conv:test-validation"},
"sender": {"speakerUri": "tag:test,2025:validator"},
"events": [{
"eventType": "getManifests",
"to": {"speakerUri": "tag:talker.service,2025:agent-01"}
}]
}
}'
# Test 3: Simple Utterance
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -n "Testing: Simple Utterance (Mistral)... "
response=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/ofp" \
-H "Content-Type: application/json" \
-d '{
"openFloor": {
"schema": {"version": "1.0.0"},
"conversation": {"id": "conv:validation-test"},
"sender": {"speakerUri": "tag:test,2025:validator"},
"events": [{
"eventType": "utterance",
"parameters": {
"dialogEvent": {
"id": "de:validation-001",
"speakerUri": "tag:test,2025:validator",
"span": {"startTime": "2025-01-11T14:00:00Z"},
"features": {
"text": {
"mimeType": "text/plain",
"tokens": [{"value": "Hello! Can you hear me?"}]
}
}
}
}
}]
}
}')
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | head -n-1)
if [ "$http_code" == "200" ]; then
echo -e "${GREEN}βœ“ PASSED${NC} (HTTP $http_code)"
((PASSED++))
# Check if response contains utterance
if echo "$body" | grep -q "utterance"; then
echo -e " ${GREEN}β†’ Mistral responded!${NC}"
else
echo -e " ${YELLOW}β†’ Response received but no utterance detected${NC}"
fi
else
echo -e "${RED}βœ— FAILED${NC} (HTTP $http_code)"
echo "Response: $body"
((FAILED++))
fi
# Test 4: Error Handling
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -n "Testing: Invalid Envelope (Error Handling)... "
response=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/ofp" \
-H "Content-Type: application/json" \
-d '{"invalid": "data"}')
http_code=$(echo "$response" | tail -n1)
if [ "$http_code" == "400" ]; then
echo -e "${GREEN}βœ“ PASSED${NC} (HTTP $http_code - Expected error)"
((PASSED++))
else
echo -e "${YELLOW}⚠ WARNING${NC} (HTTP $http_code - Expected 400)"
fi
# Summary
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Test Summary:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "Passed: ${GREEN}$PASSED${NC}"
echo -e "Failed: ${RED}$FAILED${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}βœ“ All tests passed! Talker is working correctly.${NC}"
exit 0
else
echo -e "${RED}βœ— Some tests failed. Check the output above.${NC}"
exit 1
fi