Preload tiktoken encoding in Dockerfile (Lambda) (#220)
PR #193 added tiktoken preloading to Dockerfile_ecs but the same fix was not applied to the Lambda Dockerfile. This causes a ConnectTimeout error in network-restricted environments (e.g. Lambda in VPC without NAT Gateway) when tiktoken tries to download cl100k_base encoding at runtime from openaipublic.blob.core.windows.net. Cache the encoding at build time, consistent with Dockerfile_ecs. Related to #118
This commit is contained in:
@@ -9,6 +9,10 @@ COPY requirements.txt .
|
||||
|
||||
RUN pip3 install -r requirements.txt -U --no-cache-dir
|
||||
|
||||
# Preload tiktoken encoding: https://github.com/aws-samples/bedrock-access-gateway/issues/118
|
||||
ENV TIKTOKEN_CACHE_DIR=/var/task/.cache/tiktoken
|
||||
RUN python3 -c 'import tiktoken_ext.openai_public as tke; tke.cl100k_base()'
|
||||
|
||||
# Lambda Web Adapter requires overriding the Lambda base image entrypoint
|
||||
# to run the web app directly instead of the Lambda runtime handler
|
||||
ENTRYPOINT []
|
||||
|
||||
Reference in New Issue
Block a user