How do I upload a file to the knowledge base in parent-child structure mode through the API interface of DIFY? #15087
Replies: 2 comments
-
Hello @VincentWallace8012! I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let me know how I can assist you today! To upload a file to the knowledge base in parent-child structure mode through the Dify API, you need to adjust the curl --location --request POST 'http://127.0.0.1/v1/datasets/{dataset_id}/document/create-by-file' \
--header 'Authorization: Bearer {api_key}' \
--form 'data="{
\"indexing_technique\":\"high_quality\",
\"process_rule\":{
\"rules\":{
\"pre_processing_rules\":[
{\"id\":\"remove_extra_spaces\",\"enabled\":true},
{\"id\":\"remove_urls_emails\",\"enabled\":true}
],
\"segmentation\":{
\"separator\":\"###\",
\"max_tokens\":500
},
\"subchunk_segmentation\":{
\"separator\":\"\n\",
\"max_tokens\":200
},
\"parent_mode\":\"paragraph\"
},
\"mode\":\"hierarchical\"
},
\"doc_form\":\"hierarchical_model\"
}";type=text/plain' \
--form 'file=@"/path/to/file"' This configuration sets the document to be processed in hierarchical mode, using paragraphs as parent segments and sentences as child segments [1][2]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Thank you very much, I'm going to try it with this method |
Beta Was this translation helpful? Give feedback.
-
Self Checks
Provide a description of requested docs changes
curl --location --request POST 'http://127.0.0.1/v1/datasets/{dataset_id}/document/create-by-file'
--header 'Authorization: Bearer {api_key}'
--form 'data="{"indexing_technique":"high_quality","process_rule":{"rules":{"pre_processing_rules":[{"id":"remove_extra_spaces","enabled":true},{"id":"remove_urls_emails","enabled":true}],"segmentation":{"separator":"###","max_tokens":500}},"mode":"custom"}}";type=text/plain'
--form 'file=@"/path/to/file"'
The upload file interface of dify is like this, please adjust which parameter allows me to initialize the document into the knowledge base in parent-child mode?
Beta Was this translation helpful? Give feedback.
All reactions