mirror of
https://github.com/alibaba/higress.git
synced 2026-06-26 02:35:02 +08:00
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:
27
plugins/wasm-go/extensions/ai-context-limit/prepare.sh
Executable file
27
plugins/wasm-go/extensions/ai-context-limit/prepare.sh
Executable 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)"
|
||||
Reference in New Issue
Block a user