template.zh.mdx 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  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='doc_form' type='string' key='doc_form'>
  45. 索引内容的形式
  46. - <code>text_model</code> text 文档直接 embedding,经济模式默认为该模式
  47. - <code>hierarchical_model</code> parent-child 模式
  48. - <code>qa_model</code> Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
  49. </Property>
  50. <Property name='doc_language' type='string' key='doc_language'>
  51. 在 Q&A 模式下,指定文档的语言,例如:<code>English</code>、<code>Chinese</code>
  52. </Property>
  53. <Property name='process_rule' type='object' key='process_rule'>
  54. 处理规则
  55. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  56. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  57. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  58. - <code>id</code> (string) 预处理规则的唯一标识符
  59. - 枚举:
  60. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  61. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  62. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  63. - <code>segmentation</code> (object) 分段规则
  64. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 <code>\n</code>
  65. - <code>max_tokens</code> 最大长度(token)默认为 1000
  66. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  67. - <code>subchunk_segmentation</code> (object) 子分段规则
  68. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  69. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  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 --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='通过文件创建文档 '
  132. name='#create-by-file'
  133. />
  134. <Row>
  135. <Col>
  136. 此接口基于已存在知识库,在此知识库的基础上通过文件创建新的文档
  137. ### Path
  138. <Properties>
  139. <Property name='dataset_id' type='string' key='dataset_id'>
  140. 知识库 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> 源文档 ID(选填)
  147. - 用于重新上传文档或修改文档清洗、分段配置,缺失的信息从源文档复制
  148. - 源文档不可为归档的文档
  149. - 当传入 <code>original_document_id</code> 时,代表文档进行更新操作,<code>process_rule</code> 为可填项目,不填默认使用源文档的分段方式
  150. - 未传入 <code>original_document_id</code> 时,代表文档进行新增操作,<code>process_rule</code> 为必填
  151. - <code>indexing_technique</code> 索引方式
  152. - <code>high_quality</code> 高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
  153. - <code>economy</code> 经济:使用 keyword table index 的倒排索引进行构建
  154. - <code>doc_form</code> 索引内容的形式
  155. - <code>text_model</code> text 文档直接 embedding,经济模式默认为该模式
  156. - <code>hierarchical_model</code> parent-child 模式
  157. - <code>qa_model</code> Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
  158. - <code>doc_language</code> 在 Q&A 模式下,指定文档的语言,例如:<code>English</code>、<code>Chinese</code>
  159. - <code>process_rule</code> 处理规则
  160. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  161. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  162. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  163. - <code>id</code> (string) 预处理规则的唯一标识符
  164. - 枚举:
  165. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  166. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  167. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  168. - <code>segmentation</code> (object) 分段规则
  169. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  170. - <code>max_tokens</code> 最大长度(token)默认为 1000
  171. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  172. - <code>subchunk_segmentation</code> (object) 子分段规则
  173. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  174. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  175. </Property>
  176. <Property name='file' type='multipart/form-data' key='file'>
  177. 需要上传的文件。
  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='创建空知识库'
  233. name='#create_empty_dataset'
  234. />
  235. <Row>
  236. <Col>
  237. ### Request Body
  238. <Properties>
  239. <Property name='name' type='string' key='name'>
  240. 知识库名称(必填)
  241. </Property>
  242. <Property name='description' type='string' key='description'>
  243. 知识库描述(选填)
  244. </Property>
  245. <Property name='indexing_technique' type='string' key='indexing_technique'>
  246. 索引模式(选填,建议填写)
  247. - <code>high_quality</code> 高质量
  248. - <code>economy</code> 经济
  249. </Property>
  250. <Property name='permission' type='string' key='permission'>
  251. 权限(选填,默认 only_me)
  252. - <code>only_me</code> 仅自己
  253. - <code>all_team_members</code> 所有团队成员
  254. - <code>partial_members</code> 部分团队成员
  255. </Property>
  256. <Property name='provider' type='string' key='provider'>
  257. Provider(选填,默认 vendor)
  258. - <code>vendor</code> 上传文件
  259. - <code>external</code> 外部知识库
  260. </Property>
  261. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  262. 外部知识库 API_ID(选填)
  263. </Property>
  264. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  265. 外部知识库 ID(选填)
  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 '${props.apiBaseUrl}/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='知识库列表'
  316. name='#dataset_list'
  317. />
  318. <Row>
  319. <Col>
  320. ### Query
  321. <Properties>
  322. <Property name='page' type='string' key='page'>
  323. 页码
  324. </Property>
  325. <Property name='limit' type='string' key='limit'>
  326. 返回条数,默认 20,范围 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": "知识库名称",
  349. "description": "描述信息",
  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='删除知识库'
  377. name='#delete_dataset'
  378. />
  379. <Row>
  380. <Col>
  381. ### Path
  382. <Properties>
  383. <Property name='dataset_id' type='string' key='dataset_id'>
  384. 知识库 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='通过文本更新文档'
  412. name='#update-by-text'
  413. />
  414. <Row>
  415. <Col>
  416. 此接口基于已存在知识库,在此知识库的基础上通过文本更新文档
  417. ### Path
  418. <Properties>
  419. <Property name='dataset_id' type='string' key='dataset_id'>
  420. 知识库 ID
  421. </Property>
  422. <Property name='document_id' type='string' key='document_id'>
  423. 文档 ID
  424. </Property>
  425. </Properties>
  426. ### Request Body
  427. <Properties>
  428. <Property name='name' type='string' key='name'>
  429. 文档名称(选填)
  430. </Property>
  431. <Property name='text' type='string' key='text'>
  432. 文档内容(选填)
  433. </Property>
  434. <Property name='process_rule' type='object' key='process_rule'>
  435. 处理规则(选填)
  436. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  437. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  438. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  439. - <code>id</code> (string) 预处理规则的唯一标识符
  440. - 枚举:
  441. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  442. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  443. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  444. - <code>segmentation</code> (object) 分段规则
  445. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  446. - <code>max_tokens</code> 最大长度(token)默认为 1000
  447. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  448. - <code>subchunk_segmentation</code> (object) 子分段规则
  449. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  450. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  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='通过文件更新文档'
  509. name='#update-by-file'
  510. />
  511. <Row>
  512. <Col>
  513. 此接口基于已存在知识库,在此知识库的基础上通过文件更新文档的操作。
  514. ### Path
  515. <Properties>
  516. <Property name='dataset_id' type='string' key='dataset_id'>
  517. 知识库 ID
  518. </Property>
  519. <Property name='document_id' type='string' key='document_id'>
  520. 文档 ID
  521. </Property>
  522. </Properties>
  523. ### Request Body
  524. <Properties>
  525. <Property name='name' type='string' key='name'>
  526. 文档名称(选填)
  527. </Property>
  528. <Property name='file' type='multipart/form-data' key='file'>
  529. 需要上传的文件
  530. </Property>
  531. <Property name='process_rule' type='object' key='process_rule'>
  532. 处理规则(选填)
  533. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义
  534. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  535. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  536. - <code>id</code> (string) 预处理规则的唯一标识符
  537. - 枚举:
  538. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  539. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  540. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  541. - <code>segmentation</code> (object) 分段规则
  542. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  543. - <code>max_tokens</code> 最大长度(token)默认为 1000
  544. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  545. - <code>subchunk_segmentation</code> (object) 子分段规则
  546. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  547. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  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='获取文档嵌入状态(进度)'
  603. name='#indexing_status'
  604. />
  605. <Row>
  606. <Col>
  607. ### Path
  608. <Properties>
  609. <Property name='dataset_id' type='string' key='dataset_id'>
  610. 知识库 ID
  611. </Property>
  612. <Property name='batch' type='string' key='batch'>
  613. 上传文档的批次号
  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='删除文档'
  656. name='#delete_document'
  657. />
  658. <Row>
  659. <Col>
  660. ### Path
  661. <Properties>
  662. <Property name='dataset_id' type='string' key='dataset_id'>
  663. 知识库 ID
  664. </Property>
  665. <Property name='document_id' type='string' key='document_id'>
  666. 文档 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='知识库文档列表'
  696. name='#dataset_document_list'
  697. />
  698. <Row>
  699. <Col>
  700. ### Path
  701. <Properties>
  702. <Property name='dataset_id' type='string' key='dataset_id'>
  703. 知识库 ID
  704. </Property>
  705. </Properties>
  706. ### Query
  707. <Properties>
  708. <Property name='keyword' type='string' key='keyword'>
  709. 搜索关键词,可选,目前仅搜索文档名称
  710. </Property>
  711. <Property name='page' type='string' key='page'>
  712. 页码,可选
  713. </Property>
  714. <Property name='limit' type='string' key='limit'>
  715. 返回条数,可选,默认 20,范围 1-100
  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='新增分段'
  768. name='#create_new_segment'
  769. />
  770. <Row>
  771. <Col>
  772. ### Path
  773. <Properties>
  774. <Property name='dataset_id' type='string' key='dataset_id'>
  775. 知识库 ID
  776. </Property>
  777. <Property name='document_id' type='string' key='document_id'>
  778. 文档 ID
  779. </Property>
  780. </Properties>
  781. ### Request Body
  782. <Properties>
  783. <Property name='segments' type='object list' key='segments'>
  784. - <code>content</code> (text) 文本内容/问题内容,必填
  785. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  786. - <code>keywords</code> (list) 关键字,非必填
  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='查询文档分段'
  851. name='#get_segment'
  852. />
  853. <Row>
  854. <Col>
  855. ### Path
  856. <Properties>
  857. <Property name='dataset_id' type='string' key='dataset_id'>
  858. 知识库 ID
  859. </Property>
  860. <Property name='document_id' type='string' key='document_id'>
  861. 文档 ID
  862. </Property>
  863. </Properties>
  864. ### Query
  865. <Properties>
  866. <Property name='keyword' type='string' key='keyword'>
  867. 搜索关键词,可选
  868. </Property>
  869. <Property name='status' type='string' key='status'>
  870. 搜索状态,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='删除文档分段'
  926. name='#delete_segment'
  927. />
  928. <Row>
  929. <Col>
  930. ### Path
  931. <Properties>
  932. <Property name='dataset_id' type='string' key='dataset_id'>
  933. 知识库 ID
  934. </Property>
  935. <Property name='document_id' type='string' key='document_id'>
  936. 文档 ID
  937. </Property>
  938. <Property name='segment_id' type='string' key='segment_id'>
  939. 文档分段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}/documents/{document_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}/documents/{document_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='更新文档分段'
  970. name='#update_segment'
  971. />
  972. <Row>
  973. <Col>
  974. ### POST
  975. <Properties>
  976. <Property name='dataset_id' type='string' key='dataset_id'>
  977. 知识库 ID
  978. </Property>
  979. <Property name='document_id' type='string' key='document_id'>
  980. 文档 ID
  981. </Property>
  982. <Property name='segment_id' type='string' key='segment_id'>
  983. 文档分段ID
  984. </Property>
  985. </Properties>
  986. ### Request Body
  987. <Properties>
  988. <Property name='segment' type='object' key='segment'>
  989. - <code>content</code> (text) 文本内容/问题内容,必填
  990. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  991. - <code>keywords</code> (list) 关键字,非必填
  992. - <code>enabled</code> (bool) false/true,非必填
  993. - <code>regenerate_child_chunks</code> (bool) 是否重新生成子分段,非必填
  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 'Authorization: Bearer {api_key}' \
  1007. --header 'Content-Type: application/json' \
  1008. --data-raw '{
  1009. "segment": {
  1010. "content": "1",
  1011. "answer": "1",
  1012. "keywords": ["a"],
  1013. "enabled": false
  1014. }
  1015. }'
  1016. ```
  1017. </CodeGroup>
  1018. <CodeGroup title="Response">
  1019. ```json {{ title: 'Response' }}
  1020. {
  1021. "data": [{
  1022. "id": "",
  1023. "position": 1,
  1024. "document_id": "",
  1025. "content": "1",
  1026. "answer": "1",
  1027. "word_count": 25,
  1028. "tokens": 0,
  1029. "keywords": [
  1030. "a"
  1031. ],
  1032. "index_node_id": "",
  1033. "index_node_hash": "",
  1034. "hit_count": 0,
  1035. "enabled": true,
  1036. "disabled_at": null,
  1037. "disabled_by": null,
  1038. "status": "completed",
  1039. "created_by": "",
  1040. "created_at": 1695312007,
  1041. "indexing_at": 1695312007,
  1042. "completed_at": 1695312007,
  1043. "error": null,
  1044. "stopped_at": null
  1045. }],
  1046. "doc_form": "text_model"
  1047. }
  1048. ```
  1049. </CodeGroup>
  1050. </Col>
  1051. </Row>
  1052. <hr className='ml-0 mr-0' />
  1053. <Heading
  1054. url='/datasets/{dataset_id}/retrieve'
  1055. method='POST'
  1056. title='检索知识库'
  1057. name='#dataset_retrieval'
  1058. />
  1059. <Row>
  1060. <Col>
  1061. ### Path
  1062. <Properties>
  1063. <Property name='dataset_id' type='string' key='dataset_id'>
  1064. 知识库 ID
  1065. </Property>
  1066. </Properties>
  1067. ### Request Body
  1068. <Properties>
  1069. <Property name='query' type='string' key='query'>
  1070. 检索关键词
  1071. </Property>
  1072. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1073. 检索参数(选填,如不填,按照默认方式召回)
  1074. - <code>search_method</code> (text) 检索方法:以下三个关键字之一,必填
  1075. - <code>keyword_search</code> 关键字检索
  1076. - <code>semantic_search</code> 语义检索
  1077. - <code>full_text_search</code> 全文检索
  1078. - <code>hybrid_search</code> 混合检索
  1079. - <code>reranking_enable</code> (bool) 是否启用 Reranking,非必填,如果检索模式为 semantic_search 模式或者 hybrid_search 则传值
  1080. - <code>reranking_mode</code> (object) Rerank模型配置,非必填,如果启用了 reranking 则传值
  1081. - <code>reranking_provider_name</code> (string) Rerank 模型提供商
  1082. - <code>reranking_model_name</code> (string) Rerank 模型名称
  1083. - <code>weights</code> (double) 混合检索模式下语意检索的权重设置
  1084. - <code>top_k</code> (integer) 返回结果数量,非必填
  1085. - <code>score_threshold_enabled</code> (bool) 是否开启 score 阈值
  1086. - <code>score_threshold</code> (double) Score 阈值
  1087. </Property>
  1088. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1089. 未启用字段
  1090. </Property>
  1091. </Properties>
  1092. </Col>
  1093. <Col sticky>
  1094. <CodeGroup
  1095. title="Request"
  1096. tag="POST"
  1097. label="/datasets/{dataset_id}/retrieve"
  1098. 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 '{
  1099. "query": "test",
  1100. "retrieval_model": {
  1101. "search_method": "keyword_search",
  1102. "reranking_enable": false,
  1103. "reranking_mode": null,
  1104. "reranking_model": {
  1105. "reranking_provider_name": "",
  1106. "reranking_model_name": ""
  1107. },
  1108. "weights": null,
  1109. "top_k": 1,
  1110. "score_threshold_enabled": false,
  1111. "score_threshold": null
  1112. }
  1113. }'`}
  1114. >
  1115. ```bash {{ title: 'cURL' }}
  1116. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1117. --header 'Authorization: Bearer {api_key}' \
  1118. --header 'Content-Type: application/json' \
  1119. --data-raw '{
  1120. "query": "test",
  1121. "retrieval_model": {
  1122. "search_method": "keyword_search",
  1123. "reranking_enable": false,
  1124. "reranking_mode": null,
  1125. "reranking_model": {
  1126. "reranking_provider_name": "",
  1127. "reranking_model_name": ""
  1128. },
  1129. "weights": null,
  1130. "top_k": 2,
  1131. "score_threshold_enabled": false,
  1132. "score_threshold": null
  1133. }
  1134. }'
  1135. ```
  1136. </CodeGroup>
  1137. <CodeGroup title="Response">
  1138. ```json {{ title: 'Response' }}
  1139. {
  1140. "query": {
  1141. "content": "test"
  1142. },
  1143. "records": [
  1144. {
  1145. "segment": {
  1146. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1147. "position": 1,
  1148. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1149. "content": "Operation guide",
  1150. "answer": null,
  1151. "word_count": 847,
  1152. "tokens": 280,
  1153. "keywords": [
  1154. "install",
  1155. "java",
  1156. "base",
  1157. "scripts",
  1158. "jdk",
  1159. "manual",
  1160. "internal",
  1161. "opens",
  1162. "add",
  1163. "vmoptions"
  1164. ],
  1165. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1166. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1167. "hit_count": 0,
  1168. "enabled": true,
  1169. "disabled_at": null,
  1170. "disabled_by": null,
  1171. "status": "completed",
  1172. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1173. "created_at": 1728734540,
  1174. "indexing_at": 1728734552,
  1175. "completed_at": 1728734584,
  1176. "error": null,
  1177. "stopped_at": null,
  1178. "document": {
  1179. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1180. "data_source_type": "upload_file",
  1181. "name": "readme.txt",
  1182. "doc_type": null
  1183. }
  1184. },
  1185. "score": 3.730463140527718e-05,
  1186. "tsne_position": null
  1187. }
  1188. ]
  1189. }
  1190. ```
  1191. </CodeGroup>
  1192. </Col>
  1193. </Row>
  1194. <hr className='ml-0 mr-0' />
  1195. <Row>
  1196. <Col>
  1197. ### 错误信息
  1198. <Properties>
  1199. <Property name='code' type='string' key='code'>
  1200. 返回的错误代码
  1201. </Property>
  1202. </Properties>
  1203. <Properties>
  1204. <Property name='status' type='number' key='status'>
  1205. 返回的错误状态
  1206. </Property>
  1207. </Properties>
  1208. <Properties>
  1209. <Property name='message' type='string' key='message'>
  1210. 返回的错误信息
  1211. </Property>
  1212. </Properties>
  1213. </Col>
  1214. <Col>
  1215. <CodeGroup title="Example">
  1216. ```json {{ title: 'Response' }}
  1217. {
  1218. "code": "no_file_uploaded",
  1219. "message": "Please upload your file.",
  1220. "status": 400
  1221. }
  1222. ```
  1223. </CodeGroup>
  1224. </Col>
  1225. </Row>
  1226. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  1227. <thead style={{ background: '#f9fafc' }}>
  1228. <tr>
  1229. <th className="p-2 border border-slate-300">code</th>
  1230. <th className="p-2 border border-slate-300">status</th>
  1231. <th className="p-2 border border-slate-300">message</th>
  1232. </tr>
  1233. </thead>
  1234. <tbody>
  1235. <tr>
  1236. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  1237. <td className="p-2 border border-slate-300">400</td>
  1238. <td className="p-2 border border-slate-300">Please upload your file.</td>
  1239. </tr>
  1240. <tr>
  1241. <td className="p-2 border border-slate-300">too_many_files</td>
  1242. <td className="p-2 border border-slate-300">400</td>
  1243. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  1244. </tr>
  1245. <tr>
  1246. <td className="p-2 border border-slate-300">file_too_large</td>
  1247. <td className="p-2 border border-slate-300">413</td>
  1248. <td className="p-2 border border-slate-300">File size exceeded.</td>
  1249. </tr>
  1250. <tr>
  1251. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  1252. <td className="p-2 border border-slate-300">415</td>
  1253. <td className="p-2 border border-slate-300">File type not allowed.</td>
  1254. </tr>
  1255. <tr>
  1256. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  1257. <td className="p-2 border border-slate-300">400</td>
  1258. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  1259. </tr>
  1260. <tr>
  1261. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  1262. <td className="p-2 border border-slate-300">400</td>
  1263. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  1264. </tr>
  1265. <tr>
  1266. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  1267. <td className="p-2 border border-slate-300">403</td>
  1268. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  1269. </tr>
  1270. <tr>
  1271. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  1272. <td className="p-2 border border-slate-300">409</td>
  1273. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  1274. </tr>
  1275. <tr>
  1276. <td className="p-2 border border-slate-300">invalid_action</td>
  1277. <td className="p-2 border border-slate-300">400</td>
  1278. <td className="p-2 border border-slate-300">Invalid action.</td>
  1279. </tr>
  1280. <tr>
  1281. <td className="p-2 border border-slate-300">document_already_finished</td>
  1282. <td className="p-2 border border-slate-300">400</td>
  1283. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  1284. </tr>
  1285. <tr>
  1286. <td className="p-2 border border-slate-300">document_indexing</td>
  1287. <td className="p-2 border border-slate-300">400</td>
  1288. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  1289. </tr>
  1290. <tr>
  1291. <td className="p-2 border border-slate-300">invalid_metadata</td>
  1292. <td className="p-2 border border-slate-300">400</td>
  1293. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  1294. </tr>
  1295. </tbody>
  1296. </table>
  1297. <div className="pb-4" />