template.zh.mdx 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  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. # 知识库 API
  4. <div>
  5. ### 鉴权
  6. Dify Service API 使用 `API-Key` 进行鉴权。
  7. 建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。
  8. 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:
  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='通过文本创建文档'
  20. name='#create-by-text'
  21. />
  22. <Row>
  23. <Col>
  24. 此接口基于已存在知识库,在此知识库的基础上通过文本创建新的文档
  25. ### Path
  26. <Properties>
  27. <Property name='dataset_id' type='string' key='dataset_id'>
  28. 知识库 ID
  29. </Property>
  30. </Properties>
  31. ### Request Body
  32. <Properties>
  33. <Property name='name' type='string' key='name'>
  34. 文档名称
  35. </Property>
  36. <Property name='text' type='string' key='text'>
  37. 文档内容
  38. </Property>
  39. <Property name='indexing_technique' type='string' key='indexing_technique'>
  40. 索引方式
  41. - <code>high_quality</code> 高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
  42. - <code>economy</code> 经济:使用 keyword table index 的倒排索引进行构建
  43. </Property>
  44. <Property name='process_rule' type='object' key='process_rule'>
  45. 处理规则
  46. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  47. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  48. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  49. - <code>id</code> (string) 预处理规则的唯一标识符
  50. - 枚举:
  51. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  52. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  53. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  54. - <code>segmentation</code> (object) 分段规则
  55. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  56. - <code>max_tokens</code> 最大长度(token)默认为 1000
  57. </Property>
  58. </Properties>
  59. </Col>
  60. <Col sticky>
  61. <CodeGroup
  62. title="Request"
  63. tag="POST"
  64. label="/datasets/{dataset_id}/document/create-by-text"
  65. 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"}}'`}
  66. >
  67. ```bash {{ title: 'cURL' }}
  68. curl --location --request --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
  69. --header 'Authorization: Bearer {api_key}' \
  70. --header 'Content-Type: application/json' \
  71. --data-raw '{
  72. "name": "text",
  73. "text": "text",
  74. "indexing_technique": "high_quality",
  75. "process_rule": {
  76. "mode": "automatic"
  77. }
  78. }'
  79. ```
  80. </CodeGroup>
  81. <CodeGroup title="Response">
  82. ```json {{ title: 'Response' }}
  83. {
  84. "document": {
  85. "id": "",
  86. "position": 1,
  87. "data_source_type": "upload_file",
  88. "data_source_info": {
  89. "upload_file_id": ""
  90. },
  91. "dataset_process_rule_id": "",
  92. "name": "text.txt",
  93. "created_from": "api",
  94. "created_by": "",
  95. "created_at": 1695690280,
  96. "tokens": 0,
  97. "indexing_status": "waiting",
  98. "error": null,
  99. "enabled": true,
  100. "disabled_at": null,
  101. "disabled_by": null,
  102. "archived": false,
  103. "display_status": "queuing",
  104. "word_count": 0,
  105. "hit_count": 0,
  106. "doc_form": "text_model"
  107. },
  108. "batch": ""
  109. }
  110. ```
  111. </CodeGroup>
  112. </Col>
  113. </Row>
  114. <hr className='ml-0 mr-0' />
  115. <Heading
  116. url='/datasets/{dataset_id}/document/create-by-file'
  117. method='POST'
  118. title='通过文件创建文档 '
  119. name='#create-by-file'
  120. />
  121. <Row>
  122. <Col>
  123. 此接口基于已存在知识库,在此知识库的基础上通过文件创建新的文档
  124. ### Path
  125. <Properties>
  126. <Property name='dataset_id' type='string' key='dataset_id'>
  127. 知识库 ID
  128. </Property>
  129. </Properties>
  130. ### Request Body
  131. <Properties>
  132. <Property name='data' type='multipart/form-data json string' key='data'>
  133. - <code>original_document_id</code> 源文档 ID(选填)
  134. - 用于重新上传文档或修改文档清洗、分段配置,缺失的信息从源文档复制
  135. - 源文档不可为归档的文档
  136. - 当传入 <code>original_document_id</code> 时,代表文档进行更新操作,<code>process_rule</code> 为可填项目,不填默认使用源文档的分段方式
  137. - 未传入 <code>original_document_id</code> 时,代表文档进行新增操作,<code>process_rule</code> 为必填
  138. - <code>indexing_technique</code> 索引方式
  139. - <code>high_quality</code> 高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
  140. - <code>economy</code> 经济:使用 keyword table index 的倒排索引进行构建
  141. - <code>process_rule</code> 处理规则
  142. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  143. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  144. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  145. - <code>id</code> (string) 预处理规则的唯一标识符
  146. - 枚举:
  147. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  148. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  149. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  150. - <code>segmentation</code> (object) 分段规则
  151. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  152. - <code>max_tokens</code> 最大长度(token)默认为 1000
  153. </Property>
  154. <Property name='file' type='multipart/form-data' key='file'>
  155. 需要上传的文件。
  156. </Property>
  157. </Properties>
  158. </Col>
  159. <Col sticky>
  160. <CodeGroup
  161. title="Request"
  162. tag="POST"
  163. label="/datasets/{dataset_id}/document/create-by-file"
  164. 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"'`}
  165. >
  166. ```bash {{ title: 'cURL' }}
  167. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
  168. --header 'Authorization: Bearer {api_key}' \
  169. --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' \
  170. --form 'file=@"/path/to/file"'
  171. ```
  172. </CodeGroup>
  173. <CodeGroup title="Response">
  174. ```json {{ title: 'Response' }}
  175. {
  176. "document": {
  177. "id": "",
  178. "position": 1,
  179. "data_source_type": "upload_file",
  180. "data_source_info": {
  181. "upload_file_id": ""
  182. },
  183. "dataset_process_rule_id": "",
  184. "name": "Dify.txt",
  185. "created_from": "api",
  186. "created_by": "",
  187. "created_at": 1695308667,
  188. "tokens": 0,
  189. "indexing_status": "waiting",
  190. "error": null,
  191. "enabled": true,
  192. "disabled_at": null,
  193. "disabled_by": null,
  194. "archived": false,
  195. "display_status": "queuing",
  196. "word_count": 0,
  197. "hit_count": 0,
  198. "doc_form": "text_model"
  199. },
  200. "batch": ""
  201. }
  202. ```
  203. </CodeGroup>
  204. </Col>
  205. </Row>
  206. <hr className='ml-0 mr-0' />
  207. <Heading
  208. url='/datasets'
  209. method='POST'
  210. title='创建空知识库'
  211. name='#create_empty_dataset'
  212. />
  213. <Row>
  214. <Col>
  215. ### Request Body
  216. <Properties>
  217. <Property name='name' type='string' key='name'>
  218. 知识库名称(必填)
  219. </Property>
  220. <Property name='description' type='string' key='description'>
  221. 知识库描述(选填)
  222. </Property>
  223. <Property name='indexing_technique' type='string' key='indexing_technique'>
  224. 索引模式(选填,建议填写)
  225. - <code>high_quality</code> 高质量
  226. - <code>economy</code> 经济
  227. </Property>
  228. <Property name='permission' type='string' key='permission'>
  229. 权限(选填,默认 only_me)
  230. - <code>only_me</code> 仅自己
  231. - <code>all_team_members</code> 所有团队成员
  232. - <code>partial_members</code> 部分团队成员
  233. </Property>
  234. <Property name='provider' type='string' key='provider'>
  235. Provider(选填,默认 vendor)
  236. - <code>vendor</code> 上传文件
  237. - <code>external</code> 外部知识库
  238. </Property>
  239. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  240. 外部知识库 API_ID(选填)
  241. </Property>
  242. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  243. 外部知识库 ID(选填)
  244. </Property>
  245. </Properties>
  246. </Col>
  247. <Col sticky>
  248. <CodeGroup
  249. title="Request"
  250. tag="POST"
  251. label="/datasets"
  252. 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"}'`}
  253. >
  254. ```bash {{ title: 'cURL' }}
  255. curl --location --request POST '${props.apiBaseUrl}/datasets' \
  256. --header 'Authorization: Bearer {api_key}' \
  257. --header 'Content-Type: application/json' \
  258. --data-raw '{
  259. "name": "name",
  260. "permission": "only_me"
  261. }'
  262. ```
  263. </CodeGroup>
  264. <CodeGroup title="Response">
  265. ```json {{ title: 'Response' }}
  266. {
  267. "id": "",
  268. "name": "name",
  269. "description": null,
  270. "provider": "vendor",
  271. "permission": "only_me",
  272. "data_source_type": null,
  273. "indexing_technique": null,
  274. "app_count": 0,
  275. "document_count": 0,
  276. "word_count": 0,
  277. "created_by": "",
  278. "created_at": 1695636173,
  279. "updated_by": "",
  280. "updated_at": 1695636173,
  281. "embedding_model": null,
  282. "embedding_model_provider": null,
  283. "embedding_available": null
  284. }
  285. ```
  286. </CodeGroup>
  287. </Col>
  288. </Row>
  289. <hr className='ml-0 mr-0' />
  290. <Heading
  291. url='/datasets'
  292. method='GET'
  293. title='知识库列表'
  294. name='#dataset_list'
  295. />
  296. <Row>
  297. <Col>
  298. ### Query
  299. <Properties>
  300. <Property name='page' type='string' key='page'>
  301. 页码
  302. </Property>
  303. <Property name='limit' type='string' key='limit'>
  304. 返回条数,默认 20,范围 1-100
  305. </Property>
  306. </Properties>
  307. </Col>
  308. <Col sticky>
  309. <CodeGroup
  310. title="Request"
  311. tag="GET"
  312. label="/datasets"
  313. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  314. >
  315. ```bash {{ title: 'cURL' }}
  316. curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
  317. --header 'Authorization: Bearer {api_key}'
  318. ```
  319. </CodeGroup>
  320. <CodeGroup title="Response">
  321. ```json {{ title: 'Response' }}
  322. {
  323. "data": [
  324. {
  325. "id": "",
  326. "name": "知识库名称",
  327. "description": "描述信息",
  328. "permission": "only_me",
  329. "data_source_type": "upload_file",
  330. "indexing_technique": "",
  331. "app_count": 2,
  332. "document_count": 10,
  333. "word_count": 1200,
  334. "created_by": "",
  335. "created_at": "",
  336. "updated_by": "",
  337. "updated_at": ""
  338. },
  339. ...
  340. ],
  341. "has_more": true,
  342. "limit": 20,
  343. "total": 50,
  344. "page": 1
  345. }
  346. ```
  347. </CodeGroup>
  348. </Col>
  349. </Row>
  350. <hr className='ml-0 mr-0' />
  351. <Heading
  352. url='/datasets/{dataset_id}'
  353. method='DELETE'
  354. title='删除知识库'
  355. name='#delete_dataset'
  356. />
  357. <Row>
  358. <Col>
  359. ### Path
  360. <Properties>
  361. <Property name='dataset_id' type='string' key='dataset_id'>
  362. 知识库 ID
  363. </Property>
  364. </Properties>
  365. </Col>
  366. <Col sticky>
  367. <CodeGroup
  368. title="Request"
  369. tag="DELETE"
  370. label="/datasets/{dataset_id}"
  371. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  372. >
  373. ```bash {{ title: 'cURL' }}
  374. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
  375. --header 'Authorization: Bearer {api_key}'
  376. ```
  377. </CodeGroup>
  378. <CodeGroup title="Response">
  379. ```text {{ title: 'Response' }}
  380. 204 No Content
  381. ```
  382. </CodeGroup>
  383. </Col>
  384. </Row>
  385. <hr className='ml-0 mr-0' />
  386. <Heading
  387. url='/datasets/{dataset_id}/documents/{document_id}/update-by-text'
  388. method='POST'
  389. title='通过文本更新文档 '
  390. name='#update-by-text'
  391. />
  392. <Row>
  393. <Col>
  394. 此接口基于已存在知识库,在此知识库的基础上通过文本更新文档
  395. ### Path
  396. <Properties>
  397. <Property name='dataset_id' type='string' key='dataset_id'>
  398. 知识库 ID
  399. </Property>
  400. <Property name='document_id' type='string' key='document_id'>
  401. 文档 ID
  402. </Property>
  403. </Properties>
  404. ### Request Body
  405. <Properties>
  406. <Property name='name' type='string' key='name'>
  407. 文档名称(选填)
  408. </Property>
  409. <Property name='text' type='string' key='text'>
  410. 文档内容(选填)
  411. </Property>
  412. <Property name='process_rule' type='object' key='process_rule'>
  413. 处理规则(选填)
  414. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  415. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  416. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  417. - <code>id</code> (string) 预处理规则的唯一标识符
  418. - 枚举:
  419. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  420. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  421. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  422. - <code>segmentation</code> (object) 分段规则
  423. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  424. - <code>max_tokens</code> 最大长度(token)默认为 1000
  425. </Property>
  426. </Properties>
  427. </Col>
  428. <Col sticky>
  429. <CodeGroup
  430. title="Request"
  431. tag="POST"
  432. label="/datasets/{dataset_id}/documents/{document_id}/update-by-text"
  433. 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"}'`}
  434. >
  435. ```bash {{ title: 'cURL' }}
  436. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
  437. --header 'Authorization: Bearer {api_key}' \
  438. --header 'Content-Type: application/json' \
  439. --data-raw '{
  440. "name": "name",
  441. "text": "text"
  442. }'
  443. ```
  444. </CodeGroup>
  445. <CodeGroup title="Response">
  446. ```json {{ title: 'Response' }}
  447. {
  448. "document": {
  449. "id": "",
  450. "position": 1,
  451. "data_source_type": "upload_file",
  452. "data_source_info": {
  453. "upload_file_id": ""
  454. },
  455. "dataset_process_rule_id": "",
  456. "name": "name.txt",
  457. "created_from": "api",
  458. "created_by": "",
  459. "created_at": 1695308667,
  460. "tokens": 0,
  461. "indexing_status": "waiting",
  462. "error": null,
  463. "enabled": true,
  464. "disabled_at": null,
  465. "disabled_by": null,
  466. "archived": false,
  467. "display_status": "queuing",
  468. "word_count": 0,
  469. "hit_count": 0,
  470. "doc_form": "text_model"
  471. },
  472. "batch": ""
  473. }
  474. ```
  475. </CodeGroup>
  476. </Col>
  477. </Row>
  478. <hr className='ml-0 mr-0' />
  479. <Heading
  480. url='/datasets/{dataset_id}/documents/{document_id}/update-by-file'
  481. method='POST'
  482. title='通过文件更新文档 '
  483. name='#update-by-file'
  484. />
  485. <Row>
  486. <Col>
  487. 此接口基于已存在知识库,在此知识库的基础上通过文件更新文档的操作。
  488. ### Path
  489. <Properties>
  490. <Property name='dataset_id' type='string' key='dataset_id'>
  491. 知识库 ID
  492. </Property>
  493. <Property name='document_id' type='string' key='document_id'>
  494. 文档 ID
  495. </Property>
  496. </Properties>
  497. ### Request Body
  498. <Properties>
  499. <Property name='name' type='string' key='name'>
  500. 文档名称(选填)
  501. </Property>
  502. <Property name='file' type='multipart/form-data' key='file'>
  503. 需要上传的文件
  504. </Property>
  505. <Property name='process_rule' type='object' key='process_rule'>
  506. 处理规则(选填)
  507. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  508. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  509. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  510. - <code>id</code> (string) 预处理规则的唯一标识符
  511. - 枚举:
  512. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  513. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  514. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  515. - <code>segmentation</code> (object) 分段规则
  516. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  517. - <code>max_tokens</code> 最大长度(token)默认为 1000
  518. </Property>
  519. </Properties>
  520. </Col>
  521. <Col sticky>
  522. <CodeGroup
  523. title="Request"
  524. tag="POST"
  525. label="/datasets/{dataset_id}/documents/{document_id}/update-by-file"
  526. 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"'`}
  527. >
  528. ```bash {{ title: 'cURL' }}
  529. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
  530. --header 'Authorization: Bearer {api_key}' \
  531. --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' \
  532. --form 'file=@"/path/to/file"'
  533. ```
  534. </CodeGroup>
  535. <CodeGroup title="Response">
  536. ```json {{ title: 'Response' }}
  537. {
  538. "document": {
  539. "id": "",
  540. "position": 1,
  541. "data_source_type": "upload_file",
  542. "data_source_info": {
  543. "upload_file_id": ""
  544. },
  545. "dataset_process_rule_id": "",
  546. "name": "Dify.txt",
  547. "created_from": "api",
  548. "created_by": "",
  549. "created_at": 1695308667,
  550. "tokens": 0,
  551. "indexing_status": "waiting",
  552. "error": null,
  553. "enabled": true,
  554. "disabled_at": null,
  555. "disabled_by": null,
  556. "archived": false,
  557. "display_status": "queuing",
  558. "word_count": 0,
  559. "hit_count": 0,
  560. "doc_form": "text_model"
  561. },
  562. "batch": "20230921150427533684"
  563. }
  564. ```
  565. </CodeGroup>
  566. </Col>
  567. </Row>
  568. <hr className='ml-0 mr-0' />
  569. <Heading
  570. url='/datasets/{dataset_id}/documents/{batch}/indexing-status'
  571. method='GET'
  572. title='获取文档嵌入状态(进度)'
  573. name='#indexing_status'
  574. />
  575. <Row>
  576. <Col>
  577. ### Path
  578. <Properties>
  579. <Property name='dataset_id' type='string' key='dataset_id'>
  580. 知识库 ID
  581. </Property>
  582. <Property name='batch' type='string' key='batch'>
  583. 上传文档的批次号
  584. </Property>
  585. </Properties>
  586. </Col>
  587. <Col sticky>
  588. <CodeGroup
  589. title="Request"
  590. tag="GET"
  591. label="/datasets/{dataset_id}/documents/{batch}/indexing-status"
  592. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \\\n--header 'Authorization: Bearer {api_key}'`}
  593. >
  594. ```bash {{ title: 'cURL' }}
  595. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
  596. --header 'Authorization: Bearer {api_key}' \
  597. ```
  598. </CodeGroup>
  599. <CodeGroup title="Response">
  600. ```json {{ title: 'Response' }}
  601. {
  602. "data":[{
  603. "id": "",
  604. "indexing_status": "indexing",
  605. "processing_started_at": 1681623462.0,
  606. "parsing_completed_at": 1681623462.0,
  607. "cleaning_completed_at": 1681623462.0,
  608. "splitting_completed_at": 1681623462.0,
  609. "completed_at": null,
  610. "paused_at": null,
  611. "error": null,
  612. "stopped_at": null,
  613. "completed_segments": 24,
  614. "total_segments": 100
  615. }]
  616. }
  617. ```
  618. </CodeGroup>
  619. </Col>
  620. </Row>
  621. <hr className='ml-0 mr-0' />
  622. <Heading
  623. url='/datasets/{dataset_id}/documents/{document_id}'
  624. method='DELETE'
  625. title='删除文档'
  626. name='#delete_document'
  627. />
  628. <Row>
  629. <Col>
  630. ### Path
  631. <Properties>
  632. <Property name='dataset_id' type='string' key='dataset_id'>
  633. 知识库 ID
  634. </Property>
  635. <Property name='document_id' type='string' key='document_id'>
  636. 文档 ID
  637. </Property>
  638. </Properties>
  639. </Col>
  640. <Col sticky>
  641. <CodeGroup
  642. title="Request"
  643. tag="DELETE"
  644. label="/datasets/{dataset_id}/documents/{document_id}"
  645. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  646. >
  647. ```bash {{ title: 'cURL' }}
  648. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
  649. --header 'Authorization: Bearer {api_key}' \
  650. ```
  651. </CodeGroup>
  652. <CodeGroup title="Response">
  653. ```json {{ title: 'Response' }}
  654. {
  655. "result": "success"
  656. }
  657. ```
  658. </CodeGroup>
  659. </Col>
  660. </Row>
  661. <hr className='ml-0 mr-0' />
  662. <Heading
  663. url='/datasets/{dataset_id}/documents'
  664. method='GET'
  665. title='知识库文档列表'
  666. name='#dataset_document_list'
  667. />
  668. <Row>
  669. <Col>
  670. ### Path
  671. <Properties>
  672. <Property name='dataset_id' type='string' key='dataset_id'>
  673. 知识库 ID
  674. </Property>
  675. </Properties>
  676. ### Query
  677. <Properties>
  678. <Property name='keyword' type='string' key='keyword'>
  679. 搜索关键词,可选,目前仅搜索文档名称
  680. </Property>
  681. <Property name='page' type='string' key='page'>
  682. 页码,可选
  683. </Property>
  684. <Property name='limit' type='string' key='limit'>
  685. 返回条数,可选,默认 20,范围 1-100
  686. </Property>
  687. </Properties>
  688. </Col>
  689. <Col sticky>
  690. <CodeGroup
  691. title="Request"
  692. tag="GET"
  693. label="/datasets/{dataset_id}/documents"
  694. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \\\n--header 'Authorization: Bearer {api_key}'`}
  695. >
  696. ```bash {{ title: 'cURL' }}
  697. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
  698. --header 'Authorization: Bearer {api_key}' \
  699. ```
  700. </CodeGroup>
  701. <CodeGroup title="Response">
  702. ```json {{ title: 'Response' }}
  703. {
  704. "data": [
  705. {
  706. "id": "",
  707. "position": 1,
  708. "data_source_type": "file_upload",
  709. "data_source_info": null,
  710. "dataset_process_rule_id": null,
  711. "name": "dify",
  712. "created_from": "",
  713. "created_by": "",
  714. "created_at": 1681623639,
  715. "tokens": 0,
  716. "indexing_status": "waiting",
  717. "error": null,
  718. "enabled": true,
  719. "disabled_at": null,
  720. "disabled_by": null,
  721. "archived": false
  722. },
  723. ],
  724. "has_more": false,
  725. "limit": 20,
  726. "total": 9,
  727. "page": 1
  728. }
  729. ```
  730. </CodeGroup>
  731. </Col>
  732. </Row>
  733. <hr className='ml-0 mr-0' />
  734. <Heading
  735. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  736. method='POST'
  737. title='新增分段'
  738. name='#create_new_segment'
  739. />
  740. <Row>
  741. <Col>
  742. ### Path
  743. <Properties>
  744. <Property name='dataset_id' type='string' key='dataset_id'>
  745. 知识库 ID
  746. </Property>
  747. <Property name='document_id' type='string' key='document_id'>
  748. 文档 ID
  749. </Property>
  750. </Properties>
  751. ### Request Body
  752. <Properties>
  753. <Property name='segments' type='object list' key='segments'>
  754. - <code>content</code> (text) 文本内容/问题内容,必填
  755. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  756. - <code>keywords</code> (list) 关键字,非必填
  757. </Property>
  758. </Properties>
  759. </Col>
  760. <Col sticky>
  761. <CodeGroup
  762. title="Request"
  763. tag="POST"
  764. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  765. 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"]}]}'`}
  766. >
  767. ```bash {{ title: 'cURL' }}
  768. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  769. --header 'Authorization: Bearer {api_key}' \
  770. --header 'Content-Type: application/json' \
  771. --data-raw '{
  772. "segments": [
  773. {
  774. "content": "1",
  775. "answer": "1",
  776. "keywords": ["a"]
  777. }
  778. ]
  779. }'
  780. ```
  781. </CodeGroup>
  782. <CodeGroup title="Response">
  783. ```json {{ title: 'Response' }}
  784. {
  785. "data": [{
  786. "id": "",
  787. "position": 1,
  788. "document_id": "",
  789. "content": "1",
  790. "answer": "1",
  791. "word_count": 25,
  792. "tokens": 0,
  793. "keywords": [
  794. "a"
  795. ],
  796. "index_node_id": "",
  797. "index_node_hash": "",
  798. "hit_count": 0,
  799. "enabled": true,
  800. "disabled_at": null,
  801. "disabled_by": null,
  802. "status": "completed",
  803. "created_by": "",
  804. "created_at": 1695312007,
  805. "indexing_at": 1695312007,
  806. "completed_at": 1695312007,
  807. "error": null,
  808. "stopped_at": null
  809. }],
  810. "doc_form": "text_model"
  811. }
  812. ```
  813. </CodeGroup>
  814. </Col>
  815. </Row>
  816. <hr className='ml-0 mr-0' />
  817. <Heading
  818. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  819. method='GET'
  820. title='查询文档分段'
  821. name='#get_segment'
  822. />
  823. <Row>
  824. <Col>
  825. ### Path
  826. <Properties>
  827. <Property name='dataset_id' type='string' key='dataset_id'>
  828. 知识库 ID
  829. </Property>
  830. <Property name='document_id' type='string' key='document_id'>
  831. 文档 ID
  832. </Property>
  833. </Properties>
  834. ### Query
  835. <Properties>
  836. <Property name='keyword' type='string' key='keyword'>
  837. 搜索关键词,可选
  838. </Property>
  839. <Property name='status' type='string' key='status'>
  840. 搜索状态,completed
  841. </Property>
  842. </Properties>
  843. </Col>
  844. <Col sticky>
  845. <CodeGroup
  846. title="Request"
  847. tag="GET"
  848. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  849. 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'`}
  850. >
  851. ```bash {{ title: 'cURL' }}
  852. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  853. --header 'Authorization: Bearer {api_key}' \
  854. --header 'Content-Type: application/json'
  855. ```
  856. </CodeGroup>
  857. <CodeGroup title="Response">
  858. ```json {{ title: 'Response' }}
  859. {
  860. "data": [{
  861. "id": "",
  862. "position": 1,
  863. "document_id": "",
  864. "content": "1",
  865. "answer": "1",
  866. "word_count": 25,
  867. "tokens": 0,
  868. "keywords": [
  869. "a"
  870. ],
  871. "index_node_id": "",
  872. "index_node_hash": "",
  873. "hit_count": 0,
  874. "enabled": true,
  875. "disabled_at": null,
  876. "disabled_by": null,
  877. "status": "completed",
  878. "created_by": "",
  879. "created_at": 1695312007,
  880. "indexing_at": 1695312007,
  881. "completed_at": 1695312007,
  882. "error": null,
  883. "stopped_at": null
  884. }],
  885. "doc_form": "text_model"
  886. }
  887. ```
  888. </CodeGroup>
  889. </Col>
  890. </Row>
  891. <hr className='ml-0 mr-0' />
  892. <Heading
  893. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  894. method='DELETE'
  895. title='删除文档分段'
  896. name='#delete_segment'
  897. />
  898. <Row>
  899. <Col>
  900. ### Path
  901. <Properties>
  902. <Property name='dataset_id' type='string' key='dataset_id'>
  903. 知识库 ID
  904. </Property>
  905. <Property name='document_id' type='string' key='document_id'>
  906. 文档 ID
  907. </Property>
  908. <Property name='segment_id' type='string' key='segment_id'>
  909. 文档分段ID
  910. </Property>
  911. </Properties>
  912. </Col>
  913. <Col sticky>
  914. <CodeGroup
  915. title="Request"
  916. tag="DELETE"
  917. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  918. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  919. >
  920. ```bash {{ title: 'cURL' }}
  921. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  922. --header 'Authorization: Bearer {api_key}' \
  923. --header 'Content-Type: application/json'
  924. ```
  925. </CodeGroup>
  926. <CodeGroup title="Response">
  927. ```json {{ title: 'Response' }}
  928. {
  929. "result": "success"
  930. }
  931. ```
  932. </CodeGroup>
  933. </Col>
  934. </Row>
  935. <hr className='ml-0 mr-0' />
  936. <Heading
  937. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  938. method='POST'
  939. title='更新文档分段'
  940. name='#update_segment'
  941. />
  942. <Row>
  943. <Col>
  944. ### POST
  945. <Properties>
  946. <Property name='dataset_id' type='string' key='dataset_id'>
  947. 知识库 ID
  948. </Property>
  949. <Property name='document_id' type='string' key='document_id'>
  950. 文档 ID
  951. </Property>
  952. <Property name='segment_id' type='string' key='segment_id'>
  953. 文档分段ID
  954. </Property>
  955. </Properties>
  956. ### Request Body
  957. <Properties>
  958. <Property name='segment' type='object' key='segment'>
  959. - <code>content</code> (text) 文本内容/问题内容,必填
  960. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  961. - <code>keywords</code> (list) 关键字,非必填
  962. - <code>enabled</code> (bool) false/true,非必填
  963. </Property>
  964. </Properties>
  965. </Col>
  966. <Col sticky>
  967. <CodeGroup
  968. title="Request"
  969. tag="POST"
  970. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  971. 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}}'`}
  972. >
  973. ```bash {{ title: 'cURL' }}
  974. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  975. --header 'Authorization: Bearer {api_key}' \
  976. --header 'Content-Type: application/json' \
  977. --data-raw '{
  978. "segment": {
  979. "content": "1",
  980. "answer": "1",
  981. "keywords": ["a"],
  982. "enabled": false
  983. }
  984. }'
  985. ```
  986. </CodeGroup>
  987. <CodeGroup title="Response">
  988. ```json {{ title: 'Response' }}
  989. {
  990. "data": [{
  991. "id": "",
  992. "position": 1,
  993. "document_id": "",
  994. "content": "1",
  995. "answer": "1",
  996. "word_count": 25,
  997. "tokens": 0,
  998. "keywords": [
  999. "a"
  1000. ],
  1001. "index_node_id": "",
  1002. "index_node_hash": "",
  1003. "hit_count": 0,
  1004. "enabled": true,
  1005. "disabled_at": null,
  1006. "disabled_by": null,
  1007. "status": "completed",
  1008. "created_by": "",
  1009. "created_at": 1695312007,
  1010. "indexing_at": 1695312007,
  1011. "completed_at": 1695312007,
  1012. "error": null,
  1013. "stopped_at": null
  1014. }],
  1015. "doc_form": "text_model"
  1016. }
  1017. ```
  1018. </CodeGroup>
  1019. </Col>
  1020. </Row>
  1021. <hr className='ml-0 mr-0' />
  1022. <Heading
  1023. url='/datasets/{dataset_id}/retrieve'
  1024. method='POST'
  1025. title='检索知识库'
  1026. name='#dataset_retrieval'
  1027. />
  1028. <Row>
  1029. <Col>
  1030. ### Path
  1031. <Properties>
  1032. <Property name='dataset_id' type='string' key='dataset_id'>
  1033. 知识库 ID
  1034. </Property>
  1035. </Properties>
  1036. ### Request Body
  1037. <Properties>
  1038. <Property name='query' type='string' key='query'>
  1039. 检索关键词
  1040. </Property>
  1041. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1042. 检索参数(选填,如不填,按照默认方式召回)
  1043. - <code>search_method</code> (text) 检索方法:以下三个关键字之一,必填
  1044. - <code>keyword_search</code> 关键字检索
  1045. - <code>semantic_search</code> 语义检索
  1046. - <code>full_text_search</code> 全文检索
  1047. - <code>hybrid_search</code> 混合检索
  1048. - <code>reranking_enable</code> (bool) 是否启用 Reranking,非必填,如果检索模式为 semantic_search 模式或者 hybrid_search 则传值
  1049. - <code>reranking_mode</code> (object) Rerank模型配置,非必填,如果启用了 reranking 则传值
  1050. - <code>reranking_provider_name</code> (string) Rerank 模型提供商
  1051. - <code>reranking_model_name</code> (string) Rerank 模型名称
  1052. - <code>weights</code> (double) 混合检索模式下语意检索的权重设置
  1053. - <code>top_k</code> (integer) 返回结果数量,非必填
  1054. - <code>score_threshold_enabled</code> (bool) 是否开启 score 阈值
  1055. - <code>score_threshold</code> (double) Score 阈值
  1056. </Property>
  1057. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1058. 未启用字段
  1059. </Property>
  1060. </Properties>
  1061. </Col>
  1062. <Col sticky>
  1063. <CodeGroup
  1064. title="Request"
  1065. tag="POST"
  1066. label="/datasets/{dataset_id}/retrieve"
  1067. 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 '{
  1068. "query": "test",
  1069. "retrieval_model": {
  1070. "search_method": "keyword_search",
  1071. "reranking_enable": false,
  1072. "reranking_mode": null,
  1073. "reranking_model": {
  1074. "reranking_provider_name": "",
  1075. "reranking_model_name": ""
  1076. },
  1077. "weights": null,
  1078. "top_k": 1,
  1079. "score_threshold_enabled": false,
  1080. "score_threshold": null
  1081. }
  1082. }'`}
  1083. >
  1084. ```bash {{ title: 'cURL' }}
  1085. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1086. --header 'Authorization: Bearer {api_key}' \
  1087. --header 'Content-Type: application/json' \
  1088. --data-raw '{
  1089. "query": "test",
  1090. "retrieval_model": {
  1091. "search_method": "keyword_search",
  1092. "reranking_enable": false,
  1093. "reranking_mode": null,
  1094. "reranking_model": {
  1095. "reranking_provider_name": "",
  1096. "reranking_model_name": ""
  1097. },
  1098. "weights": null,
  1099. "top_k": 2,
  1100. "score_threshold_enabled": false,
  1101. "score_threshold": null
  1102. }
  1103. }'
  1104. ```
  1105. </CodeGroup>
  1106. <CodeGroup title="Response">
  1107. ```json {{ title: 'Response' }}
  1108. {
  1109. "query": {
  1110. "content": "test"
  1111. },
  1112. "records": [
  1113. {
  1114. "segment": {
  1115. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1116. "position": 1,
  1117. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1118. "content": "Operation guide",
  1119. "answer": null,
  1120. "word_count": 847,
  1121. "tokens": 280,
  1122. "keywords": [
  1123. "install",
  1124. "java",
  1125. "base",
  1126. "scripts",
  1127. "jdk",
  1128. "manual",
  1129. "internal",
  1130. "opens",
  1131. "add",
  1132. "vmoptions"
  1133. ],
  1134. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1135. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1136. "hit_count": 0,
  1137. "enabled": true,
  1138. "disabled_at": null,
  1139. "disabled_by": null,
  1140. "status": "completed",
  1141. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1142. "created_at": 1728734540,
  1143. "indexing_at": 1728734552,
  1144. "completed_at": 1728734584,
  1145. "error": null,
  1146. "stopped_at": null,
  1147. "document": {
  1148. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1149. "data_source_type": "upload_file",
  1150. "name": "readme.txt",
  1151. "doc_type": null
  1152. }
  1153. },
  1154. "score": 3.730463140527718e-05,
  1155. "tsne_position": null
  1156. }
  1157. ]
  1158. }
  1159. ```
  1160. </CodeGroup>
  1161. </Col>
  1162. </Row>
  1163. <hr className='ml-0 mr-0' />
  1164. <Row>
  1165. <Col>
  1166. ### 错误信息
  1167. <Properties>
  1168. <Property name='code' type='string' key='code'>
  1169. 返回的错误代码
  1170. </Property>
  1171. </Properties>
  1172. <Properties>
  1173. <Property name='status' type='number' key='status'>
  1174. 返回的错误状态
  1175. </Property>
  1176. </Properties>
  1177. <Properties>
  1178. <Property name='message' type='string' key='message'>
  1179. 返回的错误信息
  1180. </Property>
  1181. </Properties>
  1182. </Col>
  1183. <Col>
  1184. <CodeGroup title="Example">
  1185. ```json {{ title: 'Response' }}
  1186. {
  1187. "code": "no_file_uploaded",
  1188. "message": "Please upload your file.",
  1189. "status": 400
  1190. }
  1191. ```
  1192. </CodeGroup>
  1193. </Col>
  1194. </Row>
  1195. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  1196. <thead style={{ background: '#f9fafc' }}>
  1197. <tr>
  1198. <th className="p-2 border border-slate-300">code</th>
  1199. <th className="p-2 border border-slate-300">status</th>
  1200. <th className="p-2 border border-slate-300">message</th>
  1201. </tr>
  1202. </thead>
  1203. <tbody>
  1204. <tr>
  1205. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  1206. <td className="p-2 border border-slate-300">400</td>
  1207. <td className="p-2 border border-slate-300">Please upload your file.</td>
  1208. </tr>
  1209. <tr>
  1210. <td className="p-2 border border-slate-300">too_many_files</td>
  1211. <td className="p-2 border border-slate-300">400</td>
  1212. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  1213. </tr>
  1214. <tr>
  1215. <td className="p-2 border border-slate-300">file_too_large</td>
  1216. <td className="p-2 border border-slate-300">413</td>
  1217. <td className="p-2 border border-slate-300">File size exceeded.</td>
  1218. </tr>
  1219. <tr>
  1220. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  1221. <td className="p-2 border border-slate-300">415</td>
  1222. <td className="p-2 border border-slate-300">File type not allowed.</td>
  1223. </tr>
  1224. <tr>
  1225. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  1226. <td className="p-2 border border-slate-300">400</td>
  1227. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  1228. </tr>
  1229. <tr>
  1230. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  1231. <td className="p-2 border border-slate-300">400</td>
  1232. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  1233. </tr>
  1234. <tr>
  1235. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  1236. <td className="p-2 border border-slate-300">403</td>
  1237. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  1238. </tr>
  1239. <tr>
  1240. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  1241. <td className="p-2 border border-slate-300">409</td>
  1242. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  1243. </tr>
  1244. <tr>
  1245. <td className="p-2 border border-slate-300">invalid_action</td>
  1246. <td className="p-2 border border-slate-300">400</td>
  1247. <td className="p-2 border border-slate-300">Invalid action.</td>
  1248. </tr>
  1249. <tr>
  1250. <td className="p-2 border border-slate-300">document_already_finished</td>
  1251. <td className="p-2 border border-slate-300">400</td>
  1252. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  1253. </tr>
  1254. <tr>
  1255. <td className="p-2 border border-slate-300">document_indexing</td>
  1256. <td className="p-2 border border-slate-300">400</td>
  1257. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  1258. </tr>
  1259. <tr>
  1260. <td className="p-2 border border-slate-300">invalid_metadata</td>
  1261. <td className="p-2 border border-slate-300">400</td>
  1262. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  1263. </tr>
  1264. </tbody>
  1265. </table>
  1266. <div className="pb-4" />