Spaces:
Sleeping
Sleeping
| # 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 | |