Spaces:
Sleeping
Sleeping
| # start.sh - Production launcher for Agentic Defensor | |
| # Set default mode to api | |
| MODE=${1:-api} | |
| # Process flags | |
| DEBUG="" | |
| for arg in "$@"; do | |
| if [ "$arg" == "--debug" ]; then | |
| DEBUG="--debug" | |
| fi | |
| done | |
| # Load environment variables from .env if it exists | |
| if [ -f .env ]; then | |
| source .env | |
| fi | |
| # Check API key is present | |
| if [ -z "$OPENAI_API_KEY" ]; then | |
| echo "ERROR: OPENAI_API_KEY not set. Please set it in .env file or as environment variable." | |
| exit 1 | |
| fi | |
| # Check for required files | |
| if [ ! -f "embeddings/faiss_index.index" ] || [ ! -f "data/doc_chunks.pkl" ] || [ ! -f "embeddings/embeddings.pkl" ]; then | |
| echo "WARNING: Required data files missing. Please ensure you have:" | |
| echo " - embeddings/faiss_index.index" | |
| echo " - data/doc_chunks.pkl" | |
| echo " - embeddings/embeddings.pkl" | |
| fi | |
| # Run with production settings | |
| case $MODE in | |
| api) | |
| echo "Starting API server on port 8000..." | |
| exec python3 -m uvicorn src.api.app:app --host 0.0.0.0 --port 8000 | |
| ;; | |
| interactive) | |
| echo "Starting interactive agent mode..." | |
| if [ ! -z "$DEBUG" ]; then | |
| echo "Debug mode enabled: Agent reasoning will be shown" | |
| exec python3 run.py --debug interactive --agent | |
| else | |
| exec python3 run.py interactive --agent | |
| fi | |
| ;; | |
| interactive-debug) | |
| echo "Starting interactive agent mode with reasoning..." | |
| exec python3 run.py --debug interactive --agent | |
| ;; | |
| cli) | |
| if [ -z "$2" ]; then | |
| echo "Error: Query required for CLI mode" | |
| echo "Usage: ./start.sh cli \"Your query here\"" | |
| exit 1 | |
| fi | |
| echo "Running CLI query: $2" | |
| if [ ! -z "$DEBUG" ]; then | |
| exec python3 run.py $DEBUG cli "$2" --top-k 50 | |
| else | |
| exec python3 run.py cli "$2" --top-k 50 | |
| fi | |
| ;; | |
| agent) | |
| if [ -z "$2" ]; then | |
| echo "Error: Query required for agent mode" | |
| echo "Usage: ./start.sh agent \"Your query here\"" | |
| exit 1 | |
| fi | |
| echo "Running agent query: $2" | |
| if [ ! -z "$DEBUG" ]; then | |
| exec python3 run.py $DEBUG agent "$2" --top-k 50 | |
| else | |
| exec python3 run.py agent "$2" --top-k 50 | |
| fi | |
| ;; | |
| agent-debug) | |
| if [ -z "$2" ]; then | |
| echo "Error: Query required for agent mode" | |
| echo "Usage: ./start.sh agent-debug \"Your query here\"" | |
| exit 1 | |
| fi | |
| echo "Running agent query with reasoning: $2" | |
| exec python3 run.py --debug agent "$2" --top-k 50 | |
| ;; | |
| *) | |
| echo "Unknown mode: $MODE" | |
| echo "Usage: ./start.sh [api|interactive|interactive-debug|cli|agent|agent-debug] [--debug]" | |
| echo "Examples:" | |
| echo " ./start.sh api # Start API server" | |
| echo " ./start.sh interactive # Start interactive mode" | |
| echo " ./start.sh interactive-debug # Start interactive mode with reasoning" | |
| echo " ./start.sh cli \"query\" # Run single query with standard agent" | |
| echo " ./start.sh agent \"query\" # Run single query with multi-agent system" | |
| echo " ./start.sh agent \"query\" --debug # Run query with reasoning steps" | |
| echo " ./start.sh agent-debug \"query\" # Run query with reasoning steps" | |
| exit 1 | |
| ;; | |
| esac |