feat(ai-context-limit): add context window limit wasm plugin (#4000)

Signed-off-by: Cai Rui <cairui@U-7VTK6WQN-2207.local>
This commit is contained in:
yangjuan
2026-06-24 13:40:51 +08:00
committed by GitHub
parent 6d1c55c1fb
commit e958290283
17 changed files with 1870 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# prepare.sh — Download BPE vocabulary for ai-context-limit plugin.
# Called by Makefile, root Dockerfile, and root Makefile local-build.
set -e
BPE_DIR="bpe"
BPE_FILE="${BPE_DIR}/o200k_base.tiktoken"
BPE_URL="https://openaipublic.blob.core.windows.net/encodings/o200k_base.tiktoken"
if [ -f "$BPE_FILE" ]; then
exit 0
fi
mkdir -p "$BPE_DIR"
echo "Downloading o200k_base.tiktoken..."
if command -v curl >/dev/null 2>&1; then
curl -sSfL -o "$BPE_FILE" "$BPE_URL"
elif command -v wget >/dev/null 2>&1; then
wget -q -O "$BPE_FILE" "$BPE_URL"
else
echo "Error: curl or wget is required to download BPE vocabulary" >&2
exit 1
fi
echo "Downloaded ${BPE_FILE} ($(wc -c < "$BPE_FILE" | tr -d ' ') bytes)"