#!/bin/bash set -e echo "๐Ÿš€ Starting Complete AI Agent Stack with Observability" echo "" # Check prerequisites command -v docker >/dev/null 2>&1 || { echo "โŒ Docker required but not installed." >&2; exit 1; } command -v docker compose >/dev/null 2>&1 || { echo "โŒ Docker Compose required but not installed." >&2; exit 1; } # Load environment variables if [ ! -f .env ]; then echo "โŒ .env file not found!" exit 1 fi echo "๐Ÿ“ฆ Building .NET application..." docker compose build api echo "" echo "๐Ÿ”ง Starting infrastructure services..." docker compose up -d postgres echo "โณ Waiting for PostgreSQL to be healthy..." sleep 10 docker compose up -d langfuse ollama echo "โณ Waiting for services to initialize..." sleep 20 echo "" echo "๐Ÿค– Pulling Ollama model (this may take a few minutes)..." docker exec ollama ollama pull qwen2.5-coder:7b || echo "โš ๏ธ Model pull failed, will retry on first request" echo "" echo "๐Ÿš€ Starting API service..." docker compose up -d api echo "" echo "๐Ÿ” Waiting for all services to be healthy..." for i in {1..30}; do api_health=$(curl -f -s http://localhost:6001/health 2>/dev/null || echo "fail") langfuse_health=$(curl -f -s http://localhost:3000/api/health 2>/dev/null || echo "fail") ollama_health=$(curl -f -s http://localhost:11434/api/tags 2>/dev/null || echo "fail") if [ "$api_health" != "fail" ] && [ "$langfuse_health" != "fail" ] && [ "$ollama_health" != "fail" ]; then echo "โœ… All services are healthy!" break fi echo " Waiting for services... ($i/30)" sleep 5 done echo "" echo "๐Ÿ“Š Services Status:" docker compose ps echo "" echo "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•" echo "๐ŸŽฏ Access Points:" echo " โ€ข HTTP API: http://localhost:6001/api/command/executeAgent" echo " โ€ข Swagger: http://localhost:6001/swagger" echo " โ€ข Langfuse UI: http://localhost:3000" echo " โ€ข Ollama: http://localhost:11434" echo "" echo "๐Ÿ“ Next Steps:" echo "1. Open Langfuse UI at http://localhost:3000" echo "2. Create an account and project" echo "3. Go to Settings โ†’ API Keys" echo "4. Copy the keys and update .env file:" echo " LANGFUSE_PUBLIC_KEY=pk-lf-your-key" echo " LANGFUSE_SECRET_KEY=sk-lf-your-key" echo "5. Restart API: docker compose restart api" echo "" echo "๐Ÿงช Test the agent:" echo " curl -X POST http://localhost:6001/api/command/executeAgent \\" echo " -H 'Content-Type: application/json' \\" echo " -d '{\"prompt\":\"What is 5 + 3?\"}'" echo "" echo "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"