mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
Refactor start.sh: streamline model download and argument building
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Configuration / Defaults
|
|
||||||
MODEL_PATH="${BIERGARTEN_MODEL_PATH:-/workspace/models/google_gemma-4-E4B-it-Q6_K.gguf}"
|
MODEL_PATH="${BIERGARTEN_MODEL_PATH:-/workspace/models/google_gemma-4-E4B-it-Q6_K.gguf}"
|
||||||
OUTPUT_DIR="${BIERGARTEN_OUTPUT_DIR:-/workspace/output}"
|
OUTPUT_DIR="${BIERGARTEN_OUTPUT_DIR:-/workspace/output}"
|
||||||
LOG_PATH="${BIERGARTEN_LOG_PATH:-/workspace/logs/pipeline.log}"
|
LOG_PATH="${BIERGARTEN_LOG_PATH:-/workspace/logs/pipeline.log}"
|
||||||
@@ -10,50 +9,50 @@ PROMPT_DIR="/app/prompts"
|
|||||||
|
|
||||||
echo "--- Starting Biergarten Pipeline Environment Check ---"
|
echo "--- Starting Biergarten Pipeline Environment Check ---"
|
||||||
|
|
||||||
# 1. Ensure volume mount directories exist
|
# Ensure directories exist
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
mkdir -p "$(dirname "$LOG_PATH")"
|
mkdir -p "$(dirname "$LOG_PATH")"
|
||||||
|
|
||||||
# 3. Build the command arguments
|
|
||||||
ARGS=(
|
|
||||||
"--model" "$MODEL_PATH"
|
|
||||||
"--prompt-dir" "$PROMPT_DIR"
|
|
||||||
"--output" "$OUTPUT_DIR"
|
|
||||||
"--log-path" "$LOG_PATH"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Optional hyperparameters
|
|
||||||
[[ -n "$BIERGARTEN_TEMPERATURE" ]] && ARGS+=("--temperature" "$BIERGARTEN_TEMPERATURE")
|
|
||||||
[[ -n "$BIERGARTEN_TOP_P" ]] && ARGS+=("--top-p" "$BIERGARTEN_TOP_P")
|
|
||||||
[[ -n "$BIERGARTEN_TOP_K" ]] && ARGS+=("--top-k" "$BIERGARTEN_TOP_K")
|
|
||||||
[[ -n "$BIERGARTEN_N_CTX" ]] && ARGS+=("--n-ctx" "$BIERGARTEN_N_CTX")
|
|
||||||
[[ -n "$BIERGARTEN_SEED" ]] && ARGS+=("--seed" "$BIERGARTEN_SEED")
|
|
||||||
[[ -n "$BIERGARTEN_GL_LAYERS" ]] && ARGS+=("--n-gpu-layers" "$BIERGARTEN_GL_LAYERS")
|
|
||||||
|
|
||||||
# Append any extra custom args
|
|
||||||
if [[ -n "$BIERGARTEN_EXTRA_ARGS" ]]; then
|
|
||||||
ARGS+=($BIERGARTEN_EXTRA_ARGS)
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "--- Executing: $EXECUTABLE ${ARGS[*]} ---"
|
|
||||||
# 2. Ensure model directory exists
|
|
||||||
mkdir -p "$(dirname "$MODEL_PATH")"
|
mkdir -p "$(dirname "$MODEL_PATH")"
|
||||||
|
|
||||||
# 3. Download model if missing
|
# Download model if missing
|
||||||
if [ ! -f "$MODEL_PATH" ]; then
|
if [ ! -f "$MODEL_PATH" ]; then
|
||||||
echo "Model not found. Downloading..."
|
echo "Model not found. Downloading (this may take a while)..."
|
||||||
|
|
||||||
curl -L \
|
curl -L -C - \
|
||||||
-o "$MODEL_PATH" \
|
-o "$MODEL_PATH" \
|
||||||
"https://huggingface.co/bartowski/google_gemma-4-E4B-it-GGUF/resolve/main/google_gemma-4-E4B-it-Q6_K.gguf?download=true"
|
"https://huggingface.co/bartowski/google_gemma-4-E4B-it-GGUF/resolve/main/google_gemma-4-E4B-it-Q6_K.gguf?download=true"
|
||||||
|
|
||||||
echo "Download complete."
|
echo "Download complete."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4. Verify model exists
|
# Verify model exists
|
||||||
if [ ! -f "$MODEL_PATH" ]; then
|
if [ ! -f "$MODEL_PATH" ]; then
|
||||||
echo "ERROR: Model still not found after download attempt."
|
echo "ERROR: Model still not found after download attempt."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Execute the binary directly, replacing the shell process
|
|
||||||
|
# Default GPU layers
|
||||||
|
GL_LAYERS="${BIERGARTEN_GL_LAYERS:-40}"
|
||||||
|
|
||||||
|
# Build args
|
||||||
|
ARGS=(
|
||||||
|
"--model" "$MODEL_PATH"
|
||||||
|
"--prompt-dir" "$PROMPT_DIR"
|
||||||
|
"--output" "$OUTPUT_DIR"
|
||||||
|
"--log-path" "$LOG_PATH"
|
||||||
|
"--n-gpu-layers" "$GL_LAYERS"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optional params
|
||||||
|
[[ -n "$BIERGARTEN_TEMPERATURE" ]] && ARGS+=("--temperature" "$BIERGARTEN_TEMPERATURE")
|
||||||
|
[[ -n "$BIERGARTEN_TOP_P" ]] && ARGS+=("--top-p" "$BIERGARTEN_TOP_P")
|
||||||
|
[[ -n "$BIERGARTEN_TOP_K" ]] && ARGS+=("--top-k" "$BIERGARTEN_TOP_K")
|
||||||
|
[[ -n "$BIERGARTEN_N_CTX" ]] && ARGS+=("--n-ctx" "$BIERGARTEN_N_CTX")
|
||||||
|
[[ -n "$BIERGARTEN_SEED" ]] && ARGS+=("--seed" "$BIERGARTEN_SEED")
|
||||||
|
|
||||||
|
# Extra args
|
||||||
|
[[ -n "$BIERGARTEN_EXTRA_ARGS" ]] && ARGS+=($BIERGARTEN_EXTRA_ARGS)
|
||||||
|
|
||||||
|
echo "--- Executing: $EXECUTABLE ${ARGS[*]} ---"
|
||||||
|
|
||||||
exec "$EXECUTABLE" "${ARGS[@]}"
|
exec "$EXECUTABLE" "${ARGS[@]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user