File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,19 +124,9 @@ CONTEXT_ARGS=()
124124if [ -n " $MODEL_NAME " ] && [ -n " $OPENAI_BASE_URL " ]; then
125125 SERVER_BASE=" ${OPENAI_BASE_URL%%/ v1* } "
126126 ctx_size=$( curl -sf " $SERVER_BASE /api/v1/health" 2> /dev/null \
127- | python3 -c "
128- import sys, json
129- model = '$MODEL_NAME '
130- try:
131- data = json.load(sys.stdin)
132- for m in data.get('all_models_loaded', []):
133- if m.get('model_name') == model:
134- v = m.get('recipe_options', {}).get('ctx_size', '')
135- if v: print(v)
136- break
137- except Exception:
138- pass
139- " 2> /dev/null)
127+ | jq -r --arg model " $MODEL_NAME " \
128+ ' .all_models_loaded[]? | select(.model_name == $model) | .recipe_options.ctx_size // empty' \
129+ 2> /dev/null | head -n1)
140130 if [ -n " $ctx_size " ] && [ " $ctx_size " -gt 0 ] 2> /dev/null; then
141131 tool_limit=$(( ctx_size / 8 ))
142132 [ " $tool_limit " -lt 8192 ] && tool_limit=8192
You can’t perform that action at this time.
0 commit comments