feat(eltex): three proxy models in /model, anth-glm-5.3 by default
Admins now give every key three models. ai-eltex maps them to the picker slots: - opus (default): anth-glm-5.3 - glm-5.3 on the Z.ai Anthropic endpoint: images via analyze_image, effort works, 1M window; - sonnet: zai-glm-5.3 - glm-5.3 on the OpenAI endpoint, no images or effort, 200K. Two keys get it as zai-glm-5.3-2-2 (zai-glm-5.3 is 403 for them), so the name is matched exactly or by prefix; - haiku: zai-glm-5.3-flash - fast, sees images itself, no effort, 200K; Claude Code also uses this slot for background tasks. A missing zai/flash model falls back to the default one. Model name is anth-glm-5.3 again: with anth-glm-5.3-5 the auto-logout would drop every saved key, since no key has that name now. Context window is per model instead of a global CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000: [1m] only on anth-glm-5.3 (Claude Code strips the suffix before the API call), 200K for the others, otherwise a long flash/zai session would hit "Prompt exceeds max length" instead of auto-compacting. Checked on all 6 pilot keys (19.10): default model reads a png via Read + analyze_image; sonnet/haiku answer with 200K windows; effort low on anth-glm-5.3 = 68 output tokens (max ~3500). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,25 +124,61 @@ test_eltex_claude_launcher() {
|
||||
# ── ai-eltex: модель берётся из /v1/models ключа ──────────────────────────
|
||||
test_eltex_model_from_key() {
|
||||
if echo "$ELTEX_SECTION" | grep -q '/v1/models' \
|
||||
&& echo "$ELTEX_SECTION" | grep -Fq 'model="${ELTEX_MODEL:-${model:-anth-glm-5.3-5}}"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -Fq '*" anth-glm-5.3-5 "*) echo "anth-glm-5.3-5"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -Fq 'model="${ELTEX_MODEL:-${model:-anth-glm-5.3}}"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -Fq 'pick("anth-glm-5.3", "anth-glm-5.3-")' \
|
||||
&& ! echo "$ELTEX_SECTION" | grep -q 'ids\[0\]' \
|
||||
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_OPUS_MODEL="$model"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_HAIKU_MODEL="$model"'; then
|
||||
ok "ai-eltex: uses anth-glm-5.3-5, never the first /v1/models entry (ELTEX_MODEL overrides)"
|
||||
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_OPUS_MODEL="$opus_model"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_SONNET_MODEL="$model_zai"' \
|
||||
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_HAIKU_MODEL="$model_flash"'; then
|
||||
ok "ai-eltex: anth-glm-5.3 by default, never the first /v1/models entry (ELTEX_MODEL overrides)"
|
||||
else
|
||||
fail "ai-eltex: must use anth-glm-5.3-5 (not the first /v1/models entry), ELTEX_MODEL overrides"
|
||||
fail "ai-eltex: must default to anth-glm-5.3 (not the first /v1/models entry), ELTEX_MODEL overrides"
|
||||
fi
|
||||
}
|
||||
|
||||
# ── ai-eltex: нет anth-glm-5.3-5 у ключа -> авто-логаут, свежий ключ не сохраняется ──
|
||||
# ── ai-eltex: три модели ключа по слотам пикера (имена с суффиксом тоже) ─────
|
||||
test_eltex_three_slots() {
|
||||
local tmp ok_run=1 out
|
||||
tmp=$(mktemp -d)
|
||||
mkdir -p "$tmp/bin" "$tmp/mock" "$tmp/home/.config/ai-setup"
|
||||
echo "$HELPERS_SECTION" | HELPERS_FILE="$tmp/bin/ai-api-helpers.sh" bash
|
||||
echo "$ELTEX_SECTION" | BIN_DIR="$tmp/bin" bash
|
||||
cat > "$tmp/mock/curl" <<'CURLEOF'
|
||||
#!/usr/bin/env bash
|
||||
printf '%s\n%s' "$MODELS_BODY" "200"
|
||||
CURLEOF
|
||||
cat > "$tmp/mock/claude" <<'CLAUDEEOF'
|
||||
#!/usr/bin/env bash
|
||||
echo "SLOTS opus=$ANTHROPIC_DEFAULT_OPUS_MODEL sonnet=$ANTHROPIC_DEFAULT_SONNET_MODEL haiku=$ANTHROPIC_DEFAULT_HAIKU_MODEL sub=$CLAUDE_CODE_SUBAGENT_MODEL"
|
||||
CLAUDEEOF
|
||||
chmod +x "$tmp/mock/curl" "$tmp/mock/claude"
|
||||
echo sk-test > "$tmp/home/.config/ai-setup/eltex_key"
|
||||
# Как у Бокова: zai-модель под именем с суффиксом, плюс имя группы доступа
|
||||
out=$(HOME="$tmp/home" PATH="$tmp/mock:$PATH" \
|
||||
MODELS_BODY='{"data":[{"id":"zai-glm-5.3-flash"},{"id":"anth-glm-5.3"},{"id":"zai-glm-5.3-2-2"},{"id":"ZAI-Test-Group"}]}' \
|
||||
bash "$tmp/bin/ai-eltex" 2>&1)
|
||||
echo "$out" | grep -Fq 'SLOTS opus=anth-glm-5.3[1m] sonnet=zai-glm-5.3-2-2 haiku=zai-glm-5.3-flash sub=anth-glm-5.3[1m]' || ok_run=0
|
||||
# Нет zai и flash - их слоты получают модель по умолчанию
|
||||
out=$(HOME="$tmp/home" PATH="$tmp/mock:$PATH" \
|
||||
MODELS_BODY='{"data":[{"id":"anth-glm-5.3"},{"id":"ZAI-Test-Group"}]}' \
|
||||
bash "$tmp/bin/ai-eltex" 2>&1)
|
||||
echo "$out" | grep -Fq 'SLOTS opus=anth-glm-5.3[1m] sonnet=anth-glm-5.3 haiku=anth-glm-5.3' || ok_run=0
|
||||
if [ "$ok_run" -eq 1 ]; then
|
||||
ok "ai-eltex: picker slots anth-glm-5.3[1m] / zai-glm-5.3* / zai-glm-5.3-flash, missing ones fall back to default"
|
||||
else
|
||||
fail "ai-eltex: picker slots must be anth-glm-5.3[1m] / zai-glm-5.3* / zai-glm-5.3-flash with fallback to default"
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# ── ai-eltex: нет anth-glm-5.3 у ключа -> авто-логаут, свежий ключ не сохраняется ──
|
||||
test_eltex_autologout_on_missing_model() {
|
||||
local tmp ok_run=1 rc=0 out
|
||||
tmp=$(mktemp -d)
|
||||
mkdir -p "$tmp/bin" "$tmp/mock" "$tmp/home/.config/ai-setup"
|
||||
echo "$HELPERS_SECTION" | HELPERS_FILE="$tmp/bin/ai-api-helpers.sh" bash
|
||||
echo "$ELTEX_SECTION" | BIN_DIR="$tmp/bin" bash
|
||||
# Прокси отвечает 200, но anth-glm-5.3-5 в списке моделей ключа нет
|
||||
# Прокси отвечает 200, но anth-glm-5.3 в списке моделей ключа нет
|
||||
cat > "$tmp/mock/curl" <<'CURLEOF'
|
||||
#!/usr/bin/env bash
|
||||
if [[ "$*" == *"/v1/models"* ]]; then
|
||||
@@ -159,10 +195,10 @@ CURLEOF
|
||||
MODELS_BODY='{"data":[{"id":"zai-glm-5.3-flash-2"},{"id":"ZAI-Test-Group"}]}' \
|
||||
bash "$tmp/bin/ai-eltex" 2>&1) || rc=$?
|
||||
[ "$rc" -eq 1 ] || ok_run=0
|
||||
echo "$out" | grep -q 'Ключу недоступна модель anth-glm-5.3-5' || ok_run=0
|
||||
echo "$out" | grep -q 'Ключу недоступна модель anth-glm-5.3' || ok_run=0
|
||||
echo "$out" | grep -q 'авто-логаут' || ok_run=0
|
||||
[ ! -f "$tmp/home/.config/ai-setup/eltex_key" ] || ok_run=0
|
||||
# Свежий ключ без anth-glm-5.3-5 не сохраняется вовсе
|
||||
# Свежий ключ без anth-glm-5.3 не сохраняется вовсе
|
||||
rc=0
|
||||
out=$(printf 'sk-new\n' | HOME="$tmp/home" PATH="$tmp/mock:$PATH" \
|
||||
MODELS_BODY='{"data":[{"id":"zai-glm-5.3-flash-2"}]}' \
|
||||
@@ -180,9 +216,9 @@ CURLEOF
|
||||
echo "$out" | grep -q 'Модель: anth-glm-5.3-2' || ok_run=0
|
||||
[ "$(cat "$tmp/home/.config/ai-setup/eltex_key")" = "sk-keep" ] || ok_run=0
|
||||
if [ "$ok_run" -eq 1 ]; then
|
||||
ok "ai-eltex: missing anth-glm-5.3-5 auto-logouts saved key, fresh key not saved, ELTEX_MODEL bypasses"
|
||||
ok "ai-eltex: missing anth-glm-5.3 auto-logouts saved key, fresh key not saved, ELTEX_MODEL bypasses"
|
||||
else
|
||||
fail "ai-eltex: missing anth-glm-5.3-5 must auto-logout (saved key removed, fresh key not saved, ELTEX_MODEL bypass)"
|
||||
fail "ai-eltex: missing anth-glm-5.3 must auto-logout (saved key removed, fresh key not saved, ELTEX_MODEL bypass)"
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
@@ -198,12 +234,13 @@ test_eltex_no_tool_search() {
|
||||
|
||||
# ── ai-eltex: окно 1M, как у ai-glm (иначе ctx: завышен в ~5 раз) ─────────
|
||||
test_eltex_context_window() {
|
||||
if echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000' \
|
||||
if echo "$ELTEX_SECTION" | grep -Fq 'anth-glm-5.3*) opus_model="${model}[1m]"' \
|
||||
&& ! echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_MAX_CONTEXT_TOKENS=' \
|
||||
&& ! echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_DISABLE_1M_CONTEXT=' \
|
||||
&& ! echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_AUTO_COMPACT_WINDOW='; then
|
||||
ok "ai-eltex: 1M context window, no 200K compact window / DISABLE_1M"
|
||||
ok "ai-eltex: 1M window only for anth-glm-5.3 via [1m], no global MAX_CONTEXT / DISABLE_1M"
|
||||
else
|
||||
fail "ai-eltex: must set CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000 without DISABLE_1M / AUTO_COMPACT_WINDOW"
|
||||
fail "ai-eltex: 1M only for anth-glm-5.3 via [1m], no global CLAUDE_CODE_MAX_CONTEXT_TOKENS / DISABLE_1M / AUTO_COMPACT_WINDOW"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -605,6 +642,7 @@ test_glm_official_api
|
||||
test_glm_default_effort
|
||||
test_eltex_claude_launcher
|
||||
test_eltex_model_from_key
|
||||
test_eltex_three_slots
|
||||
test_eltex_autologout_on_missing_model
|
||||
test_eltex_no_tool_search
|
||||
test_eltex_context_window
|
||||
|
||||
Reference in New Issue
Block a user