dify icon indicating copy to clipboard operation
dify copied to clipboard

Error retreiving knowledge

Open damadorPL opened this issue 1 year ago • 4 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.10.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

crwal any url with firefrawl/jina

text-embedding-ada-002 jina-reranker-v2-base-multilingual

but it fail with any combination

add it to completition and test

api return

2024-10-22 18:53:48,170.170 ERROR [Thread-3 (_generate_worker)] [app_generator.py:210] - Unknown Error when generating
Traceback (most recent call last):
  File "/app/api/core/app/apps/completion/app_generator.py", line 191, in _generate_worker
    runner.run(
  File "/app/api/core/app/apps/completion/app_runner.py", line 119, in run
    context = dataset_retrieval.retrieve(
  File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 122, in retrieve
    all_documents = self.single_retrieve(
  File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 330, in single_retrieve
    results = RetrievalService.retrieve(
  File "/app/api/core/rag/datasource/retrieval_service.py", line 104, in retrieve
    raise Exception(exception_message)
Exception: 'NoneType' object has no attribute 'replace';
'NoneType' object has no attribute 'replace'
2024-10-22 18:53:48,180.180 ERROR [Dummy-2] [base_app_generate_response_converter.py:131] - 'NoneType' object has no attribute 'replace';
'NoneType' object has no attribute 'replace'

✔️ Expected Behavior

working generation

❌ Actual Behavior

no generation and error in api

damadorPL avatar Oct 22 '24 18:10 damadorPL

I found some similar issues that might be relevant to the error you're encountering:

  1. ERROR: '<' not supported between instances of 'NoneType' and 'NoneType' - This issue was resolved by upgrading to version 0.10.0, which you are already using.

  2. Failed to invoke tool: 'NoneType' object has no attribute 'items' - The suggested solutions for this issue include:

    • Ensuring that tool parameters are correctly formatted as a dictionary and that the timezone provided is valid.
    • Verifying and updating environment variables and configurations in your Docker setup, then restarting your Docker containers.
    • Considering using a different or smarter model, as switching to a higher quality model resolved the issue for another user.

The error message you're seeing suggests that there might be a None value where a string is expected, specifically related to the replace method. Ensure that all required parameters are provided and correctly formatted. If the issue persists, you might want to check the implementation of the retrieve method in the retrieval_service.py file to ensure that the inputs to this method are valid and correctly formatted [1].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Oct 22 '24 19:10 dosubot[bot]

hi @damadorPL , I can't reproduce your problem here. Can you provide more screenshots of the operation? Or can you try it in our SaaS environment dify.ai and see if it can be reproduced? thanks

JohnJyong avatar Oct 23 '24 09:10 JohnJyong

hi @damadorPL , I can't reproduce your problem here. Can you provide more screenshots of the operation? Or can you try it in our SaaS environment dify.ai and see if it can be reproduced? thanks

https://vimeo.com/1022448757/0e95fb6b45?ts=0&share=copy here is video showing the bug on cloud and way to reproduce it

damadorPL avatar Oct 23 '24 10:10 damadorPL

problem persist on 10.1

2024-10-23T11:28:01.655817231Z 2024-10-23 11:28:01,652.652 ERROR [Thread-4 (_generate_worker)] [app_generator.py:210] - Unknown Error when generating 2024-10-23T11:28:01.655876251Z Traceback (most recent call last): 2024-10-23T11:28:01.655883965Z File "/app/api/core/app/apps/completion/app_generator.py", line 191, in _generate_worker 2024-10-23T11:28:01.655888544Z runner.run( 2024-10-23T11:28:01.655892531Z File "/app/api/core/app/apps/completion/app_runner.py", line 119, in run 2024-10-23T11:28:01.655896729Z context = dataset_retrieval.retrieve( 2024-10-23T11:28:01.655900727Z File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 122, in retrieve 2024-10-23T11:28:01.655904875Z all_documents = self.single_retrieve( 2024-10-23T11:28:01.655908912Z File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 330, in single_retrieve 2024-10-23T11:28:01.655913020Z results = RetrievalService.retrieve( 2024-10-23T11:28:01.655917027Z File "/app/api/core/rag/datasource/retrieval_service.py", line 104, in retrieve 2024-10-23T11:28:01.655921145Z raise Exception(exception_message) 2024-10-23T11:28:01.655925122Z Exception: 'NoneType' object has no attribute 'replace'; 2024-10-23T11:28:01.655929149Z 'NoneType' object has no attribute 'replace' 2024-10-23T11:28:01.661720244Z 2024-10-23 11:28:01,661.661 ERROR [Dummy-5] [base_app_generate_response_converter.py:131] - 'NoneType' object has no attribute 'replace'; 2024-10-23T11:28:01.661751621Z 'NoneType' object has no attribute 'replace'

damadorPL avatar Oct 23 '24 11:10 damadorPL

still bugged in v0.10.2

2024-10-28T11:16:15.448039942Z 2024-10-28 11:16:15,443.443 ERROR [Thread-3 (_generate_worker)] [app_generator.py:210] - Unknown Error when generating 2024-10-28T11:16:15.448149977Z Traceback (most recent call last): 2024-10-28T11:16:15.448155487Z File "/app/api/core/app/apps/completion/app_generator.py", line 191, in _generate_worker 2024-10-28T11:16:15.448160297Z runner.run( 2024-10-28T11:16:15.448164655Z File "/app/api/core/app/apps/completion/app_runner.py", line 119, in run 2024-10-28T11:16:15.448168993Z context = dataset_retrieval.retrieve( 2024-10-28T11:16:15.448173171Z File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 122, in retrieve 2024-10-28T11:16:15.448177758Z all_documents = self.single_retrieve( 2024-10-28T11:16:15.448182136Z File "/app/api/core/rag/retrieval/dataset_retrieval.py", line 330, in single_retrieve 2024-10-28T11:16:15.448186404Z results = RetrievalService.retrieve( 2024-10-28T11:16:15.448190532Z File "/app/api/core/rag/datasource/retrieval_service.py", line 104, in retrieve 2024-10-28T11:16:15.448194850Z raise Exception(exception_message) 2024-10-28T11:16:15.448199008Z Exception: 'NoneType' object has no attribute 'replace'; 2024-10-28T11:16:15.448203166Z 'NoneType' object has no attribute 'replace' 2024-10-28T11:16:15.459258785Z 2024-10-28 11:16:15,458.458 ERROR [Dummy-2] [base_app_generate_response_converter.py:131] - 'NoneType' object has no attribute 'replace'; 2024-10-28T11:16:15.459303248Z 'NoneType' object has no attribute 'replace'

damadorPL avatar Oct 28 '24 11:10 damadorPL

@damadorPL I'm sorry for replying to you so late. Unfortunately, I can't reproduce your problem according to the steps in your video. Are you free to conduct a test with me through video conference? thanks in advance~

JohnJyong avatar Oct 29 '24 06:10 JohnJyong

https://vimeo.com/1024250659/7349e3a956?share=copy create app from template set Fully SEO Optimized Article including FAQs - when you retreive context from knowledge database error is thrown

damadorPL avatar Oct 29 '24 06:10 damadorPL

all_documents = self.single_retrieve it seems that app throw error when it receive no data from RAG (NoneType) and it cant replace {{context}} variable

damadorPL avatar Oct 29 '24 07:10 damadorPL

The value passed to the retrieval function may be None. This could be due to missing data or some earlier operation not returning the expected result.

damadorPL avatar Oct 29 '24 07:10 damadorPL

and copilot says the same

The error message indicates that somewhere in the code, a NoneType object is being accessed with the replace method, which is causing an exception.

Potential NoneType Variables: Check all variables that could potentially be None and are used with the replace method.

Check for None before calling replace.

when passing empty knowledge even if variable is OPTIONAL it hang as null object cant be replaced by replace()

damadorPL avatar Oct 29 '24 07:10 damadorPL

got it, thanks for you feedback, we will fix it soon~

JohnJyong avatar Oct 31 '24 10:10 JohnJyong