mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
* fix(security): hash the publicly known master key Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: replace weak master key examples and regenerate artifacts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: replace weak key fixtures with generated test keys Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: generate master keys for proxy startup Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: preserve lens dev key entropy Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: restore proxy key compatibility in scrub examples Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: scrub merged SSO fixture and refresh dashboard bundle Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ci): stabilize test keys and metadata collection Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * chore: drop the rebuilt dashboard bundle Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: mateo <mateo@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
59 lines
2 KiB
Bash
Executable file
59 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# QA: code interpreter sandbox stickiness via metadata.session_id
|
|
# bash qa_sticky_session.sh
|
|
# LITELLM_BASE_URL=http://localhost:4000 LITELLM_KEY="$LITELLM_MASTER_KEY" bash qa_sticky_session.sh
|
|
|
|
set -euo pipefail
|
|
|
|
BASE="${LITELLM_BASE_URL:-http://localhost:4000}"
|
|
KEY="${LITELLM_KEY:-${LITELLM_MASTER_KEY:?set LITELLM_KEY or LITELLM_MASTER_KEY}}"
|
|
MODEL="${LITELLM_MODEL:-gpt-4o-mini}"
|
|
# proxy running at http://localhost:4000
|
|
SESSION_A="qa-session-$(date +%s)-A"
|
|
SESSION_B="qa-session-$(date +%s)-B"
|
|
|
|
content() {
|
|
echo "$1" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('choices',[{}])[0].get('message',{}).get('content','<error>'))"
|
|
}
|
|
|
|
call() {
|
|
local session="${1:-}" code="$2" meta=""
|
|
[[ -n "$session" ]] && meta=", \"metadata\": {\"session_id\": \"$session\"}"
|
|
curl -s -X POST "$BASE/chat/completions" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer $KEY" \
|
|
-d "{\"model\":\"$MODEL\"$meta,\"tools\":[{\"type\":\"code_interpreter\"}],\"messages\":[{\"role\":\"user\",\"content\":\"Run this Python code and tell me the result: $code\"}]}"
|
|
}
|
|
|
|
assert_match() {
|
|
local label="$1" body="$2" pattern="$3"
|
|
if echo "$body" | grep -qiE "$pattern"; then
|
|
echo "PASS $label"
|
|
else
|
|
echo "FAIL $label (expected /$pattern/)"
|
|
echo " $(content "$body")"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
echo "=== Sticky Session Sandbox QA ==="
|
|
echo "base: $BASE session A: $SESSION_A session B: $SESSION_B"
|
|
echo
|
|
|
|
R=$(call "$SESSION_A" "x = 42; print(x)")
|
|
assert_match "same session_id reuses sandbox (set x=42)" "$R" "42"
|
|
|
|
R=$(call "$SESSION_A" "print(x)")
|
|
assert_match "same session_id keeps state (x still 42)" "$R" "42"
|
|
|
|
R=$(call "$SESSION_B" "print(x)")
|
|
assert_match "different session_id is isolated" "$R" "not defined|NameError|undefined|error"
|
|
|
|
R=$(call "" "y = 99; print(y)")
|
|
assert_match "no session_id runs code" "$R" "99"
|
|
|
|
R=$(call "" "print(y)")
|
|
assert_match "no session_id gets fresh sandbox each request" "$R" "not defined|NameError|undefined|error"
|
|
|
|
echo
|
|
echo "All checks passed."
|