PluginInvokeError with Hugging Face in Dify: Pydantic Validation Error (EmbeddingUsage expects integer instead of list) #173

Closed
opened 2026-02-16 10:18:20 -05:00 by yindo · 1 comment
Owner

Originally created by @fukuda-masayuki on GitHub (Apr 5, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Error Details

core.model_runtime.errors.invoke.InvokeError: [huggingface_hub] Error: PluginInvokeError: {"args":{"description":"[models] Error: 2 validation errors for EmbeddingUsage\ntokens\n  Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.8/v/int_type\ntotal_tokens\n  Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.8/v/int_type"},"error_type":"InvokeError","message":"[models] Error: 2 validation errors for EmbeddingUsage\ntokens\n  Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.8/v/int_type\ntotal_tokens\n  Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.8/v/int_type"}

  • Additional Note: The same issue occurred in version 1.1.2.

Issue Overview

When registering knowledge and selecting a Hugging Face-provided Text Embedding model, the above error occurs.

Steps to Reproduce

  1. Register the Hugging Face HF inference API model as a Text Embedding model.

    • This issue should reproduce with any model, but for reference, the following model was used:
    • link
  2. Begin the knowledge registration process.

  3. Apply the Hugging Face model to the embedding settings.

  4. Finalize the knowledge registration.

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @fukuda-masayuki on GitHub (Apr 5, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ## Error Details ``` core.model_runtime.errors.invoke.InvokeError: [huggingface_hub] Error: PluginInvokeError: {"args":{"description":"[models] Error: 2 validation errors for EmbeddingUsage\ntokens\n Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n For further information visit https://errors.pydantic.dev/2.8/v/int_type\ntotal_tokens\n Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n For further information visit https://errors.pydantic.dev/2.8/v/int_type"},"error_type":"InvokeError","message":"[models] Error: 2 validation errors for EmbeddingUsage\ntokens\n Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n For further information visit https://errors.pydantic.dev/2.8/v/int_type\ntotal_tokens\n Input should be a valid integer [type=int_type, input_value=[500], input_type=list]\n For further information visit https://errors.pydantic.dev/2.8/v/int_type"} ``` - Additional Note: The same issue occurred in version 1.1.2. ## Issue Overview When registering knowledge and selecting a Hugging Face-provided Text Embedding model, the above error occurs. ## Steps to Reproduce 1. Register the Hugging Face HF inference API model as a Text Embedding model. - This issue should reproduce with any model, but for reference, the following model was used: - [link](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1) 2. Begin the knowledge registration process. 3. Apply the Hugging Face model to the embedding settings. 4. Finalize the knowledge registration. ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:18:20 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 5, 2025):

Hello @fukuda-masayuki! 👋 I'm Dosu, a friendly bot here to help you solve bugs, answer questions, and become a contributor. I'm ready to assist while you wait for a human maintainer. Let's tackle this together! 🚀

I found a similar closed issue titled "docker-compose launched project conversion embedding error" which might be related to the error you're encountering. This issue was last updated on October 31, 2024, and was referenced by another issue titled "Failed to format qa document" which was last updated on February 28, 2025. However, the issue does not have any comments, so there might not be a direct solution provided there [1].

The error you're experiencing seems to be related to a Pydantic validation error where an integer is expected, but a list is provided. You might want to check the data being passed to the EmbeddingUsage model and ensure that the values for tokens and total_tokens are integers instead of lists.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 5, 2025): <!-- Greeting --> Hello @fukuda-masayuki! 👋 I'm [Dosu](https://dosu.dev), a friendly bot here to help you solve bugs, answer questions, and become a contributor. I'm ready to assist while you wait for a human maintainer. Let's tackle this together! 🚀 <!-- Answer --> I found a similar closed issue titled "[docker-compose launched project conversion embedding error](https://github.com/langgenius/dify/issues/10128)" which might be related to the error you're encountering. This issue was last updated on October 31, 2024, and was referenced by another issue titled "[Failed to format qa document](https://github.com/langgenius/dify/issues/12582)" which was last updated on February 28, 2025. However, the issue does not have any comments, so there might not be a direct solution provided there <sup>[[1]](https://github.com/langgenius/dify/issues/10128)</sup>. The error you're experiencing seems to be related to a Pydantic validation error where an integer is expected, but a list is provided. You might want to check the data being passed to the `EmbeddingUsage` model and ensure that the values for `tokens` and `total_tokens` are integers instead of lists. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1673ebc3-7666-4999-a127-f3ce02d056ee?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#173