mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-07 01:02:55 +08:00
aaa7d17ef1
* feat: encapsulate logger (#6535) * feat: encapsulate logger * update engines --------- Co-authored-by: archer <545436317@qq.com> * next config * dev shell * Agent sandbox (#6532) * docs: switch to docs layout and apply black theme (#6533) * feat: add Gemini 3.1 models - Add gemini-3.1-pro-preview (released February 19, 2026) - Add gemini-3.1-flash-lite-preview (released March 3, 2026) Both models support: - 1M context window - 64k max response - Vision - Tool choice * docs: switch to docs layout and apply black theme - Change layout from notebook to docs - Update logo to icon + text format - Apply fumadocs black theme - Simplify global.css (keep only navbar and TOC styles) - Fix icon components to properly accept className props - Add mobile text overflow handling - Update Node engine requirement to >=20.x * doc * doc * lock * fix: ts * doc * doc --------- Co-authored-by: archer <archer@archerdeMac-mini.local> Co-authored-by: archer <545436317@qq.com> * Doc (#6493) * cloud doc * doc refactor * doc move * seo * remove doc * yml * doc * fix: tsconfig * fix: tsconfig * sandbox version (#6497) * sandbox version * add sandbox log * update lock * fix * fix: sandbox * doc * add console * i18n * sandbxo in agent * feat: agent sandbox * lock * feat: sandbox ui * sandbox check exists * env tempalte * doc * lock * sandbox in chat window * sandbox entry * fix: test * rename var * sandbox config tip * update sandbox lifecircle * update prompt * rename provider test * sandbox logger * yml --------- Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local> * perf: sandbox error tip * Add sandbox limit and fix some issue (#6550) * sandbox in plan * fix: some issue * fix: test * editor default path * fix: comment * perf: sandbox worksapce * doc * perf: del sandbox * sandbox build * fix: test * fix: pr comment --------- Co-authored-by: Ryo <whoeverimf5@gmail.com> Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local>
79 lines
3.3 KiB
Bash
79 lines
3.3 KiB
Bash
#!/bin/bash
|
|
# FastGPT Sandbox Python 压测脚本
|
|
# 用法: SANDBOX_TOKEN=xxx ./bench-sandbox-python.sh
|
|
# CODE_SANDBOX_URL=http://host:3000 SANDBOX_TOKEN=xxx ./bench-sandbox-python.sh
|
|
|
|
set -eo pipefail
|
|
|
|
BASE="${CODE_SANDBOX_URL:-http://localhost:3000}"
|
|
TOKEN="${SANDBOX_TOKEN:-}"
|
|
DURATION="${BENCH_DURATION:-10}"
|
|
|
|
# 构建 npx autocannon 认证参数
|
|
AUTH_ARGS=""
|
|
if [ -n "$TOKEN" ]; then
|
|
AUTH_ARGS="-H Authorization=Bearer%20${TOKEN}"
|
|
fi
|
|
|
|
echo "========================================"
|
|
echo " FastGPT Sandbox Python 压测"
|
|
echo " 服务: $BASE"
|
|
echo " 认证: $([ -n "$TOKEN" ] && echo '已配置' || echo '未配置')"
|
|
echo "========================================"
|
|
|
|
# 健康检查
|
|
HEALTH=$(curl -sf "$BASE/health" 2>/dev/null) || {
|
|
echo "错误: Sandbox 服务未启动 ($BASE/health)"
|
|
exit 1
|
|
}
|
|
echo "健康状态: $(echo "$HEALTH" | grep -o '"status":"[^"]*"' || echo "$HEALTH")"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "▶ 测试 1: 普通函数 (简单计算)"
|
|
echo " 并发: 50 持续: ${DURATION}s"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
npx autocannon -c 50 -d "$DURATION" -m POST \
|
|
-H "Content-Type=application/json" \
|
|
$AUTH_ARGS \
|
|
-b '{"code":"def main(variables):\n return 1 + 1","variables":{}}' \
|
|
"${BASE}/sandbox/python"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "▶ 测试 2: 长时间IO函数 (sleep 500ms)"
|
|
echo " 并发: 50 持续: ${DURATION}s"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
npx autocannon -c 50 -d "$DURATION" -m POST \
|
|
-H "Content-Type=application/json" \
|
|
$AUTH_ARGS \
|
|
-b '{"code":"import time\ndef main(variables):\n time.sleep(0.5)\n return \"done\"","variables":{}}' \
|
|
"${BASE}/sandbox/python"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "▶ 测试 3: 高CPU函数 (大量计算)"
|
|
echo " 并发: 10 持续: ${DURATION}s"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
npx autocannon -c 10 -d "$DURATION" -m POST \
|
|
-H "Content-Type=application/json" \
|
|
$AUTH_ARGS \
|
|
-b '{"code":"import math\ndef main(variables):\n s=0\n for i in range(5000000):\n s+=math.sqrt(i)\n return s","variables":{}}' \
|
|
"${BASE}/sandbox/python"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "▶ 测试 4: 高内存函数 (大列表)"
|
|
echo " 并发: 10 持续: ${DURATION}s"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
npx autocannon -c 10 -d "$DURATION" -m POST \
|
|
-H "Content-Type=application/json" \
|
|
$AUTH_ARGS \
|
|
-b '{"code":"def main(variables):\n arr = [i*i for i in range(2000000)]\n return len(arr)","variables":{}}' \
|
|
"${BASE}/sandbox/python"
|
|
|
|
echo ""
|
|
echo "========================================"
|
|
echo " 压测完成!"
|
|
echo "========================================"
|