#!/bin/bash # SkyTalk API - Manual Testing with curl # Run this script to test the API endpoints manually BASE_URL="http://localhost:8000" echo "🌟 SkyTalk API Manual Testing with curl" echo "========================================" # Test 1: Health check echo "" echo "🏥 Testing health check..." curl -s -X GET "$BASE_URL/health" | jq '.' || echo "Health check failed" # Test 2: Root endpoint echo "" echo "🏠 Testing root endpoint..." curl -s -X GET "$BASE_URL/" | jq '.' || echo "Root endpoint failed" # Test 3: Start session echo "" echo "🚀 Starting a new session..." SESSION_RESPONSE=$(curl -s -X POST "$BASE_URL/sessions/start" \ -H "Content-Type: application/json" \ -d '{"topic": "AI ethics in autonomous vehicles"}') echo $SESSION_RESPONSE | jq '.' # Extract session ID SESSION_ID=$(echo $SESSION_RESPONSE | jq -r '.session_id') echo "Session ID: $SESSION_ID" if [ "$SESSION_ID" = "null" ]; then echo "❌ Failed to start session" exit 1 fi # Test 4: Send messages echo "" echo "💬 Sending messages to the session..." MESSAGES=( "I'm concerned about how autonomous vehicles make ethical decisions" "What happens when a car has to choose between hitting one person or five people?" "I think we need clear guidelines and possibly government regulation" "Yes, I think we've covered the main ethical dilemmas I was thinking about" ) for message in "${MESSAGES[@]}"; do echo "" echo "Sending: $message" RESPONSE=$(curl -s -X POST "$BASE_URL/sessions/sendMessage" \ -H "Content-Type: application/json" \ -d "{\"session_id\": \"$SESSION_ID\", \"message\": \"$message\"}") echo $RESPONSE | jq '.' # Check if session ended STATUS=$(echo $RESPONSE | jq -r '.status') if [ "$STATUS" = "processing" ]; then echo "🔄 Session ended, synthesis should begin..." break fi # Wait a bit between messages sleep 2 done # Test 5: Check session status echo "" echo "📊 Checking session status..." for i in {1..5}; do echo "Status check #$i:" STATUS_RESPONSE=$(curl -s -X GET "$BASE_URL/sessions/getStatus?session_id=$SESSION_ID") echo $STATUS_RESPONSE | jq '.' STATUS=$(echo $STATUS_RESPONSE | jq -r '.status') if [ "$STATUS" = "completed" ]; then echo "✅ Synthesis completed!" break elif [ "$STATUS" = "failed" ]; then echo "❌ Synthesis failed!" break fi echo "Still processing... waiting 5 seconds" sleep 5 done echo "" echo "🎉 Manual testing completed!" echo "" echo "📚 Next steps:" echo " - Check the generated database: skytalk.db" echo " - Explore the vector store: chroma_db/" echo " - View API docs: $BASE_URL/docs"