Dify can't enable knowledge graph search method in RAGFlow when using RAGFlow as an external knowledge base
Self Checks
- [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.
1. Is this request related to a challenge you're experiencing? Tell me about your story.
Hello everyone, I'm trying to use RAGFlow as an external knowledge base for a RAG retrieval task. I'm using Dify 1.1.3 and 0.15.3, RAGFlow version v0.17.2 slim Knowledge graphs can be generated in RAGFlow, I have successfully connected to the RAGFlow knowledge base in Dify and successfully tested the search, and I was able to get the results of the search with or without using rerank model. But when I try to call "Use Knowledge Graph" in Dify, I find that Dify's recall settings interface does not provide a corresponding enable button.
I looked at the source code of RAGFlow, Dify uses this interface when calling RAGFlow knowledge base
#RAGFlow
#./api/apps/sdk/dify_retrieval.py
@manager.route('/dify/retrieval', methods=['POST']) # noqa: F821
@apikey_required
@validate_request("knowledge_id", "query")
def retrieval(tenant_id):
req = request.json
question = req["query"]
kb_id = req["knowledge_id"]
use_kg = req.get("use_kg", False)
...
if use_kg:
ck = settings.kg_retrievaler.retrieval(question,
[tenant_id],
[kb_id],
embd_mdl,
LLMBundle(kb.tenant_id, LLMType.CHAT))
and it requires the use_kg = req.get("use_kg", False) parameter to enable the Knowledge Graph feature, which is False by default in RAGFlow.
Then I looked at the source code of Dify, take the recall test interface of the knowledge base as an example
# web/app/components/datasets/hit-testing/textarea.tsx
const externalRetrievalTestingOnSubmit = async () => {
setLoading(true)
const [e, res] = await asyncRunSafe<ExternalKnowledgeBaseHitTestingResponse>(
externalKnowledgeBaseHitTesting({
# Only the following parameters were sent
datasetId,
query: text,
external_retrieval_model: {
top_k: externalRetrievalSettings.top_k,
score_threshold: externalRetrievalSettings.score_threshold,
score_threshold_enabled: externalRetrievalSettings.score_threshold_enabled,
},
}) as Promise<ExternalKnowledgeBaseHitTestingResponse>,
)
if (!e) {
setExternalHitResult(res)
onUpdateList?.()
}
setLoading(false)
}
and there are no Knowledge Graph parameters enabled on the sender side of Dify, which means that Dify cannot use RAGFlow's Knowledge Graph retrieval function when using RAGFlow as an external database. I found this issue in both Dify 1.1.3 and 0.15.3 versions
Will there be any plans for improvement this function in the future?
Thanks, and I'm new to Dify, if the problem isn't here, is there a relevant solution?
2. Additional context or comments
No response
3. Can you help us with this feature?
- [x] I am interested in contributing to this feature.
Hi, @WhitePlusMS. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- You reported an issue with enabling the "Use Knowledge Graph" feature in Dify when using RAGFlow as an external knowledge base.
- The connection to RAGFlow is successful, and searches can be tested.
- The Dify interface lacks an option to activate the "Use Knowledge Graph" feature, which is needed for the
use_kgparameter in the RAGFlow API. - No comments or further activity have been made on this issue.
Next Steps:
- Please let me know if this issue is still relevant to the latest version of the Dify repository by commenting here.
- If there is no further activity, this issue will be automatically closed in 15 days.
Thank you for your understanding and contribution!
In DIFY 1.2.0, this problem has not been solved, and my personal solution is to directly use the HTTP node in DIFY to implement query operations with knowledge graph through the relevant API interface of POST RAGFlow
@crazywoola, the user @WhitePlusMS has indicated that the issue with enabling the "Use Knowledge Graph" feature in Dify is still relevant in version 1.2.0 and has shared a workaround using the HTTP node. Could you please assist them with this issue?
在DIFY 1.2.0中,这个问题还没有解决,我个人的解决方案是直接使用DIFY中的HTTP节点,通过POST RAGFlow的相关API接口,实现知识图谱的查询操作
请问下用的ragflow的什么接口实现的 ?ragflow的版本是多少啊?
Can setting the parameter use_kg in the RAGFlow source code to true and restarting docker solve the problem of calling the knowledge graph function in dify?