Enhance RAG API to return token usage information and improve error h… #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Build Check | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build with Docker Compose | |
| run: | | |
| docker compose build | |
| - name: Verify builds completed | |
| run: | | |
| echo "✅ Docker Compose build completed successfully" | |
| docker images | grep memoryalpha-rag-api | |
| - name: Test health endpoint readiness | |
| run: | | |
| # Start services in background | |
| docker compose up -d | |
| # Wait for services to be ready (max 5 minutes) | |
| timeout 300 bash -c 'until curl -f http://localhost:8000/memoryalpha/health > /dev/null 2>&1; do sleep 5; echo "Waiting for API..."; done' | |
| # Verify health endpoint | |
| curl -f http://localhost:8000/memoryalpha/health | |
| echo "✅ Health check passed" | |
| - name: Test ask endpoint | |
| run: | | |
| # Test the ask endpoint with a simple query | |
| response=$(curl -X POST "http://localhost:8000/memoryalpha/rag/ask" -H "Content-Type: application/json" -d '{ | |
| "question": "What was the name of human who discovered warp drive?" | |
| }') | |
| # Check if response contains expected content | |
| if echo "$response" | grep -q "Zefram Cochrane"; then | |
| echo "✅ Ask endpoint test passed" | |
| else | |
| echo "❌ Ask endpoint test failed, answer did not contain expected content" | |
| echo "Response: $response" | |
| exit 1 | |
| fi | |
| - name: Generate OpenAPI spec | |
| run: | | |
| # Download OpenAPI spec | |
| curl -s http://localhost:8000/openapi.json -o memoryalpha-rag-api-spec.json | |
| cat memoryalpha-rag-api-spec.json | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| docker compose down -v | |
| docker system prune -f |