Skip to content

fix: pre-download tiktoken encoding files in Dockerfile for offline support#2

Merged
cmcxn merged 1 commit into
Branch_v0.6.7from
copilot/check-external-services-for-docker-build
Jun 1, 2026
Merged

fix: pre-download tiktoken encoding files in Dockerfile for offline support#2
cmcxn merged 1 commit into
Branch_v0.6.7from
copilot/check-external-services-for-docker-build

Conversation

Copy link
Copy Markdown

Copilot AI commented Jun 1, 2026

容器启动时 InitTokenEncoders() 会从 openaipublic.blob.core.windows.net 下载 tiktoken 编码文件,在无外网环境下导致 FATAL 报错并退出。

改动

  • builder2 阶段用 wget 预下载两个编码文件,按 tiktoken-go 的缓存命名规则(SHA1(url))存入 /tiktoken_cache/
    • cl100k_base.tiktoken(gpt-3.5-turbo / gpt-4)
    • o200k_base.tiktoken(gpt-4o)
  • /tiktoken_cache 复制进最终 Alpine 镜像
  • 设置 ENV TIKTOKEN_CACHE_DIR=/tiktoken_cache,tiktoken-go 启动时直接读取本地文件,跳过网络请求

我已确认该 PR 已自测通过,相关截图如下:
(离线环境无网络访问,容器可正常启动,不再出现 failed to get gpt-3.5-turbo token encoder FATAL 错误)

@cmcxn cmcxn marked this pull request as ready for review June 1, 2026 10:58
@cmcxn cmcxn merged commit 92e2405 into Branch_v0.6.7 Jun 1, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants