跳至主要內容

Dify报错

pptg小于 1 分钟

1. 请求openaipublic.blob.cor.windows.net超时

1.1 问题

img.png
img.png

1.2 原因

是tiktoken的锅,tiktoken_ext/openai_public.py#L17会去下载gpt2的分词器

而dify在python/dify_plugin/interfaces/model/ai_model.py#L281引用了gpt2的分词器

1.3 解决

进入plugin容器的挂载目录,将openai的相关文件离线下载下来

cd /app/storage/
mkdir .tiktoken_cache
cd .tiktoken_cache
wget https://openaipublic.blob.core.windows.net/gpt-2/encodings/main/vocab.bpe
cp vocab.bpe 6d1cbeee0f20b3d9449abfede4726ed8212e3aee
wget https://openaipublic.blob.core.windows.net/gpt-2/encodings/main/encoder.json
cp encoder.json 6c7ea1a7e38e3a7f062df639a5b80947f075ffe6

挂到Plugin容器上

  plugin_daemon:
    image: langgenius/dify-plugin-daemon:0.0.5-local
    restart: always
    environment:
      # Use the shared environment variables.
      <<: *shared-api-worker-env
      ...
      TIKTOKEN_CACHE_DIR: /app/storage/.tiktoken_cache
    ports:
      - "${EXPOSE_PLUGIN_DEBUGGING_PORT:-5003}:${PLUGIN_DEBUGGING_PORT:-5003}"
    volumes:
      - ./volumes/plugin_daemon:/app/storage
    depends_on:
      - db