template.en.mdx 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977
  1. import { CodeGroup } from '@/app/components/develop/code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstruction, Paragraph } from '@/app/components/develop/md.tsx'
  3. # Knowledge API
  4. <div>
  5. ### Authentication
  6. Service API of Dify authenticates using an `API-Key`.
  7. It is suggested that developers store the `API-Key` in the backend instead of sharing or storing it in the client side to avoid the leakage of the `API-Key`, which may lead to property loss.
  8. All API requests should include your `API-Key` in the **`Authorization`** HTTP Header, as shown below:
  9. <CodeGroup title="Code">
  10. ```javascript
  11. Authorization: Bearer {API_KEY}
  12. ```
  13. </CodeGroup>
  14. </div>
  15. <hr className='ml-0 mr-0' />
  16. <Heading
  17. url='/datasets/{dataset_id}/document/create-by-text'
  18. method='POST'
  19. title='Create a Document from Text'
  20. name='#create-by-text'
  21. />
  22. <Row>
  23. <Col>
  24. This API is based on an existing knowledge and creates a new document through text based on this knowledge.
  25. ### Params
  26. <Properties>
  27. <Property name='dataset_id' type='string' key='dataset_id'>
  28. Knowledge ID
  29. </Property>
  30. </Properties>
  31. ### Request Body
  32. <Properties>
  33. <Property name='name' type='string' key='name'>
  34. Document name
  35. </Property>
  36. <Property name='text' type='string' key='text'>
  37. Document content
  38. </Property>
  39. <Property name='indexing_technique' type='string' key='indexing_technique'>
  40. Index mode
  41. - <code>high_quality</code> High quality: embedding using embedding model, built as vector database index
  42. - <code>economy</code> Economy: Build using inverted index of keyword table index
  43. </Property>
  44. <Property name='doc_form' type='string' key='doc_form'>
  45. Format of indexed content
  46. - <code>text_model</code> Text documents are directly embedded; `economy` mode defaults to using this form
  47. - <code>hierarchical_model</code> Parent-child mode
  48. - <code>qa_model</code> Q&A Mode: Generates Q&A pairs for segmented documents and then embeds the questions
  49. </Property>
  50. <Property name='doc_language' type='string' key='doc_language'>
  51. In Q&A mode, specify the language of the document, for example: <code>English</code>, <code>Chinese</code>
  52. </Property>
  53. <Property name='process_rule' type='object' key='process_rule'>
  54. Processing rules
  55. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  56. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  57. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  58. - <code>id</code> (string) Unique identifier for the preprocessing rule
  59. - enumerate
  60. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  61. - <code>remove_urls_emails</code> Delete URL, email address
  62. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  63. - <code>segmentation</code> (object) Segmentation rules
  64. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  65. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  66. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  67. - <code>subchunk_segmentation</code> (object) Child chunk rules
  68. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  69. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  70. - <code>chunk_overlap</code> Define the overlap between adjacent chunks (optional)
  71. </Property>
  72. <PropertyInstruction>When no parameters are set for the knowledge base, the first upload requires the following parameters to be provided; if not provided, the default parameters will be used.</PropertyInstruction>
  73. <Property name='retrieval_model' type='object' key='retrieval_model'>
  74. Retrieval model
  75. - <code>search_method</code> (string) Search method
  76. - <code>hybrid_search</code> Hybrid search
  77. - <code>semantic_search</code> Semantic search
  78. - <code>full_text_search</code> Full-text search
  79. - <code>reranking_enable</code> (bool) Whether to enable reranking
  80. - <code>reranking_mode</code> (object) Rerank model configuration
  81. - <code>reranking_provider_name</code> (string) Rerank model provider
  82. - <code>reranking_model_name</code> (string) Rerank model name
  83. - <code>top_k</code> (int) Number of results to return
  84. - <code>score_threshold_enabled</code> (bool) Whether to enable score threshold
  85. - <code>score_threshold</code> (float) Score threshold
  86. </Property>
  87. <Property name='embedding_model' type='string' key='embedding_model'>
  88. Embedding model name
  89. </Property>
  90. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  91. Embedding model provider
  92. </Property>
  93. </Properties>
  94. </Col>
  95. <Col sticky>
  96. <CodeGroup
  97. title="Request"
  98. tag="POST"
  99. label="/datasets/{dataset_id}/document/create-by-text"
  100. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "text","text": "text","indexing_technique": "high_quality","process_rule": {"mode": "automatic"}}'`}
  101. >
  102. ```bash {{ title: 'cURL' }}
  103. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
  104. --header 'Authorization: Bearer {api_key}' \
  105. --header 'Content-Type: application/json' \
  106. --data-raw '{
  107. "name": "text",
  108. "text": "text",
  109. "indexing_technique": "high_quality",
  110. "process_rule": {
  111. "mode": "automatic"
  112. }
  113. }'
  114. ```
  115. </CodeGroup>
  116. <CodeGroup title="Response">
  117. ```json {{ title: 'Response' }}
  118. {
  119. "document": {
  120. "id": "",
  121. "position": 1,
  122. "data_source_type": "upload_file",
  123. "data_source_info": {
  124. "upload_file_id": ""
  125. },
  126. "dataset_process_rule_id": "",
  127. "name": "text.txt",
  128. "created_from": "api",
  129. "created_by": "",
  130. "created_at": 1695690280,
  131. "tokens": 0,
  132. "indexing_status": "waiting",
  133. "error": null,
  134. "enabled": true,
  135. "disabled_at": null,
  136. "disabled_by": null,
  137. "archived": false,
  138. "display_status": "queuing",
  139. "word_count": 0,
  140. "hit_count": 0,
  141. "doc_form": "text_model"
  142. },
  143. "batch": ""
  144. }
  145. ```
  146. </CodeGroup>
  147. </Col>
  148. </Row>
  149. <hr className='ml-0 mr-0' />
  150. <Heading
  151. url='/datasets/{dataset_id}/document/create-by-file'
  152. method='POST'
  153. title='Create a Document from a File'
  154. name='#create-by-file'
  155. />
  156. <Row>
  157. <Col>
  158. This API is based on an existing knowledge and creates a new document through a file based on this knowledge.
  159. ### Params
  160. <Properties>
  161. <Property name='dataset_id' type='string' key='dataset_id'>
  162. Knowledge ID
  163. </Property>
  164. </Properties>
  165. ### Request Body
  166. <Properties>
  167. <Property name='data' type='multipart/form-data json string' key='data'>
  168. - <code>original_document_id</code> Source document ID (optional)
  169. - Used to re-upload the document or modify the document cleaning and segmentation configuration. The missing information is copied from the source document
  170. - The source document cannot be an archived document
  171. - When original_document_id is passed in, the update operation is performed on behalf of the document. process_rule is a fillable item. If not filled in, the segmentation method of the source document will be used by default
  172. - When original_document_id is not passed in, the new operation is performed on behalf of the document, and process_rule is required
  173. - <code>indexing_technique</code> Index mode
  174. - <code>high_quality</code> High quality: embedding using embedding model, built as vector database index
  175. - <code>economy</code> Economy: Build using inverted index of keyword table index
  176. - <code>doc_form</code> Format of indexed content
  177. - <code>text_model</code> Text documents are directly embedded; `economy` mode defaults to using this form
  178. - <code>hierarchical_model</code> Parent-child mode
  179. - <code>qa_model</code> Q&A Mode: Generates Q&A pairs for segmented documents and then embeds the questions
  180. - <code>doc_language</code> In Q&A mode, specify the language of the document, for example: <code>English</code>, <code>Chinese</code>
  181. - <code>process_rule</code> Processing rules
  182. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  183. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  184. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  185. - <code>id</code> (string) Unique identifier for the preprocessing rule
  186. - enumerate
  187. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  188. - <code>remove_urls_emails</code> Delete URL, email address
  189. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  190. - <code>segmentation</code> (object) Segmentation rules
  191. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  192. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  193. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  194. - <code>subchunk_segmentation</code> (object) Child chunk rules
  195. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  196. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  197. - <code>chunk_overlap</code> Define the overlap between adjacent chunks (optional)
  198. </Property>
  199. <Property name='file' type='multipart/form-data' key='file'>
  200. Files that need to be uploaded.
  201. </Property>
  202. <PropertyInstruction>When no parameters are set for the knowledge base, the first upload requires the following parameters to be provided; if not provided, the default parameters will be used.</PropertyInstruction>
  203. <Property name='retrieval_model' type='object' key='retrieval_model'>
  204. Retrieval model
  205. - <code>search_method</code> (string) Search method
  206. - <code>hybrid_search</code> Hybrid search
  207. - <code>semantic_search</code> Semantic search
  208. - <code>full_text_search</code> Full-text search
  209. - <code>reranking_enable</code> (bool) Whether to enable reranking
  210. - <code>reranking_mode</code> (object) Rerank model configuration
  211. - <code>reranking_provider_name</code> (string) Rerank model provider
  212. - <code>reranking_model_name</code> (string) Rerank model name
  213. - <code>top_k</code> (int) Number of results to return
  214. - <code>score_threshold_enabled</code> (bool) Whether to enable score threshold
  215. - <code>score_threshold</code> (float) Score threshold
  216. </Property>
  217. <Property name='embedding_model' type='string' key='embedding_model'>
  218. Embedding model name
  219. </Property>
  220. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  221. Embedding model provider
  222. </Property>
  223. </Properties>
  224. </Col>
  225. <Col sticky>
  226. <CodeGroup
  227. title="Request"
  228. tag="POST"
  229. label="/datasets/{dataset_id}/document/create-by-file"
  230. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \\\n--header 'Authorization: Bearer {api_key}' \\\n--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' \\\n--form 'file=@"/path/to/file"'`}
  231. >
  232. ```bash {{ title: 'cURL' }}
  233. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
  234. --header 'Authorization: Bearer {api_key}' \
  235. --form 'data="{\"name\":\"Dify\",\"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' \
  236. --form 'file=@"/path/to/file"'
  237. ```
  238. </CodeGroup>
  239. <CodeGroup title="Response">
  240. ```json {{ title: 'Response' }}
  241. {
  242. "document": {
  243. "id": "",
  244. "position": 1,
  245. "data_source_type": "upload_file",
  246. "data_source_info": {
  247. "upload_file_id": ""
  248. },
  249. "dataset_process_rule_id": "",
  250. "name": "Dify.txt",
  251. "created_from": "api",
  252. "created_by": "",
  253. "created_at": 1695308667,
  254. "tokens": 0,
  255. "indexing_status": "waiting",
  256. "error": null,
  257. "enabled": true,
  258. "disabled_at": null,
  259. "disabled_by": null,
  260. "archived": false,
  261. "display_status": "queuing",
  262. "word_count": 0,
  263. "hit_count": 0,
  264. "doc_form": "text_model"
  265. },
  266. "batch": ""
  267. }
  268. ```
  269. </CodeGroup>
  270. </Col>
  271. </Row>
  272. <hr className='ml-0 mr-0' />
  273. <Heading
  274. url='/datasets'
  275. method='POST'
  276. title='Create an Empty Knowledge Base'
  277. name='#create_empty_dataset'
  278. />
  279. <Row>
  280. <Col>
  281. ### Request Body
  282. <Properties>
  283. <Property name='name' type='string' key='name'>
  284. Knowledge name
  285. </Property>
  286. <Property name='description' type='string' key='description'>
  287. Knowledge description (optional)
  288. </Property>
  289. <Property name='indexing_technique' type='string' key='indexing_technique'>
  290. Index technique (optional)
  291. - <code>high_quality</code> High quality
  292. - <code>economy</code> Economy
  293. </Property>
  294. <Property name='permission' type='string' key='permission'>
  295. Permission
  296. - <code>only_me</code> Only me
  297. - <code>all_team_members</code> All team members
  298. - <code>partial_members</code> Partial members
  299. </Property>
  300. <Property name='provider' type='string' key='provider'>
  301. Provider (optional, default: vendor)
  302. - <code>vendor</code> Vendor
  303. - <code>external</code> External knowledge
  304. </Property>
  305. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  306. External knowledge API ID (optional)
  307. </Property>
  308. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  309. External knowledge ID (optional)
  310. </Property>
  311. </Properties>
  312. </Col>
  313. <Col sticky>
  314. <CodeGroup
  315. title="Request"
  316. tag="POST"
  317. label="/datasets"
  318. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "name", "permission": "only_me"}'`}
  319. >
  320. ```bash {{ title: 'cURL' }}
  321. curl --location --request POST '${apiBaseUrl}/v1/datasets' \
  322. --header 'Authorization: Bearer {api_key}' \
  323. --header 'Content-Type: application/json' \
  324. --data-raw '{
  325. "name": "name",
  326. "permission": "only_me"
  327. }'
  328. ```
  329. </CodeGroup>
  330. <CodeGroup title="Response">
  331. ```json {{ title: 'Response' }}
  332. {
  333. "id": "",
  334. "name": "name",
  335. "description": null,
  336. "provider": "vendor",
  337. "permission": "only_me",
  338. "data_source_type": null,
  339. "indexing_technique": null,
  340. "app_count": 0,
  341. "document_count": 0,
  342. "word_count": 0,
  343. "created_by": "",
  344. "created_at": 1695636173,
  345. "updated_by": "",
  346. "updated_at": 1695636173,
  347. "embedding_model": null,
  348. "embedding_model_provider": null,
  349. "embedding_available": null
  350. }
  351. ```
  352. </CodeGroup>
  353. </Col>
  354. </Row>
  355. <hr className='ml-0 mr-0' />
  356. <Heading
  357. url='/datasets'
  358. method='GET'
  359. title='Get Knowledge Base List'
  360. name='#dataset_list'
  361. />
  362. <Row>
  363. <Col>
  364. ### Query
  365. <Properties>
  366. <Property name='page' type='string' key='page'>
  367. Page number
  368. </Property>
  369. <Property name='limit' type='string' key='limit'>
  370. Number of items returned, default 20, range 1-100
  371. </Property>
  372. </Properties>
  373. </Col>
  374. <Col sticky>
  375. <CodeGroup
  376. title="Request"
  377. tag="GET"
  378. label="/datasets"
  379. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  380. >
  381. ```bash {{ title: 'cURL' }}
  382. curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
  383. --header 'Authorization: Bearer {api_key}'
  384. ```
  385. </CodeGroup>
  386. <CodeGroup title="Response">
  387. ```json {{ title: 'Response' }}
  388. {
  389. "data": [
  390. {
  391. "id": "",
  392. "name": "name",
  393. "description": "desc",
  394. "permission": "only_me",
  395. "data_source_type": "upload_file",
  396. "indexing_technique": "",
  397. "app_count": 2,
  398. "document_count": 10,
  399. "word_count": 1200,
  400. "created_by": "",
  401. "created_at": "",
  402. "updated_by": "",
  403. "updated_at": ""
  404. },
  405. ...
  406. ],
  407. "has_more": true,
  408. "limit": 20,
  409. "total": 50,
  410. "page": 1
  411. }
  412. ```
  413. </CodeGroup>
  414. </Col>
  415. </Row>
  416. <hr className='ml-0 mr-0' />
  417. <Heading
  418. url='/datasets/{dataset_id}'
  419. method='DELETE'
  420. title='Delete a Knowledge Base'
  421. name='#delete_dataset'
  422. />
  423. <Row>
  424. <Col>
  425. ### Params
  426. <Properties>
  427. <Property name='dataset_id' type='string' key='dataset_id'>
  428. Knowledge ID
  429. </Property>
  430. </Properties>
  431. </Col>
  432. <Col sticky>
  433. <CodeGroup
  434. title="Request"
  435. tag="DELETE"
  436. label="/datasets/{dataset_id}"
  437. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  438. >
  439. ```bash {{ title: 'cURL' }}
  440. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
  441. --header 'Authorization: Bearer {api_key}'
  442. ```
  443. </CodeGroup>
  444. <CodeGroup title="Response">
  445. ```text {{ title: 'Response' }}
  446. 204 No Content
  447. ```
  448. </CodeGroup>
  449. </Col>
  450. </Row>
  451. <hr className='ml-0 mr-0' />
  452. <Heading
  453. url='/datasets/{dataset_id}/documents/{document_id}/update-by-text'
  454. method='POST'
  455. title='Update a Document with Text'
  456. name='#update-by-text'
  457. />
  458. <Row>
  459. <Col>
  460. This API is based on an existing knowledge and updates the document through text based on this knowledge.
  461. ### Params
  462. <Properties>
  463. <Property name='dataset_id' type='string' key='dataset_id'>
  464. Knowledge ID
  465. </Property>
  466. <Property name='document_id' type='string' key='document_id'>
  467. Document ID
  468. </Property>
  469. </Properties>
  470. ### Request Body
  471. <Properties>
  472. <Property name='name' type='string' key='name'>
  473. Document name (optional)
  474. </Property>
  475. <Property name='text' type='string' key='text'>
  476. Document content (optional)
  477. </Property>
  478. <Property name='process_rule' type='object' key='process_rule'>
  479. Processing rules
  480. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  481. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  482. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  483. - <code>id</code> (string) Unique identifier for the preprocessing rule
  484. - enumerate
  485. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  486. - <code>remove_urls_emails</code> Delete URL, email address
  487. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  488. - <code>segmentation</code> (object) Segmentation rules
  489. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  490. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  491. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  492. - <code>subchunk_segmentation</code> (object) Child chunk rules
  493. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  494. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  495. - <code>chunk_overlap</code> Define the overlap between adjacent chunks (optional)
  496. </Property>
  497. </Properties>
  498. </Col>
  499. <Col sticky>
  500. <CodeGroup
  501. title="Request"
  502. tag="POST"
  503. label="/datasets/{dataset_id}/documents/{document_id}/update-by-text"
  504. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "name","text": "text"}'`}
  505. >
  506. ```bash {{ title: 'cURL' }}
  507. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
  508. --header 'Authorization: Bearer {api_key}' \
  509. --header 'Content-Type: application/json' \
  510. --data-raw '{
  511. "name": "name",
  512. "text": "text"
  513. }'
  514. ```
  515. </CodeGroup>
  516. <CodeGroup title="Response">
  517. ```json {{ title: 'Response' }}
  518. {
  519. "document": {
  520. "id": "",
  521. "position": 1,
  522. "data_source_type": "upload_file",
  523. "data_source_info": {
  524. "upload_file_id": ""
  525. },
  526. "dataset_process_rule_id": "",
  527. "name": "name.txt",
  528. "created_from": "api",
  529. "created_by": "",
  530. "created_at": 1695308667,
  531. "tokens": 0,
  532. "indexing_status": "waiting",
  533. "error": null,
  534. "enabled": true,
  535. "disabled_at": null,
  536. "disabled_by": null,
  537. "archived": false,
  538. "display_status": "queuing",
  539. "word_count": 0,
  540. "hit_count": 0,
  541. "doc_form": "text_model"
  542. },
  543. "batch": ""
  544. }
  545. ```
  546. </CodeGroup>
  547. </Col>
  548. </Row>
  549. <hr className='ml-0 mr-0' />
  550. <Heading
  551. url='/datasets/{dataset_id}/documents/{document_id}/update-by-file'
  552. method='POST'
  553. title='Update a Document with a File'
  554. name='#update-by-file'
  555. />
  556. <Row>
  557. <Col>
  558. This API is based on an existing knowledge, and updates documents through files based on this knowledge
  559. ### Params
  560. <Properties>
  561. <Property name='dataset_id' type='string' key='dataset_id'>
  562. Knowledge ID
  563. </Property>
  564. <Property name='document_id' type='string' key='document_id'>
  565. Document ID
  566. </Property>
  567. </Properties>
  568. ### Request Body
  569. <Properties>
  570. <Property name='name' type='string' key='name'>
  571. Document name (optional)
  572. </Property>
  573. <Property name='file' type='multipart/form-data' key='file'>
  574. Files to be uploaded
  575. </Property>
  576. <Property name='process_rule' type='object' key='process_rule'>
  577. Processing rules
  578. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  579. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  580. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  581. - <code>id</code> (string) Unique identifier for the preprocessing rule
  582. - enumerate
  583. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  584. - <code>remove_urls_emails</code> Delete URL, email address
  585. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  586. - <code>segmentation</code> (object) Segmentation rules
  587. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  588. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  589. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  590. - <code>subchunk_segmentation</code> (object) Child chunk rules
  591. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  592. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  593. - <code>chunk_overlap</code> Define the overlap between adjacent chunks (optional)
  594. </Property>
  595. </Properties>
  596. </Col>
  597. <Col sticky>
  598. <CodeGroup
  599. title="Request"
  600. tag="POST"
  601. label="/datasets/{dataset_id}/documents/{document_id}/update-by-file"
  602. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'data="{"name":"Dify","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' \\\n--form 'file=@"/path/to/file"'`}
  603. >
  604. ```bash {{ title: 'cURL' }}
  605. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
  606. --header 'Authorization: Bearer {api_key}' \
  607. --form 'data="{\"name\":\"Dify\",\"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' \
  608. --form 'file=@"/path/to/file"'
  609. ```
  610. </CodeGroup>
  611. <CodeGroup title="Response">
  612. ```json {{ title: 'Response' }}
  613. {
  614. "document": {
  615. "id": "",
  616. "position": 1,
  617. "data_source_type": "upload_file",
  618. "data_source_info": {
  619. "upload_file_id": ""
  620. },
  621. "dataset_process_rule_id": "",
  622. "name": "Dify.txt",
  623. "created_from": "api",
  624. "created_by": "",
  625. "created_at": 1695308667,
  626. "tokens": 0,
  627. "indexing_status": "waiting",
  628. "error": null,
  629. "enabled": true,
  630. "disabled_at": null,
  631. "disabled_by": null,
  632. "archived": false,
  633. "display_status": "queuing",
  634. "word_count": 0,
  635. "hit_count": 0,
  636. "doc_form": "text_model"
  637. },
  638. "batch": "20230921150427533684"
  639. }
  640. ```
  641. </CodeGroup>
  642. </Col>
  643. </Row>
  644. <hr className='ml-0 mr-0' />
  645. <Heading
  646. url='/datasets/{dataset_id}/documents/{batch}/indexing-status'
  647. method='GET'
  648. title='Get Document Embedding Status (Progress)'
  649. name='#indexing_status'
  650. />
  651. <Row>
  652. <Col>
  653. ### Params
  654. <Properties>
  655. <Property name='dataset_id' type='string' key='dataset_id'>
  656. Knowledge ID
  657. </Property>
  658. <Property name='batch' type='string' key='batch'>
  659. Batch number of uploaded documents
  660. </Property>
  661. </Properties>
  662. </Col>
  663. <Col sticky>
  664. <CodeGroup
  665. title="Request"
  666. tag="GET"
  667. label="/datasets/{dataset_id}/documents/{batch}/indexing-status"
  668. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \\\n--header 'Authorization: Bearer {api_key}'`}
  669. >
  670. ```bash {{ title: 'cURL' }}
  671. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
  672. --header 'Authorization: Bearer {api_key}' \
  673. ```
  674. </CodeGroup>
  675. <CodeGroup title="Response">
  676. ```json {{ title: 'Response' }}
  677. {
  678. "data":[{
  679. "id": "",
  680. "indexing_status": "indexing",
  681. "processing_started_at": 1681623462.0,
  682. "parsing_completed_at": 1681623462.0,
  683. "cleaning_completed_at": 1681623462.0,
  684. "splitting_completed_at": 1681623462.0,
  685. "completed_at": null,
  686. "paused_at": null,
  687. "error": null,
  688. "stopped_at": null,
  689. "completed_segments": 24,
  690. "total_segments": 100
  691. }]
  692. }
  693. ```
  694. </CodeGroup>
  695. </Col>
  696. </Row>
  697. <hr className='ml-0 mr-0' />
  698. <Heading
  699. url='/datasets/{dataset_id}/documents/{document_id}'
  700. method='DELETE'
  701. title='Delete a Document'
  702. name='#delete_document'
  703. />
  704. <Row>
  705. <Col>
  706. ### Params
  707. <Properties>
  708. <Property name='dataset_id' type='string' key='dataset_id'>
  709. Knowledge ID
  710. </Property>
  711. <Property name='document_id' type='string' key='document_id'>
  712. Document ID
  713. </Property>
  714. </Properties>
  715. </Col>
  716. <Col sticky>
  717. <CodeGroup
  718. title="Request"
  719. tag="DELETE"
  720. label="/datasets/{dataset_id}/documents/{document_id}"
  721. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  722. >
  723. ```bash {{ title: 'cURL' }}
  724. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
  725. --header 'Authorization: Bearer {api_key}' \
  726. ```
  727. </CodeGroup>
  728. <CodeGroup title="Response">
  729. ```json {{ title: 'Response' }}
  730. {
  731. "result": "success"
  732. }
  733. ```
  734. </CodeGroup>
  735. </Col>
  736. </Row>
  737. <hr className='ml-0 mr-0' />
  738. <Heading
  739. url='/datasets/{dataset_id}/documents'
  740. method='GET'
  741. title='Get the Document List of a Knowledge Base'
  742. name='#dataset_document_list'
  743. />
  744. <Row>
  745. <Col>
  746. ### Params
  747. <Properties>
  748. <Property name='dataset_id' type='string' key='dataset_id'>
  749. Knowledge ID
  750. </Property>
  751. </Properties>
  752. ### Query
  753. <Properties>
  754. <Property name='keyword' type='string' key='keyword'>
  755. Search keywords, currently only search document names (optional)
  756. </Property>
  757. <Property name='page' type='string' key='page'>
  758. Page number (optional)
  759. </Property>
  760. <Property name='limit' type='string' key='limit'>
  761. Number of items returned, default 20, range 1-100 (optional)
  762. </Property>
  763. </Properties>
  764. </Col>
  765. <Col sticky>
  766. <CodeGroup
  767. title="Request"
  768. tag="GET"
  769. label="/datasets/{dataset_id}/documents"
  770. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \\\n--header 'Authorization: Bearer {api_key}'`}
  771. >
  772. ```bash {{ title: 'cURL' }}
  773. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
  774. --header 'Authorization: Bearer {api_key}' \
  775. ```
  776. </CodeGroup>
  777. <CodeGroup title="Response">
  778. ```json {{ title: 'Response' }}
  779. {
  780. "data": [
  781. {
  782. "id": "",
  783. "position": 1,
  784. "data_source_type": "file_upload",
  785. "data_source_info": null,
  786. "dataset_process_rule_id": null,
  787. "name": "dify",
  788. "created_from": "",
  789. "created_by": "",
  790. "created_at": 1681623639,
  791. "tokens": 0,
  792. "indexing_status": "waiting",
  793. "error": null,
  794. "enabled": true,
  795. "disabled_at": null,
  796. "disabled_by": null,
  797. "archived": false
  798. },
  799. ],
  800. "has_more": false,
  801. "limit": 20,
  802. "total": 9,
  803. "page": 1
  804. }
  805. ```
  806. </CodeGroup>
  807. </Col>
  808. </Row>
  809. <hr className='ml-0 mr-0' />
  810. <Heading
  811. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  812. method='POST'
  813. title='Add Chunks to a Document'
  814. name='#create_new_segment'
  815. />
  816. <Row>
  817. <Col>
  818. ### Params
  819. <Properties>
  820. <Property name='dataset_id' type='string' key='dataset_id'>
  821. Knowledge ID
  822. </Property>
  823. <Property name='document_id' type='string' key='document_id'>
  824. Document ID
  825. </Property>
  826. </Properties>
  827. ### Request Body
  828. <Properties>
  829. <Property name='segments' type='object list' key='segments'>
  830. - <code>content</code> (text) Text content / question content, required
  831. - <code>answer</code> (text) Answer content, if the mode of the knowledge is Q&A mode, pass the value (optional)
  832. - <code>keywords</code> (list) Keywords (optional)
  833. </Property>
  834. </Properties>
  835. </Col>
  836. <Col sticky>
  837. <CodeGroup
  838. title="Request"
  839. tag="POST"
  840. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  841. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"segments": [{"content": "1","answer": "1","keywords": ["a"]}]}'`}
  842. >
  843. ```bash {{ title: 'cURL' }}
  844. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  845. --header 'Authorization: Bearer {api_key}' \
  846. --header 'Content-Type: application/json' \
  847. --data-raw '{
  848. "segments": [
  849. {
  850. "content": "1",
  851. "answer": "1",
  852. "keywords": ["a"]
  853. }
  854. ]
  855. }'
  856. ```
  857. </CodeGroup>
  858. <CodeGroup title="Response">
  859. ```json {{ title: 'Response' }}
  860. {
  861. "data": [{
  862. "id": "",
  863. "position": 1,
  864. "document_id": "",
  865. "content": "1",
  866. "answer": "1",
  867. "word_count": 25,
  868. "tokens": 0,
  869. "keywords": [
  870. "a"
  871. ],
  872. "index_node_id": "",
  873. "index_node_hash": "",
  874. "hit_count": 0,
  875. "enabled": true,
  876. "disabled_at": null,
  877. "disabled_by": null,
  878. "status": "completed",
  879. "created_by": "",
  880. "created_at": 1695312007,
  881. "indexing_at": 1695312007,
  882. "completed_at": 1695312007,
  883. "error": null,
  884. "stopped_at": null
  885. }],
  886. "doc_form": "text_model"
  887. }
  888. ```
  889. </CodeGroup>
  890. </Col>
  891. </Row>
  892. <hr className='ml-0 mr-0' />
  893. <Heading
  894. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  895. method='GET'
  896. title='Get Chunks from a Document'
  897. name='#get_segment'
  898. />
  899. <Row>
  900. <Col>
  901. ### Path
  902. <Properties>
  903. <Property name='dataset_id' type='string' key='dataset_id'>
  904. Knowledge ID
  905. </Property>
  906. <Property name='document_id' type='string' key='document_id'>
  907. Document ID
  908. </Property>
  909. </Properties>
  910. ### Query
  911. <Properties>
  912. <Property name='keyword' type='string' key='keyword'>
  913. Keyword (optional)
  914. </Property>
  915. <Property name='status' type='string' key='status'>
  916. Search status, completed
  917. </Property>
  918. <Property name='page' type='string' key='page'>
  919. Page number (optional)
  920. </Property>
  921. <Property name='limit' type='string' key='limit'>
  922. Number of items returned, default 20, range 1-100 (optional)
  923. </Property>
  924. </Properties>
  925. </Col>
  926. <Col sticky>
  927. <CodeGroup
  928. title="Request"
  929. tag="GET"
  930. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  931. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  932. >
  933. ```bash {{ title: 'cURL' }}
  934. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  935. --header 'Authorization: Bearer {api_key}' \
  936. --header 'Content-Type: application/json'
  937. ```
  938. </CodeGroup>
  939. <CodeGroup title="Response">
  940. ```json {{ title: 'Response' }}
  941. {
  942. "data": [{
  943. "id": "",
  944. "position": 1,
  945. "document_id": "",
  946. "content": "1",
  947. "answer": "1",
  948. "word_count": 25,
  949. "tokens": 0,
  950. "keywords": [
  951. "a"
  952. ],
  953. "index_node_id": "",
  954. "index_node_hash": "",
  955. "hit_count": 0,
  956. "enabled": true,
  957. "disabled_at": null,
  958. "disabled_by": null,
  959. "status": "completed",
  960. "created_by": "",
  961. "created_at": 1695312007,
  962. "indexing_at": 1695312007,
  963. "completed_at": 1695312007,
  964. "error": null,
  965. "stopped_at": null
  966. }],
  967. "doc_form": "text_model",
  968. "has_more": false,
  969. "limit": 20,
  970. "total": 9,
  971. "page": 1
  972. }
  973. ```
  974. </CodeGroup>
  975. </Col>
  976. </Row>
  977. <hr className='ml-0 mr-0' />
  978. <Heading
  979. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  980. method='DELETE'
  981. title='Delete a Chunk in a Document'
  982. name='#delete_segment'
  983. />
  984. <Row>
  985. <Col>
  986. ### Path
  987. <Properties>
  988. <Property name='dataset_id' type='string' key='dataset_id'>
  989. Knowledge ID
  990. </Property>
  991. <Property name='document_id' type='string' key='document_id'>
  992. Document ID
  993. </Property>
  994. <Property name='segment_id' type='string' key='segment_id'>
  995. Document Segment ID
  996. </Property>
  997. </Properties>
  998. </Col>
  999. <Col sticky>
  1000. <CodeGroup
  1001. title="Request"
  1002. tag="DELETE"
  1003. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1004. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1005. >
  1006. ```bash {{ title: 'cURL' }}
  1007. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \
  1008. --header 'Authorization: Bearer {api_key}' \
  1009. --header 'Content-Type: application/json'
  1010. ```
  1011. </CodeGroup>
  1012. <CodeGroup title="Response">
  1013. ```json {{ title: 'Response' }}
  1014. {
  1015. "result": "success"
  1016. }
  1017. ```
  1018. </CodeGroup>
  1019. </Col>
  1020. </Row>
  1021. <hr className='ml-0 mr-0' />
  1022. <Heading
  1023. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1024. method='POST'
  1025. title='Update a Chunk in a Document'
  1026. name='#update_segment'
  1027. />
  1028. <Row>
  1029. <Col>
  1030. ### POST
  1031. <Properties>
  1032. <Property name='dataset_id' type='string' key='dataset_id'>
  1033. Knowledge ID
  1034. </Property>
  1035. <Property name='document_id' type='string' key='document_id'>
  1036. Document ID
  1037. </Property>
  1038. <Property name='segment_id' type='string' key='segment_id'>
  1039. Document Segment ID
  1040. </Property>
  1041. </Properties>
  1042. ### Request Body
  1043. <Properties>
  1044. <Property name='segment' type='object' key='segment'>
  1045. - <code>content</code> (text) Text content / question content, required
  1046. - <code>answer</code> (text) Answer content, passed if the knowledge is in Q&A mode (optional)
  1047. - <code>keywords</code> (list) Keyword (optional)
  1048. - <code>enabled</code> (bool) False / true (optional)
  1049. - <code>regenerate_child_chunks</code> (bool) Whether to regenerate child chunks (optional)
  1050. </Property>
  1051. </Properties>
  1052. </Col>
  1053. <Col sticky>
  1054. <CodeGroup
  1055. title="Request"
  1056. tag="POST"
  1057. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1058. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{\"segment\": {\"content\": \"1\",\"answer\": \"1\", \"keywords\": [\"a\"], \"enabled\": false}}'`}
  1059. >
  1060. ```bash {{ title: 'cURL' }}
  1061. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1062. --header 'Content-Type: application/json' \
  1063. --data-raw '{
  1064. "segment": {
  1065. "content": "1",
  1066. "answer": "1",
  1067. "keywords": ["a"],
  1068. "enabled": false
  1069. }
  1070. }'
  1071. ```
  1072. </CodeGroup>
  1073. <CodeGroup title="Response">
  1074. ```json {{ title: 'Response' }}
  1075. {
  1076. "data": {
  1077. "id": "",
  1078. "position": 1,
  1079. "document_id": "",
  1080. "content": "1",
  1081. "answer": "1",
  1082. "word_count": 25,
  1083. "tokens": 0,
  1084. "keywords": [
  1085. "a"
  1086. ],
  1087. "index_node_id": "",
  1088. "index_node_hash": "",
  1089. "hit_count": 0,
  1090. "enabled": true,
  1091. "disabled_at": null,
  1092. "disabled_by": null,
  1093. "status": "completed",
  1094. "created_by": "",
  1095. "created_at": 1695312007,
  1096. "indexing_at": 1695312007,
  1097. "completed_at": 1695312007,
  1098. "error": null,
  1099. "stopped_at": null
  1100. },
  1101. "doc_form": "text_model"
  1102. }
  1103. ```
  1104. </CodeGroup>
  1105. </Col>
  1106. </Row>
  1107. <hr className='ml-0 mr-0' />
  1108. <Heading
  1109. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1110. method='POST'
  1111. title='Create Child Chunk'
  1112. name='#create_child_chunk'
  1113. />
  1114. <Row>
  1115. <Col>
  1116. ### Params
  1117. <Properties>
  1118. <Property name='dataset_id' type='string' key='dataset_id'>
  1119. Knowledge ID
  1120. </Property>
  1121. <Property name='document_id' type='string' key='document_id'>
  1122. Document ID
  1123. </Property>
  1124. <Property name='segment_id' type='string' key='segment_id'>
  1125. Segment ID
  1126. </Property>
  1127. </Properties>
  1128. ### Request Body
  1129. <Properties>
  1130. <Property name='content' type='string' key='content'>
  1131. Child chunk content
  1132. </Property>
  1133. </Properties>
  1134. </Col>
  1135. <Col sticky>
  1136. <CodeGroup
  1137. title="Request"
  1138. tag="POST"
  1139. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1140. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"content": "Child chunk content"}'`}
  1141. >
  1142. ```bash {{ title: 'cURL' }}
  1143. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \
  1144. --header 'Authorization: Bearer {api_key}' \
  1145. --header 'Content-Type: application/json' \
  1146. --data-raw '{
  1147. "content": "Child chunk content"
  1148. }'
  1149. ```
  1150. </CodeGroup>
  1151. <CodeGroup title="Response">
  1152. ```json {{ title: 'Response' }}
  1153. {
  1154. "data": {
  1155. "id": "",
  1156. "segment_id": "",
  1157. "content": "Child chunk content",
  1158. "word_count": 25,
  1159. "tokens": 0,
  1160. "index_node_id": "",
  1161. "index_node_hash": "",
  1162. "status": "completed",
  1163. "created_by": "",
  1164. "created_at": 1695312007,
  1165. "indexing_at": 1695312007,
  1166. "completed_at": 1695312007,
  1167. "error": null,
  1168. "stopped_at": null
  1169. }
  1170. }
  1171. ```
  1172. </CodeGroup>
  1173. </Col>
  1174. </Row>
  1175. <hr className='ml-0 mr-0' />
  1176. <Heading
  1177. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1178. method='GET'
  1179. title='Get Child Chunks'
  1180. name='#get_child_chunks'
  1181. />
  1182. <Row>
  1183. <Col>
  1184. ### Params
  1185. <Properties>
  1186. <Property name='dataset_id' type='string' key='dataset_id'>
  1187. Knowledge ID
  1188. </Property>
  1189. <Property name='document_id' type='string' key='document_id'>
  1190. Document ID
  1191. </Property>
  1192. <Property name='segment_id' type='string' key='segment_id'>
  1193. Segment ID
  1194. </Property>
  1195. </Properties>
  1196. ### Query
  1197. <Properties>
  1198. <Property name='keyword' type='string' key='keyword'>
  1199. Search keyword (optional)
  1200. </Property>
  1201. <Property name='page' type='integer' key='page'>
  1202. Page number (optional, default: 1)
  1203. </Property>
  1204. <Property name='limit' type='integer' key='limit'>
  1205. Items per page (optional, default: 20, max: 100)
  1206. </Property>
  1207. </Properties>
  1208. </Col>
  1209. <Col sticky>
  1210. <CodeGroup
  1211. title="Request"
  1212. tag="GET"
  1213. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1214. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  1215. >
  1216. ```bash {{ title: 'cURL' }}
  1217. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \
  1218. --header 'Authorization: Bearer {api_key}'
  1219. ```
  1220. </CodeGroup>
  1221. <CodeGroup title="Response">
  1222. ```json {{ title: 'Response' }}
  1223. {
  1224. "data": [{
  1225. "id": "",
  1226. "segment_id": "",
  1227. "content": "Child chunk content",
  1228. "word_count": 25,
  1229. "tokens": 0,
  1230. "index_node_id": "",
  1231. "index_node_hash": "",
  1232. "status": "completed",
  1233. "created_by": "",
  1234. "created_at": 1695312007,
  1235. "indexing_at": 1695312007,
  1236. "completed_at": 1695312007,
  1237. "error": null,
  1238. "stopped_at": null
  1239. }],
  1240. "total": 1,
  1241. "total_pages": 1,
  1242. "page": 1,
  1243. "limit": 20
  1244. }
  1245. ```
  1246. </CodeGroup>
  1247. </Col>
  1248. </Row>
  1249. <hr className='ml-0 mr-0' />
  1250. <Heading
  1251. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1252. method='DELETE'
  1253. title='Delete Child Chunk'
  1254. name='#delete_child_chunk'
  1255. />
  1256. <Row>
  1257. <Col>
  1258. ### Params
  1259. <Properties>
  1260. <Property name='dataset_id' type='string' key='dataset_id'>
  1261. Knowledge ID
  1262. </Property>
  1263. <Property name='document_id' type='string' key='document_id'>
  1264. Document ID
  1265. </Property>
  1266. <Property name='segment_id' type='string' key='segment_id'>
  1267. Segment ID
  1268. </Property>
  1269. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1270. Child Chunk ID
  1271. </Property>
  1272. </Properties>
  1273. </Col>
  1274. <Col sticky>
  1275. <CodeGroup
  1276. title="Request"
  1277. tag="DELETE"
  1278. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1279. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1280. >
  1281. ```bash {{ title: 'cURL' }}
  1282. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1283. --header 'Authorization: Bearer {api_key}'
  1284. ```
  1285. </CodeGroup>
  1286. <CodeGroup title="Response">
  1287. ```json {{ title: 'Response' }}
  1288. {
  1289. "result": "success"
  1290. }
  1291. ```
  1292. </CodeGroup>
  1293. </Col>
  1294. </Row>
  1295. <hr className='ml-0 mr-0' />
  1296. <Heading
  1297. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1298. method='PATCH'
  1299. title='Update Child Chunk'
  1300. name='#update_child_chunk'
  1301. />
  1302. <Row>
  1303. <Col>
  1304. ### Params
  1305. <Properties>
  1306. <Property name='dataset_id' type='string' key='dataset_id'>
  1307. Knowledge ID
  1308. </Property>
  1309. <Property name='document_id' type='string' key='document_id'>
  1310. Document ID
  1311. </Property>
  1312. <Property name='segment_id' type='string' key='segment_id'>
  1313. Segment ID
  1314. </Property>
  1315. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1316. Child Chunk ID
  1317. </Property>
  1318. </Properties>
  1319. ### Request Body
  1320. <Properties>
  1321. <Property name='content' type='string' key='content'>
  1322. Child chunk content
  1323. </Property>
  1324. </Properties>
  1325. </Col>
  1326. <Col sticky>
  1327. <CodeGroup
  1328. title="Request"
  1329. tag="PATCH"
  1330. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1331. targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"content": "Updated child chunk content"}'`}
  1332. >
  1333. ```bash {{ title: 'cURL' }}
  1334. curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1335. --header 'Authorization: Bearer {api_key}' \
  1336. --header 'Content-Type: application/json' \
  1337. --data-raw '{
  1338. "content": "Updated child chunk content"
  1339. }'
  1340. ```
  1341. </CodeGroup>
  1342. <CodeGroup title="Response">
  1343. ```json {{ title: 'Response' }}
  1344. {
  1345. "data": {
  1346. "id": "",
  1347. "segment_id": "",
  1348. "content": "Updated child chunk content",
  1349. "word_count": 25,
  1350. "tokens": 0,
  1351. "index_node_id": "",
  1352. "index_node_hash": "",
  1353. "status": "completed",
  1354. "created_by": "",
  1355. "created_at": 1695312007,
  1356. "indexing_at": 1695312007,
  1357. "completed_at": 1695312007,
  1358. "error": null,
  1359. "stopped_at": null
  1360. }
  1361. }
  1362. ```
  1363. </CodeGroup>
  1364. </Col>
  1365. </Row>
  1366. <hr className='ml-0 mr-0' />
  1367. <Heading
  1368. url='/datasets/{dataset_id}/documents/{document_id}/upload-file'
  1369. method='GET'
  1370. title='Get Upload File'
  1371. name='#get_upload_file'
  1372. />
  1373. <Row>
  1374. <Col>
  1375. ### Path
  1376. <Properties>
  1377. <Property name='dataset_id' type='string' key='dataset_id'>
  1378. Knowledge ID
  1379. </Property>
  1380. <Property name='document_id' type='string' key='document_id'>
  1381. Document ID
  1382. </Property>
  1383. </Properties>
  1384. </Col>
  1385. <Col sticky>
  1386. <CodeGroup
  1387. title="Request"
  1388. tag="GET"
  1389. label="/datasets/{dataset_id}/documents/{document_id}/upload-file"
  1390. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1391. >
  1392. ```bash {{ title: 'cURL' }}
  1393. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \
  1394. --header 'Authorization: Bearer {api_key}' \
  1395. --header 'Content-Type: application/json'
  1396. ```
  1397. </CodeGroup>
  1398. <CodeGroup title="Response">
  1399. ```json {{ title: 'Response' }}
  1400. {
  1401. "id": "file_id",
  1402. "name": "file_name",
  1403. "size": 1024,
  1404. "extension": "txt",
  1405. "url": "preview_url",
  1406. "download_url": "download_url",
  1407. "mime_type": "text/plain",
  1408. "created_by": "user_id",
  1409. "created_at": 1728734540,
  1410. }
  1411. ```
  1412. </CodeGroup>
  1413. </Col>
  1414. </Row>
  1415. <hr className='ml-0 mr-0' />
  1416. <Heading
  1417. url='/datasets/{dataset_id}/retrieve'
  1418. method='POST'
  1419. title='Retrieve Chunks from a Knowledge Base'
  1420. name='#dataset_retrieval'
  1421. />
  1422. <Row>
  1423. <Col>
  1424. ### Path
  1425. <Properties>
  1426. <Property name='dataset_id' type='string' key='dataset_id'>
  1427. Knowledge ID
  1428. </Property>
  1429. </Properties>
  1430. ### Request Body
  1431. <Properties>
  1432. <Property name='query' type='string' key='query'>
  1433. Query keyword
  1434. </Property>
  1435. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1436. Retrieval model (optional, if not filled, it will be recalled according to the default method)
  1437. - <code>search_method</code> (text) Search method: One of the following four keywords is required
  1438. - <code>keyword_search</code> Keyword search
  1439. - <code>semantic_search</code> Semantic search
  1440. - <code>full_text_search</code> Full-text search
  1441. - <code>hybrid_search</code> Hybrid search
  1442. - <code>reranking_enable</code> (bool) Whether to enable reranking, required if the search mode is semantic_search or hybrid_search (optional)
  1443. - <code>reranking_mode</code> (object) Rerank model configuration, required if reranking is enabled
  1444. - <code>reranking_provider_name</code> (string) Rerank model provider
  1445. - <code>reranking_model_name</code> (string) Rerank model name
  1446. - <code>weights</code> (float) Semantic search weight setting in hybrid search mode
  1447. - <code>top_k</code> (integer) Number of results to return (optional)
  1448. - <code>score_threshold_enabled</code> (bool) Whether to enable score threshold
  1449. - <code>score_threshold</code> (float) Score threshold
  1450. </Property>
  1451. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1452. Unused field
  1453. </Property>
  1454. </Properties>
  1455. </Col>
  1456. <Col sticky>
  1457. <CodeGroup
  1458. title="Request"
  1459. tag="POST"
  1460. label="/datasets/{dataset_id}/retrieve"
  1461. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \\\n--header 'Authorization: Bearer {api_key}'\\\n--header 'Content-Type: application/json'\\\n--data-raw '{
  1462. "query": "test",
  1463. "retrieval_model": {
  1464. "search_method": "keyword_search",
  1465. "reranking_enable": false,
  1466. "reranking_mode": null,
  1467. "reranking_model": {
  1468. "reranking_provider_name": "",
  1469. "reranking_model_name": ""
  1470. },
  1471. "weights": null,
  1472. "top_k": 1,
  1473. "score_threshold_enabled": false,
  1474. "score_threshold": null
  1475. }
  1476. }'`}
  1477. >
  1478. ```bash {{ title: 'cURL' }}
  1479. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1480. --header 'Authorization: Bearer {api_key}' \
  1481. --header 'Content-Type: application/json' \
  1482. --data-raw '{
  1483. "query": "test",
  1484. "retrieval_model": {
  1485. "search_method": "keyword_search",
  1486. "reranking_enable": false,
  1487. "reranking_mode": null,
  1488. "reranking_model": {
  1489. "reranking_provider_name": "",
  1490. "reranking_model_name": ""
  1491. },
  1492. "weights": null,
  1493. "top_k": 2,
  1494. "score_threshold_enabled": false,
  1495. "score_threshold": null
  1496. }
  1497. }'
  1498. ```
  1499. </CodeGroup>
  1500. <CodeGroup title="Response">
  1501. ```json {{ title: 'Response' }}
  1502. {
  1503. "query": {
  1504. "content": "test"
  1505. },
  1506. "records": [
  1507. {
  1508. "segment": {
  1509. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1510. "position": 1,
  1511. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1512. "content": "Operation guide",
  1513. "answer": null,
  1514. "word_count": 847,
  1515. "tokens": 280,
  1516. "keywords": [
  1517. "install",
  1518. "java",
  1519. "base",
  1520. "scripts",
  1521. "jdk",
  1522. "manual",
  1523. "internal",
  1524. "opens",
  1525. "add",
  1526. "vmoptions"
  1527. ],
  1528. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1529. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1530. "hit_count": 0,
  1531. "enabled": true,
  1532. "disabled_at": null,
  1533. "disabled_by": null,
  1534. "status": "completed",
  1535. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1536. "created_at": 1728734540,
  1537. "indexing_at": 1728734552,
  1538. "completed_at": 1728734584,
  1539. "error": null,
  1540. "stopped_at": null,
  1541. "document": {
  1542. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1543. "data_source_type": "upload_file",
  1544. "name": "readme.txt",
  1545. }
  1546. },
  1547. "score": 3.730463140527718e-05,
  1548. "tsne_position": null
  1549. }
  1550. ]
  1551. }
  1552. ```
  1553. </CodeGroup>
  1554. </Col>
  1555. </Row>
  1556. <hr className='ml-0 mr-0' />
  1557. <Heading
  1558. url='/datasets/{dataset_id}/metadata'
  1559. method='POST'
  1560. title='Create a Knowledge Metadata'
  1561. name='#create_metadata'
  1562. />
  1563. <Row>
  1564. <Col>
  1565. ### Params
  1566. <Properties>
  1567. <Property name='dataset_id' type='string' key='dataset_id'>
  1568. Knowledge ID
  1569. </Property>
  1570. </Properties>
  1571. ### Request Body
  1572. <Properties>
  1573. <Property name='segment' type='object' key='segment'>
  1574. - <code>type</code> (string) Metadata type, required
  1575. - <code>name</code> (string) Metadata name, required
  1576. </Property>
  1577. </Properties>
  1578. </Col>
  1579. <Col sticky>
  1580. <CodeGroup
  1581. title="Request"
  1582. tag="POST"
  1583. label="/datasets/{dataset_id}/metadata"
  1584. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"type": "string", "name": "test"}'`}
  1585. >
  1586. ```bash {{ title: 'cURL' }}
  1587. ```
  1588. </CodeGroup>
  1589. <CodeGroup title="Response">
  1590. ```json {{ title: 'Response' }}
  1591. {
  1592. "id": "abc",
  1593. "type": "string",
  1594. "name": "test",
  1595. }
  1596. ```
  1597. </CodeGroup>
  1598. </Col>
  1599. </Row>
  1600. <hr className='ml-0 mr-0' />
  1601. <Heading
  1602. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  1603. method='PATCH'
  1604. title='Update a Knowledge Metadata'
  1605. name='#update_metadata'
  1606. />
  1607. <Row>
  1608. <Col>
  1609. ### Params
  1610. <Properties>
  1611. <Property name='dataset_id' type='string' key='dataset_id'>
  1612. Knowledge ID
  1613. </Property>
  1614. <Property name='metadata_id' type='string' key='metadata_id'>
  1615. Metadata ID
  1616. </Property>
  1617. </Properties>
  1618. ### Request Body
  1619. <Properties>
  1620. <Property name='segment' type='object' key='segment'>
  1621. - <code>name</code> (string) Metadata name, required
  1622. </Property>
  1623. </Properties>
  1624. </Col>
  1625. <Col sticky>
  1626. <CodeGroup
  1627. title="Request"
  1628. tag="POST"
  1629. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  1630. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"name": "test"}'`}
  1631. >
  1632. ```bash {{ title: 'cURL' }}
  1633. ```
  1634. </CodeGroup>
  1635. <CodeGroup title="Response">
  1636. ```json {{ title: 'Response' }}
  1637. {
  1638. "id": "abc",
  1639. "type": "string",
  1640. "name": "test",
  1641. }
  1642. ```
  1643. </CodeGroup>
  1644. </Col>
  1645. </Row>
  1646. <hr className='ml-0 mr-0' />
  1647. <Heading
  1648. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  1649. method='DELETE'
  1650. title='Delete a Knowledge Metadata'
  1651. name='#delete_metadata'
  1652. />
  1653. <Row>
  1654. <Col>
  1655. ### Params
  1656. <Properties>
  1657. <Property name='dataset_id' type='string' key='dataset_id'>
  1658. Knowledge ID
  1659. </Property>
  1660. <Property name='metadata_id' type='string' key='metadata_id'>
  1661. Metadata ID
  1662. </Property>
  1663. </Properties>
  1664. </Col>
  1665. <Col sticky>
  1666. <CodeGroup
  1667. title="Request"
  1668. tag="DELETE"
  1669. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  1670. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1671. >
  1672. ```bash {{ title: 'cURL' }}
  1673. ```
  1674. </CodeGroup>
  1675. </Col>
  1676. </Row>
  1677. <hr className='ml-0 mr-0' />
  1678. <Heading
  1679. url='/datasets/{dataset_id}/metadata/built-in/{action}'
  1680. method='POST'
  1681. title='Disable Or Enable Built-in Metadata'
  1682. name='#toggle_metadata'
  1683. />
  1684. <Row>
  1685. <Col>
  1686. ### Params
  1687. <Properties>
  1688. <Property name='dataset_id' type='string' key='dataset_id'>
  1689. Knowledge ID
  1690. </Property>
  1691. <Property name='action' type='string' key='action'>
  1692. disable/enable
  1693. </Property>
  1694. </Properties>
  1695. </Col>
  1696. <Col sticky>
  1697. <CodeGroup
  1698. title="Request"
  1699. tag="POST"
  1700. label="/datasets/{dataset_id}/metadata/built-in/{action}"
  1701. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1702. >
  1703. ```bash {{ title: 'cURL' }}
  1704. ```
  1705. </CodeGroup>
  1706. </Col>
  1707. </Row>
  1708. <hr className='ml-0 mr-0' />
  1709. <Heading
  1710. url='/datasets/{dataset_id}/documents/metadata'
  1711. method='POST'
  1712. title='Update Documents Metadata'
  1713. name='#update_documents_metadata'
  1714. />
  1715. <Row>
  1716. <Col>
  1717. ### Params
  1718. <Properties>
  1719. <Property name='dataset_id' type='string' key='dataset_id'>
  1720. Knowledge ID
  1721. </Property>
  1722. </Properties>
  1723. ### Request Body
  1724. <Properties>
  1725. <Property name='operation_data' type='object list' key='segments'>
  1726. - <code>document_id</code> (string) Document ID
  1727. - <code>metadata_list</code> (list) Metadata list
  1728. - <code>id</code> (string) Metadata ID
  1729. - <code>value</code> (string) Metadata value
  1730. - <code>name</code> (string) Metadata name
  1731. </Property>
  1732. </Properties>
  1733. </Col>
  1734. <Col sticky>
  1735. <CodeGroup
  1736. title="Request"
  1737. tag="POST"
  1738. label="/datasets/{dataset_id}/documents/metadata"
  1739. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"operation_data": [{"document_id": "document_id", "metadata_list": [{"id": "id", "value": "value", "name": "name"}]}]}'`}
  1740. >
  1741. ```bash {{ title: 'cURL' }}
  1742. ```
  1743. </CodeGroup>
  1744. </Col>
  1745. </Row>
  1746. <hr className='ml-0 mr-0' />
  1747. <Heading
  1748. url='/datasets/{dataset_id}/metadata'
  1749. method='GET'
  1750. title='Get Knowledge Metadata List'
  1751. name='#dataset_metadata_list'
  1752. />
  1753. <Row>
  1754. <Col>
  1755. ### Params
  1756. <Properties>
  1757. <Property name='dataset_id' type='string' key='dataset_id'>
  1758. Knowledge ID
  1759. </Property>
  1760. </Properties>
  1761. </Col>
  1762. <Col sticky>
  1763. <CodeGroup
  1764. title="Request"
  1765. tag="GET"
  1766. label="/datasets/{dataset_id}/metadata"
  1767. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
  1768. >
  1769. ```bash {{ title: 'cURL' }}
  1770. ```
  1771. </CodeGroup>
  1772. <CodeGroup title="Response">
  1773. ```json {{ title: 'Response' }}
  1774. {
  1775. "doc_metadata": [
  1776. {
  1777. "id": "",
  1778. "name": "name",
  1779. "type": "string",
  1780. "use_count": 0,
  1781. },
  1782. ...
  1783. ],
  1784. "built_in_field_enabled": true
  1785. }
  1786. ```
  1787. </CodeGroup>
  1788. </Col>
  1789. </Row>
  1790. <hr className='ml-0 mr-0' />
  1791. <Row>
  1792. <Col>
  1793. ### Error message
  1794. <Properties>
  1795. <Property name='code' type='string' key='code'>
  1796. Error code
  1797. </Property>
  1798. </Properties>
  1799. <Properties>
  1800. <Property name='status' type='number' key='status'>
  1801. Error status
  1802. </Property>
  1803. </Properties>
  1804. <Properties>
  1805. <Property name='message' type='string' key='message'>
  1806. Error message
  1807. </Property>
  1808. </Properties>
  1809. </Col>
  1810. <Col>
  1811. <CodeGroup title="Example">
  1812. ```json {{ title: 'Response' }}
  1813. {
  1814. "code": "no_file_uploaded",
  1815. "message": "Please upload your file.",
  1816. "status": 400
  1817. }
  1818. ```
  1819. </CodeGroup>
  1820. </Col>
  1821. </Row>
  1822. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  1823. <thead style={{ background: '#f9fafc' }}>
  1824. <tr>
  1825. <th className="p-2 border border-slate-300">code</th>
  1826. <th className="p-2 border border-slate-300">status</th>
  1827. <th className="p-2 border border-slate-300">message</th>
  1828. </tr>
  1829. </thead>
  1830. <tbody>
  1831. <tr>
  1832. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  1833. <td className="p-2 border border-slate-300">400</td>
  1834. <td className="p-2 border border-slate-300">Please upload your file.</td>
  1835. </tr>
  1836. <tr>
  1837. <td className="p-2 border border-slate-300">too_many_files</td>
  1838. <td className="p-2 border border-slate-300">400</td>
  1839. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  1840. </tr>
  1841. <tr>
  1842. <td className="p-2 border border-slate-300">file_too_large</td>
  1843. <td className="p-2 border border-slate-300">413</td>
  1844. <td className="p-2 border border-slate-300">File size exceeded.</td>
  1845. </tr>
  1846. <tr>
  1847. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  1848. <td className="p-2 border border-slate-300">415</td>
  1849. <td className="p-2 border border-slate-300">File type not allowed.</td>
  1850. </tr>
  1851. <tr>
  1852. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  1853. <td className="p-2 border border-slate-300">400</td>
  1854. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  1855. </tr>
  1856. <tr>
  1857. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  1858. <td className="p-2 border border-slate-300">400</td>
  1859. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  1860. </tr>
  1861. <tr>
  1862. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  1863. <td className="p-2 border border-slate-300">403</td>
  1864. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  1865. </tr>
  1866. <tr>
  1867. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  1868. <td className="p-2 border border-slate-300">409</td>
  1869. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  1870. </tr>
  1871. <tr>
  1872. <td className="p-2 border border-slate-300">invalid_action</td>
  1873. <td className="p-2 border border-slate-300">400</td>
  1874. <td className="p-2 border border-slate-300">Invalid action.</td>
  1875. </tr>
  1876. <tr>
  1877. <td className="p-2 border border-slate-300">document_already_finished</td>
  1878. <td className="p-2 border border-slate-300">400</td>
  1879. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  1880. </tr>
  1881. <tr>
  1882. <td className="p-2 border border-slate-300">document_indexing</td>
  1883. <td className="p-2 border border-slate-300">400</td>
  1884. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  1885. </tr>
  1886. <tr>
  1887. <td className="p-2 border border-slate-300">invalid_metadata</td>
  1888. <td className="p-2 border border-slate-300">400</td>
  1889. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  1890. </tr>
  1891. </tbody>
  1892. </table>
  1893. <div className="pb-4" />