Open haike-1213 opened 2 hours ago
Hey @haike-1213! It looks like you're sharing a detailed bug report and some code snippets. While I can help you solve bugs, answer technical questions, and gather engineering knowledge, this specific request seems to be more about sharing a report rather than seeking help with a technical issue.
If you think I should have answered this request, feel free to reach out to the Dosu Team.
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.8
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
✔️ Expected Behavior
Issue Description: The code logic for handling the "retriever_resources" key in the metadata dictionary is incorrect. Specifically: The code checks if "retriever_resources" exists in metadata. If it exists, it clears the list. It then iterates over and rebuilds the list. Problem Reason: The list is cleared before iteration, causing the subsequent loop to have no effect because the list is empty. Suggested Fix: Remove the operation that clears the list to preserve the existing data structure. Iterate and rebuild the list as needed. Relevant Code Snippet: if "retriever_resources" in metadata:
This line clears the list
Suggested Modified Code: if "retriever_resources" in metadata: updated_resources = [] for resource in metadata["retriever_resources"]: updated_resources.append( { "segment_id": resource["segment_id"], "position": resource["position"], "document_name": resource["document_name"], "score": resource["score"], "content": resource["content"], } ) metadata["retriever_resources"] = updated_resources
❌ Actual Behavior