dify icon indicating copy to clipboard operation
dify copied to clipboard

Run failed: 2 validation errors for KnowledgeRetrievalNodeData

Open lin1shu opened this issue 1 year ago • 6 comments

Self Checks

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

Dify version

0.7.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Build a knowledge with a PDF document
  2. Choose the default "Knowledge Retrieval + Chatbot" from "Explore", choose the knowledge.
  3. Preview the "Knowledge Retrieval" Step with any keyword
  4. UI shows following error:

Run failed: 2 validation errors for KnowledgeRetrievalNodeData multiple_retrieval_config.weights.vector_setting.embedding_provider_name Field required [type=missing, input_value={'vector_weight': 1}, input_type=dict] For further information visit https://errors.pydantic.dev/2.8/v/missing multiple_retrieval_config.weights.vector_setting.embedding_model_name Field required [type=missing, input_value={'vector_weight': 1}, input_type=dict] For further information visit https://errors.pydantic.dev/2.8/v/missing

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

lin1shu avatar Sep 03 '24 16:09 lin1shu

@lin1shu Hello there! I'm here to help you with any bugs, questions, or contributions while you're waiting for a human maintainer.

I found a similar issue that might help resolve your problem. The issue titled "Error in using knowledge base recall test" was closed and suggested ensuring that the handleChange function correctly updates the multiple_retrieval_config without including any extra inputs [1].

To resolve the validation errors for KnowledgeRetrievalNodeData in Dify version 0.7.3, ensure that the following fields are correctly populated:

  1. Selecting the Query Variable: Ensure that the query_variable_selector is set to the appropriate user input variable, typically "sys.query" in conversational applications.
  2. Choosing the Knowledge Base for Query: Ensure that dataset_ids is populated with the IDs of the knowledge bases you want to query.
  3. Configuring the Retrieval Strategy:
    • If retrieval_mode is multiWay and multiple_retrieval_config.reranking_enable is true, ensure that multiple_retrieval_config.reranking_model.provider is set.
    • If retrieval_mode is oneWay, ensure that single_retrieval_config.model.provider is set.

Here is a code snippet that shows how to set these fields correctly:

const knowledgeRetrievalNodeData = {
  query_variable_selector: ['sys.query'], // Typically the user input variable
  dataset_ids: ['your_dataset_id'], // IDs of the knowledge bases
  retrieval_mode: RETRIEVE_TYPE.multiWay, // or RETRIEVE_TYPE.oneWay
  multiple_retrieval_config: {
    top_k: DATASET_DEFAULT.top_k,
    score_threshold: undefined,
    reranking_enable: true, // or false
    reranking_model: {
      provider: 'your_reranking_model_provider', // Required if reranking_enable is true
    },
    weights: {
      vector_setting: {
        vector_weight: 1,
        embedding_provider_name: 'your_embedding_provider_name', // Required field
        embedding_model_name: 'your_embedding_model_name', // Required field
      },
      keyword_setting: {
        keyword_weight: 1,
      },
    },
  },
  single_retrieval_config: {
    model: {
      provider: 'your_model_provider', // Required if retrieval_mode is oneWay
    },
  },
};

Ensure that you replace 'your_dataset_id', 'your_reranking_model_provider', 'your_embedding_provider_name', and 'your_embedding_model_name' with the actual values you are using. Additionally, make sure that the datasets you are querying have completed indexing and are enabled [2][3][4].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Sep 03 '24 16:09 dosubot[bot]

Can you paste your configurations here?

image

crazywoola avatar Sep 04 '24 00:09 crazywoola

Thanks @crazywoola . Please see the screenshot below. Also, I tried the same settings as you posted and still got the same error message.

Screenshot 2024-09-03 at 10 08 36 PM ![Screenshot 2024-09-03 at 10 08 58 PM](https://github.com/user-attachments/assets/c41f3171-80f3-4f6b-a5e2-aa681405965f)

lin1shu avatar Sep 04 '24 05:09 lin1shu

I have the same problem.

Howe829 avatar Sep 10 '24 02:09 Howe829

I have the same problem.

I delete the Knowledge Retrieval node and create a new one, it works for me. Hope it will help you!

Howe829 avatar Sep 10 '24 02:09 Howe829

If I delete and recreate the knowledge node created from the Knowledge Retreival + Chatbot template, the error no longer occurs.

スクリーンショット 2024-09-10 14 16 51

shintaro-amaike avatar Sep 10 '24 05:09 shintaro-amaike

I'm trying to build a simple chatbot but having the same issue. Here is the error I'm getting

Run failed: 2 validation errors for KnowledgeRetrievalNodeData multiple_retrieval_config.reranking_model.provider Field required [type=missing, input_value={'reranking_provider_name...ranking_model_name': ''}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing multiple_retrieval_config.reranking_model.model Field required [type=missing, input_value={'reranking_provider_name...ranking_model_name': ''}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing

I've tried the deleting and recreating knowledge node suggested above but only got it to work in Preview and not when I go to Run App.

image

image

Tried everything but couldn't get it to work. Can anyone give me some pointers? Thank you!

CooCooRiku avatar Jan 10 '25 07:01 CooCooRiku