From 3d0dedc51e25b1b530d8270d410938dac64e3ce6 Mon Sep 17 00:00:00 2001 From: Autumn-27 <53844290+Autumn-27@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:18:51 -0400 Subject: [PATCH] =?UTF-8?q?feat(bench):=20seed=20=E5=8F=8C=20LLM=20profile?= =?UTF-8?q?=E2=80=94=E2=80=94planner=20=E7=BB=91=E5=BC=BA=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E3=80=81worker=20=E7=BB=91=E5=BC=B1=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E3=80=81=E9=BB=98=E8=AE=A4=E6=BF=80=E6=B4=BB=E5=BC=B1=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来只建 1 个 benchmark profile 全局共用。现改为: - 建 plan(LLM_MODEL_PLAN)/work(LLM_MODEL_WORK) 两个 profile,共用同一网关/密钥/格式 - 分别绑定 planner→plan、worker→work(PUT /api/agents/{key}/config llm_profile_id) - 全局激活默认 = work,未绑定的编排 agent(tec_benchmark/challenge_review)走弱模型 - .env(.example) 新增 LLM_MODEL_PLAN/WORK,缺省回退旧 LLM_MODEL,向后兼容 --- bench/.env.example | 7 ++++++- bench/seed.sh | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/bench/.env.example b/bench/.env.example index ac43002..e70c6ab 100644 --- a/bench/.env.example +++ b/bench/.env.example @@ -4,8 +4,13 @@ # 管理员密码(首次进 UI / seed 登录用) ADMIN_PASSWORD=artexbench -# ---- LLM(腾讯 tokenhub 网关,deepseek-v4-flash,openai 兼容格式) ---- +# ---- LLM(腾讯 tokenhub 网关,openai 兼容格式) ---- +# 双模型:planner 走强模型(plan)、worker 走弱模型(work),共用同一网关/密钥/格式。 +# 全局默认激活 = work(弱模型),未绑定的 agent(编排等)都走它;planner/worker 各自绑定不受影响。 LLM_FORMAT=openai +LLM_MODEL_PLAN=deepseek-pro +LLM_MODEL_WORK=deepseek-flash +# 兼容旧的单一变量:若未设 LLM_MODEL_PLAN/WORK,则两者都回退到 LLM_MODEL。 LLM_MODEL=deepseek-v4-flash # 本地测评直接用 https;托管模式改成网关形式 http://tokenhub.tencentmaas.com.tsecbench.gw/ LLM_BASE_URL=https://tokenhub.tencentmaas.com/ diff --git a/bench/seed.sh b/bench/seed.sh index 46ef395..2f52dbf 100644 --- a/bench/seed.sh +++ b/bench/seed.sh @@ -99,18 +99,41 @@ echo '{"enabled":true,"on_task_timeout":true,"task_timeout_message":"有题目 echo '{"enabled":true,"on_task_create":true,"task_create_message":"有新题目任务被创建:检查历史是否做过同一 unique_code,若有则复用其事实/经验,通过 hint 注入本任务(忽略 base url 差异)。"}' \ | post /api/agents/challenge_review/triggers "trigger challenge_review on_task_create" -# ---------- 6) LLM:建 profile → 测连通 → 激活 ---------- +# ---------- 6) LLM:建两个 profile(plan 强模型 / work 弱模型) → 测连通 → 绑定 agent → 激活默认 ---------- +# 共用同一网关/密钥/格式,仅模型名不同:planner 走强模型(plan)、worker 走弱模型(work)。 +# 运行时模型解析优先级:Agent 绑定 > 任务/会话 pin > 全局激活。planner/worker 各自绑定后走 +# 各自 profile;未绑定的 agent(编排 tec_benchmark / challenge_review 等)走全局激活的默认(work)。 log "配置 LLM ..." -PID="$(jq -n --arg f "$LLM_FORMAT" --arg m "$LLM_MODEL" --arg u "${LLM_BASE_URL:-}" --arg k "${LLM_API_KEY:-}" \ - '{name:"benchmark",format:$f,model:$m,base_url:$u,api_key:$k,reasoning_effort:""}' \ - | curl -s -X POST "$API/api/llm/profiles" -H "$AUTH" -H "$CT" --data-binary @- | jq -r '.id // empty')" -log " profile id=$PID (thinking=默认/由模型决定)" -TEST="$(jq -n --arg f "$LLM_FORMAT" --arg m "$LLM_MODEL" --arg u "${LLM_BASE_URL:-}" --arg k "${LLM_API_KEY:-}" \ - '{provider:$f,model:$m,base_url:$u,api_key:$k,reasoning_effort:""}' \ - | curl -s -X POST "$API/api/llm/test" -H "$AUTH" -H "$CT" --data-binary @-)" -log " 测试连通: $TEST" -if [ -n "$PID" ]; then - echo "{\"id\":$PID}" | post /api/llm/profiles/active "activate profile $PID" +# 模型名:优先用专用变量;缺省回退旧的单一 LLM_MODEL;再回退字面默认。 +LLM_MODEL_PLAN="${LLM_MODEL_PLAN:-${LLM_MODEL:-deepseek-pro}}" +LLM_MODEL_WORK="${LLM_MODEL_WORK:-${LLM_MODEL:-deepseek-flash}}" + +make_profile() { # $1=profile 名 $2=模型名 → stdout: 新建 profile 的 id + jq -n --arg n "$1" --arg f "$LLM_FORMAT" --arg m "$2" --arg u "${LLM_BASE_URL:-}" --arg k "${LLM_API_KEY:-}" \ + '{name:$n,format:$f,model:$m,base_url:$u,api_key:$k,reasoning_effort:""}' \ + | curl -s -X POST "$API/api/llm/profiles" -H "$AUTH" -H "$CT" --data-binary @- | jq -r '.id // empty' +} +test_llm() { # $1=模型名 → stdout: 连通测试结果 + jq -n --arg f "$LLM_FORMAT" --arg m "$1" --arg u "${LLM_BASE_URL:-}" --arg k "${LLM_API_KEY:-}" \ + '{provider:$f,model:$m,base_url:$u,api_key:$k,reasoning_effort:""}' \ + | curl -s -X POST "$API/api/llm/test" -H "$AUTH" -H "$CT" --data-binary @- +} + +PLAN_PID="$(make_profile plan "$LLM_MODEL_PLAN")" +WORK_PID="$(make_profile work "$LLM_MODEL_WORK")" +log " plan profile id=$PLAN_PID model=$LLM_MODEL_PLAN" +log " work profile id=$WORK_PID model=$LLM_MODEL_WORK" +log " 测试 plan 连通: $(test_llm "$LLM_MODEL_PLAN")" +log " 测试 work 连通: $(test_llm "$LLM_MODEL_WORK")" + +# 绑定 agent 级默认模型:planner→plan、worker→work(llm_profile_id 三态,此处传数字=绑定)。 +[ -n "$PLAN_PID" ] && echo "{\"llm_profile_id\":$PLAN_PID}" | post /api/agents/planner/config "bind planner→plan#$PLAN_PID" PUT +[ -n "$WORK_PID" ] && echo "{\"llm_profile_id\":$WORK_PID}" | post /api/agents/worker/config "bind worker→work#$WORK_PID" PUT + +# 全局激活默认 profile = work(弱模型):未绑定的 agent(编排 tec_benchmark / challenge_review 等)都走它。 +# planner/worker 已各自绑定,不受此默认影响(Agent 绑定优先级更高)。 +if [ -n "$WORK_PID" ]; then + echo "{\"id\":$WORK_PID}" | post /api/llm/profiles/active "activate default profile work#$WORK_PID" fi log "seed 完成。"