template.en.mdx 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. import { CodeGroup } from '@/app/components/develop/code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, 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. </Property>
  71. </Properties>
  72. </Col>
  73. <Col sticky>
  74. <CodeGroup
  75. title="Request"
  76. tag="POST"
  77. label="/datasets/{dataset_id}/document/create-by-text"
  78. 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"}}'`}
  79. >
  80. ```bash {{ title: 'cURL' }}
  81. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
  82. --header 'Authorization: Bearer {api_key}' \
  83. --header 'Content-Type: application/json' \
  84. --data-raw '{
  85. "name": "text",
  86. "text": "text",
  87. "indexing_technique": "high_quality",
  88. "process_rule": {
  89. "mode": "automatic"
  90. }
  91. }'
  92. ```
  93. </CodeGroup>
  94. <CodeGroup title="Response">
  95. ```json {{ title: 'Response' }}
  96. {
  97. "document": {
  98. "id": "",
  99. "position": 1,
  100. "data_source_type": "upload_file",
  101. "data_source_info": {
  102. "upload_file_id": ""
  103. },
  104. "dataset_process_rule_id": "",
  105. "name": "text.txt",
  106. "created_from": "api",
  107. "created_by": "",
  108. "created_at": 1695690280,
  109. "tokens": 0,
  110. "indexing_status": "waiting",
  111. "error": null,
  112. "enabled": true,
  113. "disabled_at": null,
  114. "disabled_by": null,
  115. "archived": false,
  116. "display_status": "queuing",
  117. "word_count": 0,
  118. "hit_count": 0,
  119. "doc_form": "text_model"
  120. },
  121. "batch": ""
  122. }
  123. ```
  124. </CodeGroup>
  125. </Col>
  126. </Row>
  127. <hr className='ml-0 mr-0' />
  128. <Heading
  129. url='/datasets/{dataset_id}/document/create-by-file'
  130. method='POST'
  131. title='Create a Document from a File'
  132. name='#create-by-file'
  133. />
  134. <Row>
  135. <Col>
  136. This API is based on an existing knowledge and creates a new document through a file based on this knowledge.
  137. ### Params
  138. <Properties>
  139. <Property name='dataset_id' type='string' key='dataset_id'>
  140. Knowledge ID
  141. </Property>
  142. </Properties>
  143. ### Request Body
  144. <Properties>
  145. <Property name='data' type='multipart/form-data json string' key='data'>
  146. - <code>original_document_id</code> Source document ID (optional)
  147. - Used to re-upload the document or modify the document cleaning and segmentation configuration. The missing information is copied from the source document
  148. - The source document cannot be an archived document
  149. - 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
  150. - When original_document_id is not passed in, the new operation is performed on behalf of the document, and process_rule is required
  151. - <code>indexing_technique</code> Index mode
  152. - <code>high_quality</code> High quality: embedding using embedding model, built as vector database index
  153. - <code>economy</code> Economy: Build using inverted index of keyword table index
  154. - <code>doc_form</code> Format of indexed content
  155. - <code>text_model</code> Text documents are directly embedded; `economy` mode defaults to using this form
  156. - <code>hierarchical_model</code> Parent-child mode
  157. - <code>qa_model</code> Q&A Mode: Generates Q&A pairs for segmented documents and then embeds the questions
  158. - <code>doc_language</code> In Q&A mode, specify the language of the document, for example: <code>English</code>, <code>Chinese</code>
  159. - <code>process_rule</code> Processing rules
  160. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  161. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  162. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  163. - <code>id</code> (string) Unique identifier for the preprocessing rule
  164. - enumerate
  165. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  166. - <code>remove_urls_emails</code> Delete URL, email address
  167. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  168. - <code>segmentation</code> (object) Segmentation rules
  169. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  170. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  171. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  172. - <code>subchunk_segmentation</code> (object) Child chunk rules
  173. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  174. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  175. </Property>
  176. <Property name='file' type='multipart/form-data' key='file'>
  177. Files that need to be uploaded.
  178. </Property>
  179. </Properties>
  180. </Col>
  181. <Col sticky>
  182. <CodeGroup
  183. title="Request"
  184. tag="POST"
  185. label="/datasets/{dataset_id}/document/create-by-file"
  186. 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"'`}
  187. >
  188. ```bash {{ title: 'cURL' }}
  189. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
  190. --header 'Authorization: Bearer {api_key}' \
  191. --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' \
  192. --form 'file=@"/path/to/file"'
  193. ```
  194. </CodeGroup>
  195. <CodeGroup title="Response">
  196. ```json {{ title: 'Response' }}
  197. {
  198. "document": {
  199. "id": "",
  200. "position": 1,
  201. "data_source_type": "upload_file",
  202. "data_source_info": {
  203. "upload_file_id": ""
  204. },
  205. "dataset_process_rule_id": "",
  206. "name": "Dify.txt",
  207. "created_from": "api",
  208. "created_by": "",
  209. "created_at": 1695308667,
  210. "tokens": 0,
  211. "indexing_status": "waiting",
  212. "error": null,
  213. "enabled": true,
  214. "disabled_at": null,
  215. "disabled_by": null,
  216. "archived": false,
  217. "display_status": "queuing",
  218. "word_count": 0,
  219. "hit_count": 0,
  220. "doc_form": "text_model"
  221. },
  222. "batch": ""
  223. }
  224. ```
  225. </CodeGroup>
  226. </Col>
  227. </Row>
  228. <hr className='ml-0 mr-0' />
  229. <Heading
  230. url='/datasets'
  231. method='POST'
  232. title='Create an Empty Knowledge Base'
  233. name='#create_empty_dataset'
  234. />
  235. <Row>
  236. <Col>
  237. ### Request Body
  238. <Properties>
  239. <Property name='name' type='string' key='name'>
  240. Knowledge name
  241. </Property>
  242. <Property name='description' type='string' key='description'>
  243. Knowledge description (optional)
  244. </Property>
  245. <Property name='indexing_technique' type='string' key='indexing_technique'>
  246. Index technique (optional)
  247. - <code>high_quality</code> High quality
  248. - <code>economy</code> Economy
  249. </Property>
  250. <Property name='permission' type='string' key='permission'>
  251. Permission
  252. - <code>only_me</code> Only me
  253. - <code>all_team_members</code> All team members
  254. - <code>partial_members</code> Partial members
  255. </Property>
  256. <Property name='provider' type='string' key='provider'>
  257. Provider (optional, default: vendor)
  258. - <code>vendor</code> Vendor
  259. - <code>external</code> External knowledge
  260. </Property>
  261. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  262. External knowledge API ID (optional)
  263. </Property>
  264. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  265. External knowledge ID (optional)
  266. </Property>
  267. </Properties>
  268. </Col>
  269. <Col sticky>
  270. <CodeGroup
  271. title="Request"
  272. tag="POST"
  273. label="/datasets"
  274. 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"}'`}
  275. >
  276. ```bash {{ title: 'cURL' }}
  277. curl --location --request POST '${apiBaseUrl}/v1/datasets' \
  278. --header 'Authorization: Bearer {api_key}' \
  279. --header 'Content-Type: application/json' \
  280. --data-raw '{
  281. "name": "name",
  282. "permission": "only_me"
  283. }'
  284. ```
  285. </CodeGroup>
  286. <CodeGroup title="Response">
  287. ```json {{ title: 'Response' }}
  288. {
  289. "id": "",
  290. "name": "name",
  291. "description": null,
  292. "provider": "vendor",
  293. "permission": "only_me",
  294. "data_source_type": null,
  295. "indexing_technique": null,
  296. "app_count": 0,
  297. "document_count": 0,
  298. "word_count": 0,
  299. "created_by": "",
  300. "created_at": 1695636173,
  301. "updated_by": "",
  302. "updated_at": 1695636173,
  303. "embedding_model": null,
  304. "embedding_model_provider": null,
  305. "embedding_available": null
  306. }
  307. ```
  308. </CodeGroup>
  309. </Col>
  310. </Row>
  311. <hr className='ml-0 mr-0' />
  312. <Heading
  313. url='/datasets'
  314. method='GET'
  315. title='Get Knowledge Base List'
  316. name='#dataset_list'
  317. />
  318. <Row>
  319. <Col>
  320. ### Query
  321. <Properties>
  322. <Property name='page' type='string' key='page'>
  323. Page number
  324. </Property>
  325. <Property name='limit' type='string' key='limit'>
  326. Number of items returned, default 20, range 1-100
  327. </Property>
  328. </Properties>
  329. </Col>
  330. <Col sticky>
  331. <CodeGroup
  332. title="Request"
  333. tag="GET"
  334. label="/datasets"
  335. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  336. >
  337. ```bash {{ title: 'cURL' }}
  338. curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
  339. --header 'Authorization: Bearer {api_key}'
  340. ```
  341. </CodeGroup>
  342. <CodeGroup title="Response">
  343. ```json {{ title: 'Response' }}
  344. {
  345. "data": [
  346. {
  347. "id": "",
  348. "name": "name",
  349. "description": "desc",
  350. "permission": "only_me",
  351. "data_source_type": "upload_file",
  352. "indexing_technique": "",
  353. "app_count": 2,
  354. "document_count": 10,
  355. "word_count": 1200,
  356. "created_by": "",
  357. "created_at": "",
  358. "updated_by": "",
  359. "updated_at": ""
  360. },
  361. ...
  362. ],
  363. "has_more": true,
  364. "limit": 20,
  365. "total": 50,
  366. "page": 1
  367. }
  368. ```
  369. </CodeGroup>
  370. </Col>
  371. </Row>
  372. <hr className='ml-0 mr-0' />
  373. <Heading
  374. url='/datasets/{dataset_id}'
  375. method='DELETE'
  376. title='Delete a Knowledge Base'
  377. name='#delete_dataset'
  378. />
  379. <Row>
  380. <Col>
  381. ### Params
  382. <Properties>
  383. <Property name='dataset_id' type='string' key='dataset_id'>
  384. Knowledge ID
  385. </Property>
  386. </Properties>
  387. </Col>
  388. <Col sticky>
  389. <CodeGroup
  390. title="Request"
  391. tag="DELETE"
  392. label="/datasets/{dataset_id}"
  393. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  394. >
  395. ```bash {{ title: 'cURL' }}
  396. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
  397. --header 'Authorization: Bearer {api_key}'
  398. ```
  399. </CodeGroup>
  400. <CodeGroup title="Response">
  401. ```text {{ title: 'Response' }}
  402. 204 No Content
  403. ```
  404. </CodeGroup>
  405. </Col>
  406. </Row>
  407. <hr className='ml-0 mr-0' />
  408. <Heading
  409. url='/datasets/{dataset_id}/documents/{document_id}/update-by-text'
  410. method='POST'
  411. title='Update a Document with Text'
  412. name='#update-by-text'
  413. />
  414. <Row>
  415. <Col>
  416. This API is based on an existing knowledge and updates the document through text based on this knowledge.
  417. ### Params
  418. <Properties>
  419. <Property name='dataset_id' type='string' key='dataset_id'>
  420. Knowledge ID
  421. </Property>
  422. <Property name='document_id' type='string' key='document_id'>
  423. Document ID
  424. </Property>
  425. </Properties>
  426. ### Request Body
  427. <Properties>
  428. <Property name='name' type='string' key='name'>
  429. Document name (optional)
  430. </Property>
  431. <Property name='text' type='string' key='text'>
  432. Document content (optional)
  433. </Property>
  434. <Property name='process_rule' type='object' key='process_rule'>
  435. Processing rules
  436. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  437. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  438. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  439. - <code>id</code> (string) Unique identifier for the preprocessing rule
  440. - enumerate
  441. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  442. - <code>remove_urls_emails</code> Delete URL, email address
  443. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  444. - <code>segmentation</code> (object) Segmentation rules
  445. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  446. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  447. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  448. - <code>subchunk_segmentation</code> (object) Child chunk rules
  449. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  450. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  451. </Property>
  452. </Properties>
  453. </Col>
  454. <Col sticky>
  455. <CodeGroup
  456. title="Request"
  457. tag="POST"
  458. label="/datasets/{dataset_id}/documents/{document_id}/update-by-text"
  459. 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"}'`}
  460. >
  461. ```bash {{ title: 'cURL' }}
  462. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
  463. --header 'Authorization: Bearer {api_key}' \
  464. --header 'Content-Type: application/json' \
  465. --data-raw '{
  466. "name": "name",
  467. "text": "text"
  468. }'
  469. ```
  470. </CodeGroup>
  471. <CodeGroup title="Response">
  472. ```json {{ title: 'Response' }}
  473. {
  474. "document": {
  475. "id": "",
  476. "position": 1,
  477. "data_source_type": "upload_file",
  478. "data_source_info": {
  479. "upload_file_id": ""
  480. },
  481. "dataset_process_rule_id": "",
  482. "name": "name.txt",
  483. "created_from": "api",
  484. "created_by": "",
  485. "created_at": 1695308667,
  486. "tokens": 0,
  487. "indexing_status": "waiting",
  488. "error": null,
  489. "enabled": true,
  490. "disabled_at": null,
  491. "disabled_by": null,
  492. "archived": false,
  493. "display_status": "queuing",
  494. "word_count": 0,
  495. "hit_count": 0,
  496. "doc_form": "text_model"
  497. },
  498. "batch": ""
  499. }
  500. ```
  501. </CodeGroup>
  502. </Col>
  503. </Row>
  504. <hr className='ml-0 mr-0' />
  505. <Heading
  506. url='/datasets/{dataset_id}/documents/{document_id}/update-by-file'
  507. method='POST'
  508. title='Update a Document with a File'
  509. name='#update-by-file'
  510. />
  511. <Row>
  512. <Col>
  513. This API is based on an existing knowledge, and updates documents through files based on this knowledge
  514. ### Params
  515. <Properties>
  516. <Property name='dataset_id' type='string' key='dataset_id'>
  517. Knowledge ID
  518. </Property>
  519. <Property name='document_id' type='string' key='document_id'>
  520. Document ID
  521. </Property>
  522. </Properties>
  523. ### Request Body
  524. <Properties>
  525. <Property name='name' type='string' key='name'>
  526. Document name (optional)
  527. </Property>
  528. <Property name='file' type='multipart/form-data' key='file'>
  529. Files to be uploaded
  530. </Property>
  531. <Property name='process_rule' type='object' key='process_rule'>
  532. Processing rules
  533. - <code>mode</code> (string) Cleaning, segmentation mode, automatic / custom
  534. - <code>rules</code> (object) Custom rules (in automatic mode, this field is empty)
  535. - <code>pre_processing_rules</code> (array[object]) Preprocessing rules
  536. - <code>id</code> (string) Unique identifier for the preprocessing rule
  537. - enumerate
  538. - <code>remove_extra_spaces</code> Replace consecutive spaces, newlines, tabs
  539. - <code>remove_urls_emails</code> Delete URL, email address
  540. - <code>enabled</code> (bool) Whether to select this rule or not. If no document ID is passed in, it represents the default value.
  541. - <code>segmentation</code> (object) Segmentation rules
  542. - <code>separator</code> Custom segment identifier, currently only allows one delimiter to be set. Default is \n
  543. - <code>max_tokens</code> Maximum length (token) defaults to 1000
  544. - <code>parent_mode</code> Retrieval mode of parent chunks: <code>full-doc</code> full text retrieval / <code>paragraph</code> paragraph retrieval
  545. - <code>subchunk_segmentation</code> (object) Child chunk rules
  546. - <code>separator</code> Segmentation identifier. Currently, only one delimiter is allowed. The default is <code>***</code>
  547. - <code>max_tokens</code> The maximum length (tokens) must be validated to be shorter than the length of the parent chunk
  548. </Property>
  549. </Properties>
  550. </Col>
  551. <Col sticky>
  552. <CodeGroup
  553. title="Request"
  554. tag="POST"
  555. label="/datasets/{dataset_id}/documents/{document_id}/update-by-file"
  556. 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"'`}
  557. >
  558. ```bash {{ title: 'cURL' }}
  559. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
  560. --header 'Authorization: Bearer {api_key}' \
  561. --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' \
  562. --form 'file=@"/path/to/file"'
  563. ```
  564. </CodeGroup>
  565. <CodeGroup title="Response">
  566. ```json {{ title: 'Response' }}
  567. {
  568. "document": {
  569. "id": "",
  570. "position": 1,
  571. "data_source_type": "upload_file",
  572. "data_source_info": {
  573. "upload_file_id": ""
  574. },
  575. "dataset_process_rule_id": "",
  576. "name": "Dify.txt",
  577. "created_from": "api",
  578. "created_by": "",
  579. "created_at": 1695308667,
  580. "tokens": 0,
  581. "indexing_status": "waiting",
  582. "error": null,
  583. "enabled": true,
  584. "disabled_at": null,
  585. "disabled_by": null,
  586. "archived": false,
  587. "display_status": "queuing",
  588. "word_count": 0,
  589. "hit_count": 0,
  590. "doc_form": "text_model"
  591. },
  592. "batch": "20230921150427533684"
  593. }
  594. ```
  595. </CodeGroup>
  596. </Col>
  597. </Row>
  598. <hr className='ml-0 mr-0' />
  599. <Heading
  600. url='/datasets/{dataset_id}/documents/{batch}/indexing-status'
  601. method='GET'
  602. title='Get Document Embedding Status (Progress)'
  603. name='#indexing_status'
  604. />
  605. <Row>
  606. <Col>
  607. ### Params
  608. <Properties>
  609. <Property name='dataset_id' type='string' key='dataset_id'>
  610. Knowledge ID
  611. </Property>
  612. <Property name='batch' type='string' key='batch'>
  613. Batch number of uploaded documents
  614. </Property>
  615. </Properties>
  616. </Col>
  617. <Col sticky>
  618. <CodeGroup
  619. title="Request"
  620. tag="GET"
  621. label="/datasets/{dataset_id}/documents/{batch}/indexing-status"
  622. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \\\n--header 'Authorization: Bearer {api_key}'`}
  623. >
  624. ```bash {{ title: 'cURL' }}
  625. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
  626. --header 'Authorization: Bearer {api_key}' \
  627. ```
  628. </CodeGroup>
  629. <CodeGroup title="Response">
  630. ```json {{ title: 'Response' }}
  631. {
  632. "data":[{
  633. "id": "",
  634. "indexing_status": "indexing",
  635. "processing_started_at": 1681623462.0,
  636. "parsing_completed_at": 1681623462.0,
  637. "cleaning_completed_at": 1681623462.0,
  638. "splitting_completed_at": 1681623462.0,
  639. "completed_at": null,
  640. "paused_at": null,
  641. "error": null,
  642. "stopped_at": null,
  643. "completed_segments": 24,
  644. "total_segments": 100
  645. }]
  646. }
  647. ```
  648. </CodeGroup>
  649. </Col>
  650. </Row>
  651. <hr className='ml-0 mr-0' />
  652. <Heading
  653. url='/datasets/{dataset_id}/documents/{document_id}'
  654. method='DELETE'
  655. title='Delete a Document'
  656. name='#delete_document'
  657. />
  658. <Row>
  659. <Col>
  660. ### Params
  661. <Properties>
  662. <Property name='dataset_id' type='string' key='dataset_id'>
  663. Knowledge ID
  664. </Property>
  665. <Property name='document_id' type='string' key='document_id'>
  666. Document ID
  667. </Property>
  668. </Properties>
  669. </Col>
  670. <Col sticky>
  671. <CodeGroup
  672. title="Request"
  673. tag="DELETE"
  674. label="/datasets/{dataset_id}/documents/{document_id}"
  675. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  676. >
  677. ```bash {{ title: 'cURL' }}
  678. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
  679. --header 'Authorization: Bearer {api_key}' \
  680. ```
  681. </CodeGroup>
  682. <CodeGroup title="Response">
  683. ```json {{ title: 'Response' }}
  684. {
  685. "result": "success"
  686. }
  687. ```
  688. </CodeGroup>
  689. </Col>
  690. </Row>
  691. <hr className='ml-0 mr-0' />
  692. <Heading
  693. url='/datasets/{dataset_id}/documents'
  694. method='GET'
  695. title='Get the Document List of a Knowledge Base'
  696. name='#dataset_document_list'
  697. />
  698. <Row>
  699. <Col>
  700. ### Params
  701. <Properties>
  702. <Property name='dataset_id' type='string' key='dataset_id'>
  703. Knowledge ID
  704. </Property>
  705. </Properties>
  706. ### Query
  707. <Properties>
  708. <Property name='keyword' type='string' key='keyword'>
  709. Search keywords, currently only search document names (optional)
  710. </Property>
  711. <Property name='page' type='string' key='page'>
  712. Page number (optional)
  713. </Property>
  714. <Property name='limit' type='string' key='limit'>
  715. Number of items returned, default 20, range 1-100 (optional)
  716. </Property>
  717. </Properties>
  718. </Col>
  719. <Col sticky>
  720. <CodeGroup
  721. title="Request"
  722. tag="GET"
  723. label="/datasets/{dataset_id}/documents"
  724. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \\\n--header 'Authorization: Bearer {api_key}'`}
  725. >
  726. ```bash {{ title: 'cURL' }}
  727. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
  728. --header 'Authorization: Bearer {api_key}' \
  729. ```
  730. </CodeGroup>
  731. <CodeGroup title="Response">
  732. ```json {{ title: 'Response' }}
  733. {
  734. "data": [
  735. {
  736. "id": "",
  737. "position": 1,
  738. "data_source_type": "file_upload",
  739. "data_source_info": null,
  740. "dataset_process_rule_id": null,
  741. "name": "dify",
  742. "created_from": "",
  743. "created_by": "",
  744. "created_at": 1681623639,
  745. "tokens": 0,
  746. "indexing_status": "waiting",
  747. "error": null,
  748. "enabled": true,
  749. "disabled_at": null,
  750. "disabled_by": null,
  751. "archived": false
  752. },
  753. ],
  754. "has_more": false,
  755. "limit": 20,
  756. "total": 9,
  757. "page": 1
  758. }
  759. ```
  760. </CodeGroup>
  761. </Col>
  762. </Row>
  763. <hr className='ml-0 mr-0' />
  764. <Heading
  765. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  766. method='POST'
  767. title='Add Chunks to a Document'
  768. name='#create_new_segment'
  769. />
  770. <Row>
  771. <Col>
  772. ### Params
  773. <Properties>
  774. <Property name='dataset_id' type='string' key='dataset_id'>
  775. Knowledge ID
  776. </Property>
  777. <Property name='document_id' type='string' key='document_id'>
  778. Document ID
  779. </Property>
  780. </Properties>
  781. ### Request Body
  782. <Properties>
  783. <Property name='segments' type='object list' key='segments'>
  784. - <code>content</code> (text) Text content / question content, required
  785. - <code>answer</code> (text) Answer content, if the mode of the knowledge is Q&A mode, pass the value (optional)
  786. - <code>keywords</code> (list) Keywords (optional)
  787. </Property>
  788. </Properties>
  789. </Col>
  790. <Col sticky>
  791. <CodeGroup
  792. title="Request"
  793. tag="POST"
  794. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  795. 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"]}]}'`}
  796. >
  797. ```bash {{ title: 'cURL' }}
  798. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  799. --header 'Authorization: Bearer {api_key}' \
  800. --header 'Content-Type: application/json' \
  801. --data-raw '{
  802. "segments": [
  803. {
  804. "content": "1",
  805. "answer": "1",
  806. "keywords": ["a"]
  807. }
  808. ]
  809. }'
  810. ```
  811. </CodeGroup>
  812. <CodeGroup title="Response">
  813. ```json {{ title: 'Response' }}
  814. {
  815. "data": [{
  816. "id": "",
  817. "position": 1,
  818. "document_id": "",
  819. "content": "1",
  820. "answer": "1",
  821. "word_count": 25,
  822. "tokens": 0,
  823. "keywords": [
  824. "a"
  825. ],
  826. "index_node_id": "",
  827. "index_node_hash": "",
  828. "hit_count": 0,
  829. "enabled": true,
  830. "disabled_at": null,
  831. "disabled_by": null,
  832. "status": "completed",
  833. "created_by": "",
  834. "created_at": 1695312007,
  835. "indexing_at": 1695312007,
  836. "completed_at": 1695312007,
  837. "error": null,
  838. "stopped_at": null
  839. }],
  840. "doc_form": "text_model"
  841. }
  842. ```
  843. </CodeGroup>
  844. </Col>
  845. </Row>
  846. <hr className='ml-0 mr-0' />
  847. <Heading
  848. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  849. method='GET'
  850. title='Get Chunks from a Document'
  851. name='#get_segment'
  852. />
  853. <Row>
  854. <Col>
  855. ### Path
  856. <Properties>
  857. <Property name='dataset_id' type='string' key='dataset_id'>
  858. Knowledge ID
  859. </Property>
  860. <Property name='document_id' type='string' key='document_id'>
  861. Document ID
  862. </Property>
  863. </Properties>
  864. ### Query
  865. <Properties>
  866. <Property name='keyword' type='string' key='keyword'>
  867. Keyword (optional)
  868. </Property>
  869. <Property name='status' type='string' key='status'>
  870. Search status, completed
  871. </Property>
  872. </Properties>
  873. </Col>
  874. <Col sticky>
  875. <CodeGroup
  876. title="Request"
  877. tag="GET"
  878. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  879. 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'`}
  880. >
  881. ```bash {{ title: 'cURL' }}
  882. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  883. --header 'Authorization: Bearer {api_key}' \
  884. --header 'Content-Type: application/json'
  885. ```
  886. </CodeGroup>
  887. <CodeGroup title="Response">
  888. ```json {{ title: 'Response' }}
  889. {
  890. "data": [{
  891. "id": "",
  892. "position": 1,
  893. "document_id": "",
  894. "content": "1",
  895. "answer": "1",
  896. "word_count": 25,
  897. "tokens": 0,
  898. "keywords": [
  899. "a"
  900. ],
  901. "index_node_id": "",
  902. "index_node_hash": "",
  903. "hit_count": 0,
  904. "enabled": true,
  905. "disabled_at": null,
  906. "disabled_by": null,
  907. "status": "completed",
  908. "created_by": "",
  909. "created_at": 1695312007,
  910. "indexing_at": 1695312007,
  911. "completed_at": 1695312007,
  912. "error": null,
  913. "stopped_at": null
  914. }],
  915. "doc_form": "text_model"
  916. }
  917. ```
  918. </CodeGroup>
  919. </Col>
  920. </Row>
  921. <hr className='ml-0 mr-0' />
  922. <Heading
  923. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  924. method='DELETE'
  925. title='Delete a Chunk in a Document'
  926. name='#delete_segment'
  927. />
  928. <Row>
  929. <Col>
  930. ### Path
  931. <Properties>
  932. <Property name='dataset_id' type='string' key='dataset_id'>
  933. Knowledge ID
  934. </Property>
  935. <Property name='document_id' type='string' key='document_id'>
  936. Document ID
  937. </Property>
  938. <Property name='segment_id' type='string' key='segment_id'>
  939. Document Segment ID
  940. </Property>
  941. </Properties>
  942. </Col>
  943. <Col sticky>
  944. <CodeGroup
  945. title="Request"
  946. tag="DELETE"
  947. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  948. 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'`}
  949. >
  950. ```bash {{ title: 'cURL' }}
  951. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \
  952. --header 'Authorization: Bearer {api_key}' \
  953. --header 'Content-Type: application/json'
  954. ```
  955. </CodeGroup>
  956. <CodeGroup title="Response">
  957. ```json {{ title: 'Response' }}
  958. {
  959. "result": "success"
  960. }
  961. ```
  962. </CodeGroup>
  963. </Col>
  964. </Row>
  965. <hr className='ml-0 mr-0' />
  966. <Heading
  967. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  968. method='POST'
  969. title='Update a Chunk in a Document'
  970. name='#update_segment'
  971. />
  972. <Row>
  973. <Col>
  974. ### POST
  975. <Properties>
  976. <Property name='dataset_id' type='string' key='dataset_id'>
  977. Knowledge ID
  978. </Property>
  979. <Property name='document_id' type='string' key='document_id'>
  980. Document ID
  981. </Property>
  982. <Property name='segment_id' type='string' key='segment_id'>
  983. Document Segment ID
  984. </Property>
  985. </Properties>
  986. ### Request Body
  987. <Properties>
  988. <Property name='segment' type='object' key='segment'>
  989. - <code>content</code> (text) Text content / question content, required
  990. - <code>answer</code> (text) Answer content, passed if the knowledge is in Q&A mode (optional)
  991. - <code>keywords</code> (list) Keyword (optional)
  992. - <code>enabled</code> (bool) False / true (optional)
  993. - <code>regenerate_child_chunks</code> (bool) Whether to regenerate child chunks (optional)
  994. </Property>
  995. </Properties>
  996. </Col>
  997. <Col sticky>
  998. <CodeGroup
  999. title="Request"
  1000. tag="POST"
  1001. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1002. 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}}'`}
  1003. >
  1004. ```bash {{ title: 'cURL' }}
  1005. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1006. --header 'Content-Type: application/json' \
  1007. --data-raw '{
  1008. "segment": {
  1009. "content": "1",
  1010. "answer": "1",
  1011. "keywords": ["a"],
  1012. "enabled": false
  1013. }
  1014. }'
  1015. ```
  1016. </CodeGroup>
  1017. <CodeGroup title="Response">
  1018. ```json {{ title: 'Response' }}
  1019. {
  1020. "data": [{
  1021. "id": "",
  1022. "position": 1,
  1023. "document_id": "",
  1024. "content": "1",
  1025. "answer": "1",
  1026. "word_count": 25,
  1027. "tokens": 0,
  1028. "keywords": [
  1029. "a"
  1030. ],
  1031. "index_node_id": "",
  1032. "index_node_hash": "",
  1033. "hit_count": 0,
  1034. "enabled": true,
  1035. "disabled_at": null,
  1036. "disabled_by": null,
  1037. "status": "completed",
  1038. "created_by": "",
  1039. "created_at": 1695312007,
  1040. "indexing_at": 1695312007,
  1041. "completed_at": 1695312007,
  1042. "error": null,
  1043. "stopped_at": null
  1044. }],
  1045. "doc_form": "text_model"
  1046. }
  1047. ```
  1048. </CodeGroup>
  1049. </Col>
  1050. </Row>
  1051. <hr className='ml-0 mr-0' />
  1052. <Heading
  1053. url='/datasets/{dataset_id}/retrieve'
  1054. method='POST'
  1055. title='Retrieve Chunks from a Knowledge Base'
  1056. name='#dataset_retrieval'
  1057. />
  1058. <Row>
  1059. <Col>
  1060. ### Path
  1061. <Properties>
  1062. <Property name='dataset_id' type='string' key='dataset_id'>
  1063. Knowledge ID
  1064. </Property>
  1065. </Properties>
  1066. ### Request Body
  1067. <Properties>
  1068. <Property name='query' type='string' key='query'>
  1069. Query keyword
  1070. </Property>
  1071. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1072. Retrieval model (optional, if not filled, it will be recalled according to the default method)
  1073. - <code>search_method</code> (text) Search method: One of the following four keywords is required
  1074. - <code>keyword_search</code> Keyword search
  1075. - <code>semantic_search</code> Semantic search
  1076. - <code>full_text_search</code> Full-text search
  1077. - <code>hybrid_search</code> Hybrid search
  1078. - <code>reranking_enable</code> (bool) Whether to enable reranking, required if the search mode is semantic_search or hybrid_search (optional)
  1079. - <code>reranking_mode</code> (object) Rerank model configuration, required if reranking is enabled
  1080. - <code>reranking_provider_name</code> (string) Rerank model provider
  1081. - <code>reranking_model_name</code> (string) Rerank model name
  1082. - <code>weights</code> (double) Semantic search weight setting in hybrid search mode
  1083. - <code>top_k</code> (integer) Number of results to return (optional)
  1084. - <code>score_threshold_enabled</code> (bool) Whether to enable score threshold
  1085. - <code>score_threshold</code> (double) Score threshold
  1086. </Property>
  1087. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1088. Unused field
  1089. </Property>
  1090. </Properties>
  1091. </Col>
  1092. <Col sticky>
  1093. <CodeGroup
  1094. title="Request"
  1095. tag="POST"
  1096. label="/datasets/{dataset_id}/retrieve"
  1097. 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 '{
  1098. "query": "test",
  1099. "retrieval_model": {
  1100. "search_method": "keyword_search",
  1101. "reranking_enable": false,
  1102. "reranking_mode": null,
  1103. "reranking_model": {
  1104. "reranking_provider_name": "",
  1105. "reranking_model_name": ""
  1106. },
  1107. "weights": null,
  1108. "top_k": 1,
  1109. "score_threshold_enabled": false,
  1110. "score_threshold": null
  1111. }
  1112. }'`}
  1113. >
  1114. ```bash {{ title: 'cURL' }}
  1115. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1116. --header 'Authorization: Bearer {api_key}' \
  1117. --header 'Content-Type: application/json' \
  1118. --data-raw '{
  1119. "query": "test",
  1120. "retrieval_model": {
  1121. "search_method": "keyword_search",
  1122. "reranking_enable": false,
  1123. "reranking_mode": null,
  1124. "reranking_model": {
  1125. "reranking_provider_name": "",
  1126. "reranking_model_name": ""
  1127. },
  1128. "weights": null,
  1129. "top_k": 2,
  1130. "score_threshold_enabled": false,
  1131. "score_threshold": null
  1132. }
  1133. }'
  1134. ```
  1135. </CodeGroup>
  1136. <CodeGroup title="Response">
  1137. ```json {{ title: 'Response' }}
  1138. {
  1139. "query": {
  1140. "content": "test"
  1141. },
  1142. "records": [
  1143. {
  1144. "segment": {
  1145. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1146. "position": 1,
  1147. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1148. "content": "Operation guide",
  1149. "answer": null,
  1150. "word_count": 847,
  1151. "tokens": 280,
  1152. "keywords": [
  1153. "install",
  1154. "java",
  1155. "base",
  1156. "scripts",
  1157. "jdk",
  1158. "manual",
  1159. "internal",
  1160. "opens",
  1161. "add",
  1162. "vmoptions"
  1163. ],
  1164. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1165. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1166. "hit_count": 0,
  1167. "enabled": true,
  1168. "disabled_at": null,
  1169. "disabled_by": null,
  1170. "status": "completed",
  1171. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1172. "created_at": 1728734540,
  1173. "indexing_at": 1728734552,
  1174. "completed_at": 1728734584,
  1175. "error": null,
  1176. "stopped_at": null,
  1177. "document": {
  1178. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1179. "data_source_type": "upload_file",
  1180. "name": "readme.txt",
  1181. "doc_type": null
  1182. }
  1183. },
  1184. "score": 3.730463140527718e-05,
  1185. "tsne_position": null
  1186. }
  1187. ]
  1188. }
  1189. ```
  1190. </CodeGroup>
  1191. </Col>
  1192. </Row>
  1193. <hr className='ml-0 mr-0' />
  1194. <Row>
  1195. <Col>
  1196. ### Error message
  1197. <Properties>
  1198. <Property name='code' type='string' key='code'>
  1199. Error code
  1200. </Property>
  1201. </Properties>
  1202. <Properties>
  1203. <Property name='status' type='number' key='status'>
  1204. Error status
  1205. </Property>
  1206. </Properties>
  1207. <Properties>
  1208. <Property name='message' type='string' key='message'>
  1209. Error message
  1210. </Property>
  1211. </Properties>
  1212. </Col>
  1213. <Col>
  1214. <CodeGroup title="Example">
  1215. ```json {{ title: 'Response' }}
  1216. {
  1217. "code": "no_file_uploaded",
  1218. "message": "Please upload your file.",
  1219. "status": 400
  1220. }
  1221. ```
  1222. </CodeGroup>
  1223. </Col>
  1224. </Row>
  1225. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  1226. <thead style={{ background: '#f9fafc' }}>
  1227. <tr>
  1228. <th className="p-2 border border-slate-300">code</th>
  1229. <th className="p-2 border border-slate-300">status</th>
  1230. <th className="p-2 border border-slate-300">message</th>
  1231. </tr>
  1232. </thead>
  1233. <tbody>
  1234. <tr>
  1235. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  1236. <td className="p-2 border border-slate-300">400</td>
  1237. <td className="p-2 border border-slate-300">Please upload your file.</td>
  1238. </tr>
  1239. <tr>
  1240. <td className="p-2 border border-slate-300">too_many_files</td>
  1241. <td className="p-2 border border-slate-300">400</td>
  1242. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  1243. </tr>
  1244. <tr>
  1245. <td className="p-2 border border-slate-300">file_too_large</td>
  1246. <td className="p-2 border border-slate-300">413</td>
  1247. <td className="p-2 border border-slate-300">File size exceeded.</td>
  1248. </tr>
  1249. <tr>
  1250. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  1251. <td className="p-2 border border-slate-300">415</td>
  1252. <td className="p-2 border border-slate-300">File type not allowed.</td>
  1253. </tr>
  1254. <tr>
  1255. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  1256. <td className="p-2 border border-slate-300">400</td>
  1257. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  1258. </tr>
  1259. <tr>
  1260. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  1261. <td className="p-2 border border-slate-300">400</td>
  1262. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  1263. </tr>
  1264. <tr>
  1265. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  1266. <td className="p-2 border border-slate-300">403</td>
  1267. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  1268. </tr>
  1269. <tr>
  1270. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  1271. <td className="p-2 border border-slate-300">409</td>
  1272. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  1273. </tr>
  1274. <tr>
  1275. <td className="p-2 border border-slate-300">invalid_action</td>
  1276. <td className="p-2 border border-slate-300">400</td>
  1277. <td className="p-2 border border-slate-300">Invalid action.</td>
  1278. </tr>
  1279. <tr>
  1280. <td className="p-2 border border-slate-300">document_already_finished</td>
  1281. <td className="p-2 border border-slate-300">400</td>
  1282. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  1283. </tr>
  1284. <tr>
  1285. <td className="p-2 border border-slate-300">document_indexing</td>
  1286. <td className="p-2 border border-slate-300">400</td>
  1287. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  1288. </tr>
  1289. <tr>
  1290. <td className="p-2 border border-slate-300">invalid_metadata</td>
  1291. <td className="p-2 border border-slate-300">400</td>
  1292. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  1293. </tr>
  1294. </tbody>
  1295. </table>
  1296. <div className="pb-4" />