[PR #866] [MERGED] Remove transformers dependencies on Llama API plugin #1599

Closed
opened 2026-02-16 10:23:26 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/866
Author: @Riandy
Created: 5/6/2025
Status: Merged
Merged: 5/6/2025
Merged by: @crazywoola

Base: mainHead: llama-api-fix-transformers


📝 Commits (1)

  • d11c1a3 Remove transformers dependencies

📊 Changes

3 files changed (+3 additions, -6 deletions)

View changed files

📝 models/llama_api/manifest.yaml (+2 -2)
📝 models/llama_api/models/llm/llm.py (+1 -3)
📝 models/llama_api/requirements.txt (+0 -1)

📄 Description

https://github.com/langgenius/dify-official-plugins/pull/845 introduced Llama API plugin.

Initially we are using transformers package to count tokens, but somehow the production version of dify has this weird error

[llama-api] Error: PluginInvokeError: {"args":{},"error_type":"KeyError","message":"\u003cclass 'transformers.models.bit.configuration_bit.BitConfig'\u003e"}

I suspect it's related to some transformers package dependencies version incompatibility or something.
Upon digging futher, looks like dify provide a util function to count an approximate tokens using _get_num_tokens_by_gpt2()
I saw many model providers are using that too, and hence migrating to that and removing transformers as a package dependencies.

I tested this by building the dify plugin manually, and upload it into dify cloud (prod) and test it out, and how the error no longer appears.

Screenshot 2025-05-06 at 8 37 06 PM Screenshot 2025-05-06 at 8 41 51 PM

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-official-plugins/pull/866 **Author:** [@Riandy](https://github.com/Riandy) **Created:** 5/6/2025 **Status:** ✅ Merged **Merged:** 5/6/2025 **Merged by:** [@crazywoola](https://github.com/crazywoola) **Base:** `main` ← **Head:** `llama-api-fix-transformers` --- ### 📝 Commits (1) - [`d11c1a3`](https://github.com/langgenius/dify-official-plugins/commit/d11c1a365c6c12b931fd8f8f0465eb6035e042eb) Remove transformers dependencies ### 📊 Changes **3 files changed** (+3 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `models/llama_api/manifest.yaml` (+2 -2) 📝 `models/llama_api/models/llm/llm.py` (+1 -3) 📝 `models/llama_api/requirements.txt` (+0 -1) </details> ### 📄 Description https://github.com/langgenius/dify-official-plugins/pull/845 introduced Llama API plugin. Initially we are using transformers package to count tokens, but somehow the production version of dify has this weird error ``` [llama-api] Error: PluginInvokeError: {"args":{},"error_type":"KeyError","message":"\u003cclass 'transformers.models.bit.configuration_bit.BitConfig'\u003e"} ``` I suspect it's related to some transformers package dependencies version incompatibility or something. Upon digging futher, looks like dify provide a util function to count an approximate tokens using _get_num_tokens_by_gpt2() I saw many model providers are using that too, and hence migrating to that and removing transformers as a package dependencies. I tested this by building the dify plugin manually, and upload it into dify cloud (prod) and test it out, and how the error no longer appears. <img width="1226" alt="Screenshot 2025-05-06 at 8 37 06 PM" src="https://github.com/user-attachments/assets/db8dab0b-06b1-4645-a901-4a0086fb6e29" /> <img width="1219" alt="Screenshot 2025-05-06 at 8 41 51 PM" src="https://github.com/user-attachments/assets/b9dc4f7a-4f78-4db1-a7f8-7ee7f419ecac" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 10:23:26 -05:00
yindo closed this issue 2026-02-16 10:23:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#1599