dify icon indicating copy to clipboard operation
dify copied to clipboard

Query annotation failed error when querying to an app with annotation enabled but no question added

Open bowenliang123 opened this issue 10 months ago • 3 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a quesion, 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] Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.6.3

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

  1. create an basic app
  2. enable annotation reply, but with no annotations added
  3. query to the app

✔️ Expected Behavior

No response

❌ Actual Behavior

  1. exceptions in api module log, it seems querying to an non-existed vector index on vdb
WARNING:core.app.features.annotation_reply.annotation_reply:Query annotation failed, exception: 
Error during query: [{'locations': [{'column': 6, 'line': 1}], 'message': 'Cannot query field 
"Vector_index_67d9a50a_d0e5_4a14_bbd7_95e69bea1d4d_Node" on type "GetObjectsObj". Did you mean 
"Vector_index_1206a54a_1768_4598_8b50_bfbb9668ef7d_Node", 
"Vector_index_e7c142a9_f08c_4284_bae6_aeefbd008bfd_Node", 
"Vector_index_641caa60_a4d5_43de_aff5_1d26fba3d29b_Node", 
"Vector_index_c738d801_16f1_47d9_9025_9c6961754fec_Node", or 
"Vector_index_fc7da34a_794c_4663_9f79_26fa7b46f691_Node"?', 'path': None}].

bowenliang123 avatar Apr 16 '24 10:04 bowenliang123

The issue you're experiencing is due to the enable_annotation_reply_task function attempting to index annotations for the app when there are none available. This leads to the error because it tries to query a vector index that doesn't exist in vdb.

To fix this, you'll need to modify the enable_annotation_reply_task function to check if there are no annotations before proceeding with the indexing process. If no annotations are found, the function should skip the indexing but still complete the setup for the annotation reply feature. This involves updating or creating the AppAnnotationSetting to ensure the feature is configured correctly, even in the absence of annotations.

Here's a brief overview of what you need to do:

  1. Add a condition to check if the annotations list is empty after retrieving all annotations for the app.
  2. If the list is empty, log a message indicating no annotations were found and skip the indexing process.
  3. Regardless of whether annotations exist, proceed to update or create the AppAnnotationSetting for the app to ensure the annotation reply feature is correctly set up.

This approach ensures that the task can handle cases with no annotations to index, avoiding the exceptions you encountered. It also makes sure that the annotation reply feature is enabled correctly, with or without annotations.

This solution should resolve the error you're seeing. If you encounter any further issues or need additional assistance, feel free to ask.

Sources

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.

If you want to continue the conversation, start your reply with @dosu-bot.

dosubot[bot] avatar Apr 16 '24 10:04 dosubot[bot]

cc @JohnJyong

bowenliang123 avatar Apr 17 '24 00:04 bowenliang123

Hi, @bowenliang123,

I'm helping the Dify team manage their backlog and am marking this issue as stale. From what I understand, the issue you reported concerned an error occurring when querying an app with annotation enabled but no annotations added, leading to exceptions in the API module log. It seems that a potential solution was provided, and the issue may have been resolved by modifying the enable_annotation_reply_task function to handle cases with no annotations to index, possibly with collaboration from @JohnJyong.

Could you please confirm if this issue is still relevant to the latest version of the Dify repository? If it is, please let the Dify team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you!

dosubot[bot] avatar May 18 '24 16:05 dosubot[bot]