#!/bin/bash

# Function to check if Docker is running
docker_running() {
    docker info >/dev/null 2>&1
}

# Start Docker if it's not already running
if ! docker_running; then
    echo "Starting Docker..."
    open -a Docker
    
    # Wait for Docker to start
    while ! docker_running; do
        echo "Waiting for Docker to start..."
        sleep 5
    done
    echo "Docker is now running"
fi

# Get the script directory
script_dir=$(dirname "$0")
cd "$script_dir"

# Start the services defined in docker-compose.yml
echo "Starting services with Docker Compose..."
docker-compose up -d
echo "Waiting for services to start..."
sleep 20 

# Change to the directory containing Python script
cd "$script_dir/systex-RAG-sherry"
echo "Running RAG application..."
python ollama_chat.py

# 使脚本文件可执行：
# chmod +x run.sh

# /answer2?question=解釋碳排放法規

