#!/usr/bin/env bash # model-for-opencode entrypoint. Runs inside the container; takes no arguments. # The weights are at /weights/qwen3-4b (read-only); nothing is fetched at run time. set -eu echo '{"phase":"loading","detail":"loading Qwen3 4B into the GPU"}' >> "$M64_STATUS" # Every setting is here, fixed: callers can't change them (a chat capsule only # accepts messages, tools, tool_choice, response_format, max_tokens, stream, seed). # --jinja use the model's own chat template: needed for tool calls, # which is how opencode reads files and runs commands # --ctx-size 32768 opencode's system prompt and tools take ~10k tokens # -ngl 999 every layer on the GPU # -fa on + q8_0 KV cache halves the KV cache's memory, so 32k fits in ~6 GB # --host 0.0.0.0 inside the container's own network: only m64's front # and gate can reach it exec /app/llama-server \ --model /weights/qwen3-4b/Qwen3-4B-Q4_K_M.gguf \ --alias qwen3-4b \ --jinja \ --ctx-size 32768 \ -ngl 999 \ -fa on \ --cache-type-k q8_0 --cache-type-v q8_0 \ --host 0.0.0.0 --port "$M64_PORT"