template.en.mdx 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  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" />