#!/usr/bin/env bash # Exit on error, undefined variables, and print commands set -e # Default values (can be overridden by command-line arguments) SESSION_NAME="${1:-textgen}" LITELLM_PORT="${2:-8031}" if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then echo "Session '$SESSION_NAME' already exists. No action taken." exit 0 fi # Check if session already exists if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then # Create new detached session tmux new-session -d -s "$SESSION_NAME" # Start the open-webui server in its own virtual environment tmux send-keys -t "$SESSION_NAME" "source .venv_open_webui/bin/activate.fish && open-webui serve" C-m # Start litellm in a new pane with its own virtual environment tmux split-window -v -t "$SESSION_NAME" tmux send-keys -t "$SESSION_NAME" "source .venv_litellm/bin/activate.fish && source .env && litellm --telemetry False --config ./litellm.yaml --host 127.0.0.1 --port $LITELLM_PORT" C-m echo "Session '$SESSION_NAME' created and configured. To connect, type: tmux attach -t $SESSION_NAME" else echo "Session '$SESSION_NAME' already exists. Exiting." exit 1 fi