langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
46.38k stars 6.55k forks source link

Error occurred when adding Doubao TEXT Embedding model #4550

Closed xiaohai-78 closed 4 months ago

xiaohai-78 commented 4 months ago

Self Checks

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

code : "invalid_param" message : "2 validation errors for EmbeddingUsage\ntokens\n none is not an allowed value (type=type_error.none.not_allowed)\ntotal_tokens\n none is not an allowed value (type=type_error.none.not_allowed)" status : 400 image

✔️ Expected Behavior

The Doubao TEXT Embedding model can be added normally

❌ Actual Behavior

No response

dosubot[bot] commented 4 months ago

To resolve the validation errors related to the 'tokens' and 'total_tokens' fields when adding the Doubao TEXT Embedding model in Dify version 0.6.8, you need to ensure that these fields are included in the model configuration.

Here is the updated configuration:

ModelConfigs = {
    'Doubao-embedding': {
        'req_params': {},
        'model_properties': {
            'context_size': 4096,
            'max_chunks': 1,
            'tokens': 0,  # Add this line
            'total_tokens': 0,  # Add this line
        }
    },
}

By adding 'tokens': 0 and 'total_tokens': 0 to the model_properties, you should be able to resolve the validation errors. If you continue to experience issues, ensure that all environment variable settings and Docker network configurations are correctly applied. Also, check for any firewall rules or network policies that might be blocking the connection between Dify and the Doubao service.

#### Details **Sources** - [Add model provider Ollama fail](https://github.com/langgenius/dify/issues/4307) - [Add Volcengine Doubao-embedding model error](https://github.com/langgenius/dify/issues/4430) - [Encountered an error while using ZhipuAI's text-embedding model in Dify.](https://github.com/langgenius/dify/issues/1984) - [通过智谱AI的api-key接入智谱AI模型后,使用智谱AI的text_embedding报错](https://github.com/langgenius/dify/issues/1981) - [api/core/model_runtime/model_providers/volcengine_maas/text_embedding/models.py](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/volcengine_maas/text_embedding/models.py) - [api/core/model_runtime/entities/text_embedding_entities.py](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/entities/text_embedding_entities.py) - [api/controllers/console/workspace/models.py](https://github.com/langgenius/dify/blob/main/api/controllers/console/workspace/models.py) - [api/tests/integration_tests/model_runtime/huggingface_hub/test_text_embedding.py](https://github.com/langgenius/dify/blob/main/api/tests/integration_tests/model_runtime/huggingface_hub/test_text_embedding.py) - [api/controllers/service_api/app/error.py](https://github.com/langgenius/dify/blob/main/api/controllers/service_api/app/error.py)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

JohnJyong commented 4 months ago

@sinomoe pls help to check this issue

JohnJyong commented 4 months ago

it has fixed by below pr : https://github.com/langgenius/dify/pull/4431

xiaohai-78 commented 4 months ago

it has fixed by below pr : #4431它已修复以下 PR : #4431

When will this bug go online?