Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

template.zh.mdx 92KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806
  1. {/**
  2. * @typedef Props
  3. * @property {string} apiBaseUrl
  4. */}
  5. import { CodeGroup } from '@/app/components/develop/code.tsx'
  6. import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstruction, Paragraph } from '@/app/components/develop/md.tsx'
  7. # 知识库 API
  8. <div>
  9. ### 鉴权
  10. Service API 使用 `API-Key` 进行鉴权。
  11. 建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。
  12. 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:
  13. <CodeGroup title="Code">
  14. ```javascript
  15. Authorization: Bearer {API_KEY}
  16. ```
  17. </CodeGroup>
  18. </div>
  19. <hr className='ml-0 mr-0' />
  20. <Heading
  21. url='/datasets/{dataset_id}/document/create-by-text'
  22. method='POST'
  23. title='通过文本创建文档'
  24. name='#create-by-text'
  25. />
  26. <Row>
  27. <Col>
  28. 此接口基于已存在知识库,在此知识库的基础上通过文本创建新的文档
  29. ### Path
  30. <Properties>
  31. <Property name='dataset_id' type='string' key='dataset_id'>
  32. 知识库 ID
  33. </Property>
  34. </Properties>
  35. ### Request Body
  36. <Properties>
  37. <Property name='name' type='string' key='name'>
  38. 文档名称
  39. </Property>
  40. <Property name='text' type='string' key='text'>
  41. 文档内容
  42. </Property>
  43. <Property name='indexing_technique' type='string' key='indexing_technique'>
  44. 索引方式
  45. - <code>high_quality</code> 高质量:使用
  46. ding 模型进行嵌入,构建为向量数据库索引
  47. - <code>economy</code> 经济:使用 keyword table index 的倒排索引进行构建
  48. </Property>
  49. <Property name='doc_form' type='string' key='doc_form'>
  50. 索引内容的形式
  51. - <code>text_model</code> text 文档直接 embedding,经济模式默认为该模式
  52. - <code>hierarchical_model</code> parent-child 模式
  53. - <code>qa_model</code> Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
  54. </Property>
  55. <Property name='doc_language' type='string' key='doc_language'>
  56. 在 Q&A 模式下,指定文档的语言,例如:<code>English</code>、<code>Chinese</code>
  57. </Property>
  58. <Property name='process_rule' type='object' key='process_rule'>
  59. 处理规则
  60. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义 / hierarchical 父子
  61. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  62. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  63. - <code>id</code> (string) 预处理规则的唯一标识符
  64. - 枚举:
  65. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  66. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  67. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  68. - <code>segmentation</code> (object) 分段规则
  69. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 <code>\n</code>
  70. - <code>max_tokens</code> 最大长度(token)默认为 1000
  71. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  72. - <code>subchunk_segmentation</code> (object) 子分段规则
  73. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  74. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  75. - <code>chunk_overlap</code> 分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
  76. </Property>
  77. <PropertyInstruction>当知识库未设置任何参数的时候,首次上传需要提供以下参数,未提供则使用默认选项:</PropertyInstruction>
  78. <Property name='retrieval_model' type='object' key='retrieval_model'>
  79. 检索模式
  80. - <code>search_method</code> (string) 检索方法
  81. - <code>hybrid_search</code> 混合检索
  82. - <code>semantic_search</code> 语义检索
  83. - <code>full_text_search</code> 全文检索
  84. - <code>reranking_enable</code> (bool) 是否开启rerank
  85. - <code>reranking_mode</code> (String) 混合检索
  86. - <code>weighted_score</code> 权重设置
  87. - <code>reranking_model</code> Rerank 模型
  88. - <code>reranking_model</code> (object) Rerank 模型配置
  89. - <code>reranking_provider_name</code> (string) Rerank 模型的提供商
  90. - <code>reranking_model_name</code> (string) Rerank 模型的名称
  91. - <code>top_k</code> (int) 召回条数
  92. - <code>score_threshold_enabled</code> (bool)是否开启召回分数限制
  93. - <code>score_threshold</code> (float) 召回分数限制
  94. </Property>
  95. <Property name='embedding_model' type='string' key='embedding_model'>
  96. Embedding 模型名称
  97. </Property>
  98. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  99. Embedding 模型供应商
  100. </Property>
  101. </Properties>
  102. </Col>
  103. <Col sticky>
  104. <CodeGroup
  105. title="Request"
  106. tag="POST"
  107. label="/datasets/{dataset_id}/document/create-by-text"
  108. 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"}}'`}
  109. >
  110. ```bash {{ title: 'cURL' }}
  111. curl --location --request --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
  112. --header 'Authorization: Bearer {api_key}' \
  113. --header 'Content-Type: application/json' \
  114. --data-raw '{
  115. "name": "text",
  116. "text": "text",
  117. "indexing_technique": "high_quality",
  118. "process_rule": {
  119. "mode": "automatic"
  120. }
  121. }'
  122. ```
  123. </CodeGroup>
  124. <CodeGroup title="Response">
  125. ```json {{ title: 'Response' }}
  126. {
  127. "document": {
  128. "id": "",
  129. "position": 1,
  130. "data_source_type": "upload_file",
  131. "data_source_info": {
  132. "upload_file_id": ""
  133. },
  134. "dataset_process_rule_id": "",
  135. "name": "text.txt",
  136. "created_from": "api",
  137. "created_by": "",
  138. "created_at": 1695690280,
  139. "tokens": 0,
  140. "indexing_status": "waiting",
  141. "error": null,
  142. "enabled": true,
  143. "disabled_at": null,
  144. "disabled_by": null,
  145. "archived": false,
  146. "display_status": "queuing",
  147. "word_count": 0,
  148. "hit_count": 0,
  149. "doc_form": "text_model"
  150. },
  151. "batch": ""
  152. }
  153. ```
  154. </CodeGroup>
  155. </Col>
  156. </Row>
  157. <hr className='ml-0 mr-0' />
  158. <Heading
  159. url='/datasets/{dataset_id}/document/create-by-file'
  160. method='POST'
  161. title='通过文件创建文档 '
  162. name='#create-by-file'
  163. />
  164. <Row>
  165. <Col>
  166. 此接口基于已存在知识库,在此知识库的基础上通过文件创建新的文档
  167. ### Path
  168. <Properties>
  169. <Property name='dataset_id' type='string' key='dataset_id'>
  170. 知识库 ID
  171. </Property>
  172. </Properties>
  173. ### Request Body
  174. <Properties>
  175. <Property name='data' type='multipart/form-data json string' key='data'>
  176. - <code>original_document_id</code> 源文档 ID(选填)
  177. - 用于重新上传文档或修改文档清洗、分段配置,缺失的信息从源文档复制
  178. - 源文档不可为归档的文档
  179. - 当传入 <code>original_document_id</code> 时,代表文档进行更新操作,<code>process_rule</code> 为可填项目,不填默认使用源文档的分段方式
  180. - 未传入 <code>original_document_id</code> 时,代表文档进行新增操作,<code>process_rule</code> 为必填
  181. - <code>indexing_technique</code> 索引方式
  182. - <code>high_quality</code> 高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
  183. - <code>economy</code> 经济:使用 keyword table index 的倒排索引进行构建
  184. - <code>doc_form</code> 索引内容的形式
  185. - <code>text_model</code> text 文档直接 embedding,经济模式默认为该模式
  186. - <code>hierarchical_model</code> parent-child 模式
  187. - <code>qa_model</code> Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
  188. - <code>doc_language</code> 在 Q&A 模式下,指定文档的语言,例如:<code>English</code>、<code>Chinese</code>
  189. - <code>process_rule</code> 处理规则
  190. - <code>mode</code> (string) 清洗、分段模式,automatic 自动 / custom 自定义 / hierarchical 父子
  191. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  192. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  193. - <code>id</code> (string) 预处理规则的唯一标识符
  194. - 枚举:
  195. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  196. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  197. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  198. - <code>segmentation</code> (object) 分段规则
  199. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  200. - <code>max_tokens</code> 最大长度(token)默认为 1000
  201. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  202. - <code>subchunk_segmentation</code> (object) 子分段规则
  203. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  204. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  205. - <code>chunk_overlap</code> 分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
  206. </Property>
  207. <Property name='file' type='multipart/form-data' key='file'>
  208. 需要上传的文件。
  209. </Property>
  210. <PropertyInstruction>当知识库未设置任何参数的时候,首次上传需要提供以下参数,未提供则使用默认选项:</PropertyInstruction>
  211. <Property name='retrieval_model' type='object' key='retrieval_model'>
  212. 检索模式
  213. - <code>search_method</code> (string) 检索方法
  214. - <code>hybrid_search</code> 混合检索
  215. - <code>semantic_search</code> 语义检索
  216. - <code>full_text_search</code> 全文检索
  217. - <code>reranking_enable</code> (bool) 是否开启 rerank
  218. - <code>reranking_model</code> (object) Rerank 模型配置
  219. - <code>reranking_provider_name</code> (string) Rerank 模型的提供商
  220. - <code>reranking_model_name</code> (string) Rerank 模型的名称
  221. - <code>top_k</code> (int) 召回条数
  222. - <code>score_threshold_enabled</code> (bool) 是否开启召回分数限制
  223. - <code>score_threshold</code> (float) 召回分数限制
  224. </Property>
  225. <Property name='embedding_model' type='string' key='embedding_model'>
  226. Embedding 模型名称
  227. </Property>
  228. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  229. Embedding 模型供应商
  230. </Property>
  231. </Properties>
  232. </Col>
  233. <Col sticky>
  234. <CodeGroup
  235. title="Request"
  236. tag="POST"
  237. label="/datasets/{dataset_id}/document/create-by-file"
  238. 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"'`}
  239. >
  240. ```bash {{ title: 'cURL' }}
  241. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
  242. --header 'Authorization: Bearer {api_key}' \
  243. --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' \
  244. --form 'file=@"/path/to/file"'
  245. ```
  246. </CodeGroup>
  247. <CodeGroup title="Response">
  248. ```json {{ title: 'Response' }}
  249. {
  250. "document": {
  251. "id": "",
  252. "position": 1,
  253. "data_source_type": "upload_file",
  254. "data_source_info": {
  255. "upload_file_id": ""
  256. },
  257. "dataset_process_rule_id": "",
  258. "name": "Dify.txt",
  259. "created_from": "api",
  260. "created_by": "",
  261. "created_at": 1695308667,
  262. "tokens": 0,
  263. "indexing_status": "waiting",
  264. "error": null,
  265. "enabled": true,
  266. "disabled_at": null,
  267. "disabled_by": null,
  268. "archived": false,
  269. "display_status": "queuing",
  270. "word_count": 0,
  271. "hit_count": 0,
  272. "doc_form": "text_model"
  273. },
  274. "batch": ""
  275. }
  276. ```
  277. </CodeGroup>
  278. </Col>
  279. </Row>
  280. <hr className='ml-0 mr-0' />
  281. <Heading
  282. url='/datasets'
  283. method='POST'
  284. title='创建空知识库'
  285. name='#create_empty_dataset'
  286. />
  287. <Row>
  288. <Col>
  289. ### Request Body
  290. <Properties>
  291. <Property name='name' type='string' key='name'>
  292. 知识库名称(必填)
  293. </Property>
  294. <Property name='description' type='string' key='description'>
  295. 知识库描述(选填)
  296. </Property>
  297. <Property name='indexing_technique' type='string' key='indexing_technique'>
  298. 索引模式(选填,建议填写)
  299. - <code>high_quality</code> 高质量
  300. - <code>economy</code> 经济
  301. </Property>
  302. <Property name='permission' type='string' key='permission'>
  303. 权限(选填,默认 only_me)
  304. - <code>only_me</code> 仅自己
  305. - <code>all_team_members</code> 所有团队成员
  306. - <code>partial_members</code> 部分团队成员
  307. </Property>
  308. <Property name='provider' type='string' key='provider'>
  309. Provider(选填,默认 vendor)
  310. - <code>vendor</code> 上传文件
  311. - <code>external</code> 外部知识库
  312. </Property>
  313. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  314. 外部知识库 API_ID(选填)
  315. </Property>
  316. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  317. 外部知识库 ID(选填)
  318. </Property>
  319. <Property name='embedding_model' type='str' key='embedding_model'>
  320. Embedding 模型名称
  321. </Property>
  322. <Property name='embedding_model_provider' type='str' key='embedding_model_provider'>
  323. Embedding 模型供应商
  324. </Property>
  325. <Property name='retrieval_model' type='object' key='retrieval_model'>
  326. 检索模式
  327. - <code>search_method</code> (string) 检索方法
  328. - <code>hybrid_search</code> 混合检索
  329. - <code>semantic_search</code> 语义检索
  330. - <code>full_text_search</code> 全文检索
  331. - <code>reranking_enable</code> (bool) 是否开启 rerank
  332. - <code>reranking_model</code> (object) Rerank 模型配置
  333. - <code>reranking_provider_name</code> (string) Rerank 模型的提供商
  334. - <code>reranking_model_name</code> (string) Rerank 模型的名称
  335. - <code>top_k</code> (int) 召回条数
  336. - <code>score_threshold_enabled</code> (bool) 是否开启召回分数限制
  337. - <code>score_threshold</code> (float) 召回分数限制
  338. </Property>
  339. </Properties>
  340. </Col>
  341. <Col sticky>
  342. <CodeGroup
  343. title="Request"
  344. tag="POST"
  345. label="/datasets"
  346. 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"}'`}
  347. >
  348. ```bash {{ title: 'cURL' }}
  349. curl --location --request POST '${props.apiBaseUrl}/datasets' \
  350. --header 'Authorization: Bearer {api_key}' \
  351. --header 'Content-Type: application/json' \
  352. --data-raw '{
  353. "name": "name",
  354. "permission": "only_me"
  355. }'
  356. ```
  357. </CodeGroup>
  358. <CodeGroup title="Response">
  359. ```json {{ title: 'Response' }}
  360. {
  361. "id": "",
  362. "name": "name",
  363. "description": null,
  364. "provider": "vendor",
  365. "permission": "only_me",
  366. "data_source_type": null,
  367. "indexing_technique": null,
  368. "app_count": 0,
  369. "document_count": 0,
  370. "word_count": 0,
  371. "created_by": "",
  372. "created_at": 1695636173,
  373. "updated_by": "",
  374. "updated_at": 1695636173,
  375. "embedding_model": null,
  376. "embedding_model_provider": null,
  377. "embedding_available": null
  378. }
  379. ```
  380. </CodeGroup>
  381. </Col>
  382. </Row>
  383. <hr className='ml-0 mr-0' />
  384. <Heading
  385. url='/datasets'
  386. method='GET'
  387. title='知识库列表'
  388. name='#dataset_list'
  389. />
  390. <Row>
  391. <Col>
  392. ### Query
  393. <Properties>
  394. <Property name='keyword' type='string' key='keyword'>
  395. 搜索关键词,可选
  396. </Property>
  397. <Property name='tag_ids' type='array[string]' key='tag_ids'>
  398. 标签 ID 列表,可选
  399. </Property>
  400. <Property name='page' type='integer' key='page'>
  401. 页码,可选,默认为 1
  402. </Property>
  403. <Property name='limit' type='string' key='limit'>
  404. 返回条数,可选,默认 20,范围 1-100
  405. </Property>
  406. <Property name='include_all' type='boolean' key='include_all'>
  407. 是否包含所有数据集(仅对所有者生效),可选,默认为 false
  408. </Property>
  409. </Properties>
  410. </Col>
  411. <Col sticky>
  412. <CodeGroup
  413. title="Request"
  414. tag="GET"
  415. label="/datasets"
  416. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  417. >
  418. ```bash {{ title: 'cURL' }}
  419. curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
  420. --header 'Authorization: Bearer {api_key}'
  421. ```
  422. </CodeGroup>
  423. <CodeGroup title="Response">
  424. ```json {{ title: 'Response' }}
  425. {
  426. "data": [
  427. {
  428. "id": "",
  429. "name": "知识库名称",
  430. "description": "描述信息",
  431. "permission": "only_me",
  432. "data_source_type": "upload_file",
  433. "indexing_technique": "",
  434. "app_count": 2,
  435. "document_count": 10,
  436. "word_count": 1200,
  437. "created_by": "",
  438. "created_at": "",
  439. "updated_by": "",
  440. "updated_at": ""
  441. },
  442. ...
  443. ],
  444. "has_more": true,
  445. "limit": 20,
  446. "total": 50,
  447. "page": 1
  448. }
  449. ```
  450. </CodeGroup>
  451. </Col>
  452. </Row>
  453. <hr className='ml-0 mr-0' />
  454. <Heading
  455. url='/datasets/{dataset_id}'
  456. method='GET'
  457. title='查看知识库详情'
  458. name='#view_dataset'
  459. />
  460. <Row>
  461. <Col>
  462. ### Path
  463. <Properties>
  464. <Property name='dataset_id' type='string' key='dataset_id'>
  465. 知识库 ID
  466. </Property>
  467. </Properties>
  468. </Col>
  469. <Col sticky>
  470. <CodeGroup
  471. title="Request"
  472. tag="GET"
  473. label="/datasets/{dataset_id}"
  474. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  475. >
  476. ```bash {{ title: 'cURL' }}
  477. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}' \
  478. --header 'Authorization: Bearer {api_key}'
  479. ```
  480. </CodeGroup>
  481. <CodeGroup title="Response">
  482. ```json {{ title: 'Response' }}
  483. {
  484. "id": "eaedb485-95ac-4ffd-ab1e-18da6d676a2f",
  485. "name": "Test Knowledge Base",
  486. "description": "",
  487. "provider": "vendor",
  488. "permission": "only_me",
  489. "data_source_type": null,
  490. "indexing_technique": null,
  491. "app_count": 0,
  492. "document_count": 0,
  493. "word_count": 0,
  494. "created_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
  495. "created_at": 1735620612,
  496. "updated_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
  497. "updated_at": 1735620612,
  498. "embedding_model": null,
  499. "embedding_model_provider": null,
  500. "embedding_available": true,
  501. "retrieval_model_dict": {
  502. "search_method": "semantic_search",
  503. "reranking_enable": false,
  504. "reranking_mode": null,
  505. "reranking_model": {
  506. "reranking_provider_name": "",
  507. "reranking_model_name": ""
  508. },
  509. "weights": null,
  510. "top_k": 2,
  511. "score_threshold_enabled": false,
  512. "score_threshold": null
  513. },
  514. "tags": [],
  515. "doc_form": null,
  516. "external_knowledge_info": {
  517. "external_knowledge_id": null,
  518. "external_knowledge_api_id": null,
  519. "external_knowledge_api_name": null,
  520. "external_knowledge_api_endpoint": null
  521. },
  522. "external_retrieval_model": {
  523. "top_k": 2,
  524. "score_threshold": 0.0,
  525. "score_threshold_enabled": null
  526. }
  527. }
  528. ```
  529. </CodeGroup>
  530. </Col>
  531. </Row>
  532. <hr className='ml-0 mr-0' />
  533. <Heading
  534. url='/datasets/{dataset_id}'
  535. method='PATCH'
  536. title='修改知识库详情'
  537. name='#update_dataset'
  538. />
  539. <Row>
  540. <Col>
  541. ### Path
  542. <Properties>
  543. <Property name='dataset_id' type='string' key='dataset_id'>
  544. 知识库 ID
  545. </Property>
  546. </Properties>
  547. ### Request Body
  548. <Properties>
  549. <Property name='indexing_technique' type='string' key='indexing_technique'>
  550. 索引模式(选填,建议填写)
  551. - <code>high_quality</code> 高质量
  552. - <code>economy</code> 经济
  553. </Property>
  554. <Property name='permission' type='string' key='permission'>
  555. 权限(选填,默认 only_me)
  556. - <code>only_me</code> 仅自己
  557. - <code>all_team_members</code> 所有团队成员
  558. - <code>partial_members</code> 部分团队成员
  559. </Property>
  560. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  561. 嵌入模型提供商(选填), 必须先在系统内设定好接入的模型,对应的是provider字段
  562. </Property>
  563. <Property name='embedding_model' type='string' key='embedding_model'>
  564. 嵌入模型(选填)
  565. </Property>
  566. <Property name='retrieval_model' type='object' key='retrieval_model'>
  567. 检索参数(选填,如不填,按照默认方式召回)
  568. - <code>search_method</code> (text) 检索方法:以下四个关键字之一,必填
  569. - <code>keyword_search</code> 关键字检索
  570. - <code>semantic_search</code> 语义检索
  571. - <code>full_text_search</code> 全文检索
  572. - <code>hybrid_search</code> 混合检索
  573. - <code>reranking_enable</code> (bool) 是否启用 Reranking,非必填,如果检索模式为 semantic_search 模式或者 hybrid_search 则传值
  574. - <code>reranking_mode</code> (object) Rerank 模型配置,非必填,如果启用了 reranking 则传值
  575. - <code>reranking_provider_name</code> (string) Rerank 模型提供商
  576. - <code>reranking_model_name</code> (string) Rerank 模型名称
  577. - <code>weights</code> (float) 混合检索模式下语意检索的权重设置
  578. - <code>top_k</code> (integer) 返回结果数量,非必填
  579. - <code>score_threshold_enabled</code> (bool) 是否开启 score 阈值
  580. - <code>score_threshold</code> (float) Score 阈值
  581. </Property>
  582. <Property name='partial_member_list' type='array' key='partial_member_list'>
  583. 部分团队成员 ID 列表(选填)
  584. </Property>
  585. </Properties>
  586. </Col>
  587. <Col sticky>
  588. <CodeGroup
  589. title="Request"
  590. tag="PATCH"
  591. label="/datasets/{dataset_id}"
  592. targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{
  593. "name": "Test Knowledge Base",
  594. "indexing_technique": "high_quality",
  595. "permission": "only_me",
  596. "embedding_model_provider": "zhipuai",
  597. "embedding_model": "embedding-3",
  598. "retrieval_model": {
  599. "search_method": "keyword_search",
  600. "reranking_enable": false,
  601. "reranking_mode": null,
  602. "reranking_model": {
  603. "reranking_provider_name": "",
  604. "reranking_model_name": ""
  605. },
  606. "weights": null,
  607. "top_k": 1,
  608. "score_threshold_enabled": false,
  609. "score_threshold": null
  610. },
  611. "partial_member_list": []
  612. }'
  613. `}
  614. >
  615. ```bash {{ title: 'cURL' }}
  616. curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}' \
  617. --header 'Authorization: Bearer {api_key}' \
  618. --header 'Content-Type: application/json' \
  619. --data-raw '{
  620. "name": "Test Knowledge Base",
  621. "indexing_technique": "high_quality",
  622. "permission": "only_me",
  623. "embedding_model_provider": "zhipuai",
  624. "embedding_model": "embedding-3",
  625. "retrieval_model": {
  626. "search_method": "keyword_search",
  627. "reranking_enable": false,
  628. "reranking_mode": null,
  629. "reranking_model": {
  630. "reranking_provider_name": "",
  631. "reranking_model_name": ""
  632. },
  633. "weights": null,
  634. "top_k": 1,
  635. "score_threshold_enabled": false,
  636. "score_threshold": null
  637. },
  638. "partial_member_list": []
  639. }'
  640. ```
  641. </CodeGroup>
  642. <CodeGroup title="Response">
  643. ```json {{ title: 'Response' }}
  644. {
  645. "id": "eaedb485-95ac-4ffd-ab1e-18da6d676a2f",
  646. "name": "Test Knowledge Base",
  647. "description": "",
  648. "provider": "vendor",
  649. "permission": "only_me",
  650. "data_source_type": null,
  651. "indexing_technique": "high_quality",
  652. "app_count": 0,
  653. "document_count": 0,
  654. "word_count": 0,
  655. "created_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
  656. "created_at": 1735620612,
  657. "updated_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
  658. "updated_at": 1735622679,
  659. "embedding_model": "embedding-3",
  660. "embedding_model_provider": "zhipuai",
  661. "embedding_available": null,
  662. "retrieval_model_dict": {
  663. "search_method": "semantic_search",
  664. "reranking_enable": false,
  665. "reranking_mode": null,
  666. "reranking_model": {
  667. "reranking_provider_name": "",
  668. "reranking_model_name": ""
  669. },
  670. "weights": null,
  671. "top_k": 2,
  672. "score_threshold_enabled": false,
  673. "score_threshold": null
  674. },
  675. "tags": [],
  676. "doc_form": null,
  677. "external_knowledge_info": {
  678. "external_knowledge_id": null,
  679. "external_knowledge_api_id": null,
  680. "external_knowledge_api_name": null,
  681. "external_knowledge_api_endpoint": null
  682. },
  683. "external_retrieval_model": {
  684. "top_k": 2,
  685. "score_threshold": 0.0,
  686. "score_threshold_enabled": null
  687. },
  688. "partial_member_list": []
  689. }
  690. ```
  691. </CodeGroup>
  692. </Col>
  693. </Row>
  694. <hr className='ml-0 mr-0' />
  695. <Heading
  696. url='/datasets/{dataset_id}'
  697. method='DELETE'
  698. title='删除知识库'
  699. name='#delete_dataset'
  700. />
  701. <Row>
  702. <Col>
  703. ### Path
  704. <Properties>
  705. <Property name='dataset_id' type='string' key='dataset_id'>
  706. 知识库 ID
  707. </Property>
  708. </Properties>
  709. </Col>
  710. <Col sticky>
  711. <CodeGroup
  712. title="Request"
  713. tag="DELETE"
  714. label="/datasets/{dataset_id}"
  715. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  716. >
  717. ```bash {{ title: 'cURL' }}
  718. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
  719. --header 'Authorization: Bearer {api_key}'
  720. ```
  721. </CodeGroup>
  722. <CodeGroup title="Response">
  723. ```text {{ title: 'Response' }}
  724. 204 No Content
  725. ```
  726. </CodeGroup>
  727. </Col>
  728. </Row>
  729. <hr className='ml-0 mr-0' />
  730. <Heading
  731. url='/datasets/{dataset_id}/documents/{document_id}/update-by-text'
  732. method='POST'
  733. title='通过文本更新文档'
  734. name='#update-by-text'
  735. />
  736. <Row>
  737. <Col>
  738. 此接口基于已存在知识库,在此知识库的基础上通过文本更新文档
  739. ### Path
  740. <Properties>
  741. <Property name='dataset_id' type='string' key='dataset_id'>
  742. 知识库 ID
  743. </Property>
  744. <Property name='document_id' type='string' key='document_id'>
  745. 文档 ID
  746. </Property>
  747. </Properties>
  748. ### Request Body
  749. <Properties>
  750. <Property name='name' type='string' key='name'>
  751. 文档名称(选填)
  752. </Property>
  753. <Property name='text' type='string' key='text'>
  754. 文档内容(选填)
  755. </Property>
  756. <Property name='process_rule' type='object' key='process_rule'>
  757. 处理规则(选填)
  758. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义 / hierarchical 父子
  759. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  760. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  761. - <code>id</code> (string) 预处理规则的唯一标识符
  762. - 枚举:
  763. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  764. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  765. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  766. - <code>segmentation</code> (object) 分段规则
  767. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  768. - <code>max_tokens</code> 最大长度(token)默认为 1000
  769. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  770. - <code>subchunk_segmentation</code> (object) 子分段规则
  771. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  772. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  773. - <code>chunk_overlap</code> 分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
  774. </Property>
  775. </Properties>
  776. </Col>
  777. <Col sticky>
  778. <CodeGroup
  779. title="Request"
  780. tag="POST"
  781. label="/datasets/{dataset_id}/documents/{document_id}/update-by-text"
  782. 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"}'`}
  783. >
  784. ```bash {{ title: 'cURL' }}
  785. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
  786. --header 'Authorization: Bearer {api_key}' \
  787. --header 'Content-Type: application/json' \
  788. --data-raw '{
  789. "name": "name",
  790. "text": "text"
  791. }'
  792. ```
  793. </CodeGroup>
  794. <CodeGroup title="Response">
  795. ```json {{ title: 'Response' }}
  796. {
  797. "document": {
  798. "id": "",
  799. "position": 1,
  800. "data_source_type": "upload_file",
  801. "data_source_info": {
  802. "upload_file_id": ""
  803. },
  804. "dataset_process_rule_id": "",
  805. "name": "name.txt",
  806. "created_from": "api",
  807. "created_by": "",
  808. "created_at": 1695308667,
  809. "tokens": 0,
  810. "indexing_status": "waiting",
  811. "error": null,
  812. "enabled": true,
  813. "disabled_at": null,
  814. "disabled_by": null,
  815. "archived": false,
  816. "display_status": "queuing",
  817. "word_count": 0,
  818. "hit_count": 0,
  819. "doc_form": "text_model"
  820. },
  821. "batch": ""
  822. }
  823. ```
  824. </CodeGroup>
  825. </Col>
  826. </Row>
  827. <hr className='ml-0 mr-0' />
  828. <Heading
  829. url='/datasets/{dataset_id}/documents/{document_id}/update-by-file'
  830. method='POST'
  831. title='通过文件更新文档'
  832. name='#update-by-file'
  833. />
  834. <Row>
  835. <Col>
  836. 此接口基于已存在知识库,在此知识库的基础上通过文件更新文档的操作。
  837. ### Path
  838. <Properties>
  839. <Property name='dataset_id' type='string' key='dataset_id'>
  840. 知识库 ID
  841. </Property>
  842. <Property name='document_id' type='string' key='document_id'>
  843. 文档 ID
  844. </Property>
  845. </Properties>
  846. ### Request Body
  847. <Properties>
  848. <Property name='name' type='string' key='name'>
  849. 文档名称(选填)
  850. </Property>
  851. <Property name='file' type='multipart/form-data' key='file'>
  852. 需要上传的文件
  853. </Property>
  854. <Property name='process_rule' type='object' key='process_rule'>
  855. 处理规则(选填)
  856. - <code>mode</code> (string) 清洗、分段模式 ,automatic 自动 / custom 自定义 / hierarchical 父子
  857. - <code>rules</code> (object) 自定义规则(自动模式下,该字段为空)
  858. - <code>pre_processing_rules</code> (array[object]) 预处理规则
  859. - <code>id</code> (string) 预处理规则的唯一标识符
  860. - 枚举:
  861. - <code>remove_extra_spaces</code> 替换连续空格、换行符、制表符
  862. - <code>remove_urls_emails</code> 删除 URL、电子邮件地址
  863. - <code>enabled</code> (bool) 是否选中该规则,不传入文档 ID 时代表默认值
  864. - <code>segmentation</code> (object) 分段规则
  865. - <code>separator</code> 自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
  866. - <code>max_tokens</code> 最大长度(token)默认为 1000
  867. - <code>parent_mode</code> 父分段的召回模式 <code>full-doc</code> 全文召回 / <code>paragraph</code> 段落召回
  868. - <code>subchunk_segmentation</code> (object) 子分段规则
  869. - <code>separator</code> 分段标识符,目前仅允许设置一个分隔符。默认为 <code>***</code>
  870. - <code>max_tokens</code> 最大长度 (token) 需要校验小于父级的长度
  871. - <code>chunk_overlap</code> 分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
  872. </Property>
  873. </Properties>
  874. </Col>
  875. <Col sticky>
  876. <CodeGroup
  877. title="Request"
  878. tag="POST"
  879. label="/datasets/{dataset_id}/documents/{document_id}/update-by-file"
  880. 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"'`}
  881. >
  882. ```bash {{ title: 'cURL' }}
  883. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
  884. --header 'Authorization: Bearer {api_key}' \
  885. --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' \
  886. --form 'file=@"/path/to/file"'
  887. ```
  888. </CodeGroup>
  889. <CodeGroup title="Response">
  890. ```json {{ title: 'Response' }}
  891. {
  892. "document": {
  893. "id": "",
  894. "position": 1,
  895. "data_source_type": "upload_file",
  896. "data_source_info": {
  897. "upload_file_id": ""
  898. },
  899. "dataset_process_rule_id": "",
  900. "name": "Dify.txt",
  901. "created_from": "api",
  902. "created_by": "",
  903. "created_at": 1695308667,
  904. "tokens": 0,
  905. "indexing_status": "waiting",
  906. "error": null,
  907. "enabled": true,
  908. "disabled_at": null,
  909. "disabled_by": null,
  910. "archived": false,
  911. "display_status": "queuing",
  912. "word_count": 0,
  913. "hit_count": 0,
  914. "doc_form": "text_model"
  915. },
  916. "batch": "20230921150427533684"
  917. }
  918. ```
  919. </CodeGroup>
  920. </Col>
  921. </Row>
  922. <hr className='ml-0 mr-0' />
  923. <Heading
  924. url='/datasets/{dataset_id}/documents/{batch}/indexing-status'
  925. method='GET'
  926. title='获取文档嵌入状态(进度)'
  927. name='#indexing_status'
  928. />
  929. <Row>
  930. <Col>
  931. ### Path
  932. <Properties>
  933. <Property name='dataset_id' type='string' key='dataset_id'>
  934. 知识库 ID
  935. </Property>
  936. <Property name='batch' type='string' key='batch'>
  937. 上传文档的批次号
  938. </Property>
  939. </Properties>
  940. </Col>
  941. <Col sticky>
  942. <CodeGroup
  943. title="Request"
  944. tag="GET"
  945. label="/datasets/{dataset_id}/documents/{batch}/indexing-status"
  946. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \\\n--header 'Authorization: Bearer {api_key}'`}
  947. >
  948. ```bash {{ title: 'cURL' }}
  949. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
  950. --header 'Authorization: Bearer {api_key}' \
  951. ```
  952. </CodeGroup>
  953. <CodeGroup title="Response">
  954. ```json {{ title: 'Response' }}
  955. {
  956. "data":[{
  957. "id": "",
  958. "indexing_status": "indexing",
  959. "processing_started_at": 1681623462.0,
  960. "parsing_completed_at": 1681623462.0,
  961. "cleaning_completed_at": 1681623462.0,
  962. "splitting_completed_at": 1681623462.0,
  963. "completed_at": null,
  964. "paused_at": null,
  965. "error": null,
  966. "stopped_at": null,
  967. "completed_segments": 24,
  968. "total_segments": 100
  969. }]
  970. }
  971. ```
  972. </CodeGroup>
  973. </Col>
  974. </Row>
  975. <hr className='ml-0 mr-0' />
  976. <Heading
  977. url='/datasets/{dataset_id}/documents/{document_id}'
  978. method='DELETE'
  979. title='删除文档'
  980. name='#delete_document'
  981. />
  982. <Row>
  983. <Col>
  984. ### Path
  985. <Properties>
  986. <Property name='dataset_id' type='string' key='dataset_id'>
  987. 知识库 ID
  988. </Property>
  989. <Property name='document_id' type='string' key='document_id'>
  990. 文档 ID
  991. </Property>
  992. </Properties>
  993. </Col>
  994. <Col sticky>
  995. <CodeGroup
  996. title="Request"
  997. tag="DELETE"
  998. label="/datasets/{dataset_id}/documents/{document_id}"
  999. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1000. >
  1001. ```bash {{ title: 'cURL' }}
  1002. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
  1003. --header 'Authorization: Bearer {api_key}' \
  1004. ```
  1005. </CodeGroup>
  1006. <CodeGroup title="Response">
  1007. ```text {{ title: 'Response' }}
  1008. 204 No Content
  1009. ```
  1010. </CodeGroup>
  1011. </Col>
  1012. </Row>
  1013. <hr className='ml-0 mr-0' />
  1014. <Heading
  1015. url='/datasets/{dataset_id}/documents'
  1016. method='GET'
  1017. title='知识库文档列表'
  1018. name='#dataset_document_list'
  1019. />
  1020. <Row>
  1021. <Col>
  1022. ### Path
  1023. <Properties>
  1024. <Property name='dataset_id' type='string' key='dataset_id'>
  1025. 知识库 ID
  1026. </Property>
  1027. </Properties>
  1028. ### Query
  1029. <Properties>
  1030. <Property name='keyword' type='string' key='keyword'>
  1031. 搜索关键词,可选,目前仅搜索文档名称
  1032. </Property>
  1033. <Property name='page' type='string' key='page'>
  1034. 页码,可选
  1035. </Property>
  1036. <Property name='limit' type='string' key='limit'>
  1037. 返回条数,可选,默认 20,范围 1-100
  1038. </Property>
  1039. </Properties>
  1040. </Col>
  1041. <Col sticky>
  1042. <CodeGroup
  1043. title="Request"
  1044. tag="GET"
  1045. label="/datasets/{dataset_id}/documents"
  1046. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \\\n--header 'Authorization: Bearer {api_key}'`}
  1047. >
  1048. ```bash {{ title: 'cURL' }}
  1049. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
  1050. --header 'Authorization: Bearer {api_key}' \
  1051. ```
  1052. </CodeGroup>
  1053. <CodeGroup title="Response">
  1054. ```json {{ title: 'Response' }}
  1055. {
  1056. "data": [
  1057. {
  1058. "id": "",
  1059. "position": 1,
  1060. "data_source_type": "file_upload",
  1061. "data_source_info": null,
  1062. "dataset_process_rule_id": null,
  1063. "name": "dify",
  1064. "created_from": "",
  1065. "created_by": "",
  1066. "created_at": 1681623639,
  1067. "tokens": 0,
  1068. "indexing_status": "waiting",
  1069. "error": null,
  1070. "enabled": true,
  1071. "disabled_at": null,
  1072. "disabled_by": null,
  1073. "archived": false
  1074. },
  1075. ],
  1076. "has_more": false,
  1077. "limit": 20,
  1078. "total": 9,
  1079. "page": 1
  1080. }
  1081. ```
  1082. </CodeGroup>
  1083. </Col>
  1084. </Row>
  1085. <hr className='ml-0 mr-0' />
  1086. <Heading
  1087. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  1088. method='POST'
  1089. title='新增分段'
  1090. name='#create_new_segment'
  1091. />
  1092. <Row>
  1093. <Col>
  1094. ### Path
  1095. <Properties>
  1096. <Property name='dataset_id' type='string' key='dataset_id'>
  1097. 知识库 ID
  1098. </Property>
  1099. <Property name='document_id' type='string' key='document_id'>
  1100. 文档 ID
  1101. </Property>
  1102. </Properties>
  1103. ### Request Body
  1104. <Properties>
  1105. <Property name='segments' type='object list' key='segments'>
  1106. - <code>content</code> (text) 文本内容/问题内容,必填
  1107. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  1108. - <code>keywords</code> (list) 关键字,非必填
  1109. </Property>
  1110. </Properties>
  1111. </Col>
  1112. <Col sticky>
  1113. <CodeGroup
  1114. title="Request"
  1115. tag="POST"
  1116. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  1117. 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"]}]}'`}
  1118. >
  1119. ```bash {{ title: 'cURL' }}
  1120. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  1121. --header 'Authorization: Bearer {api_key}' \
  1122. --header 'Content-Type: application/json' \
  1123. --data-raw '{
  1124. "segments": [
  1125. {
  1126. "content": "1",
  1127. "answer": "1",
  1128. "keywords": ["a"]
  1129. }
  1130. ]
  1131. }'
  1132. ```
  1133. </CodeGroup>
  1134. <CodeGroup title="Response">
  1135. ```json {{ title: 'Response' }}
  1136. {
  1137. "data": [{
  1138. "id": "",
  1139. "position": 1,
  1140. "document_id": "",
  1141. "content": "1",
  1142. "answer": "1",
  1143. "word_count": 25,
  1144. "tokens": 0,
  1145. "keywords": [
  1146. "a"
  1147. ],
  1148. "index_node_id": "",
  1149. "index_node_hash": "",
  1150. "hit_count": 0,
  1151. "enabled": true,
  1152. "disabled_at": null,
  1153. "disabled_by": null,
  1154. "status": "completed",
  1155. "created_by": "",
  1156. "created_at": 1695312007,
  1157. "indexing_at": 1695312007,
  1158. "completed_at": 1695312007,
  1159. "error": null,
  1160. "stopped_at": null
  1161. }],
  1162. "doc_form": "text_model"
  1163. }
  1164. ```
  1165. </CodeGroup>
  1166. </Col>
  1167. </Row>
  1168. <hr className='ml-0 mr-0' />
  1169. <Heading
  1170. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  1171. method='GET'
  1172. title='查询文档分段'
  1173. name='#get_segment'
  1174. />
  1175. <Row>
  1176. <Col>
  1177. ### Path
  1178. <Properties>
  1179. <Property name='dataset_id' type='string' key='dataset_id'>
  1180. 知识库 ID
  1181. </Property>
  1182. <Property name='document_id' type='string' key='document_id'>
  1183. 文档 ID
  1184. </Property>
  1185. </Properties>
  1186. ### Query
  1187. <Properties>
  1188. <Property name='keyword' type='string' key='keyword'>
  1189. 搜索关键词,可选
  1190. </Property>
  1191. <Property name='status' type='string' key='status'>
  1192. 搜索状态,completed
  1193. </Property>
  1194. <Property name='page' type='string' key='page'>
  1195. 页码,可选
  1196. </Property>
  1197. <Property name='limit' type='string' key='limit'>
  1198. 返回条数,可选,默认 20,范围 1-100
  1199. </Property>
  1200. </Properties>
  1201. </Col>
  1202. <Col sticky>
  1203. <CodeGroup
  1204. title="Request"
  1205. tag="GET"
  1206. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  1207. 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'`}
  1208. >
  1209. ```bash {{ title: 'cURL' }}
  1210. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  1211. --header 'Authorization: Bearer {api_key}' \
  1212. --header 'Content-Type: application/json'
  1213. ```
  1214. </CodeGroup>
  1215. <CodeGroup title="Response">
  1216. ```json {{ title: 'Response' }}
  1217. {
  1218. "data": [{
  1219. "id": "",
  1220. "position": 1,
  1221. "document_id": "",
  1222. "content": "1",
  1223. "answer": "1",
  1224. "word_count": 25,
  1225. "tokens": 0,
  1226. "keywords": [
  1227. "a"
  1228. ],
  1229. "index_node_id": "",
  1230. "index_node_hash": "",
  1231. "hit_count": 0,
  1232. "enabled": true,
  1233. "disabled_at": null,
  1234. "disabled_by": null,
  1235. "status": "completed",
  1236. "created_by": "",
  1237. "created_at": 1695312007,
  1238. "indexing_at": 1695312007,
  1239. "completed_at": 1695312007,
  1240. "error": null,
  1241. "stopped_at": null
  1242. }],
  1243. "doc_form": "text_model",
  1244. "has_more": false,
  1245. "limit": 20,
  1246. "total": 9,
  1247. "page": 1
  1248. }
  1249. ```
  1250. </CodeGroup>
  1251. </Col>
  1252. </Row>
  1253. <hr className='ml-0 mr-0' />
  1254. <Heading
  1255. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1256. method='DELETE'
  1257. title='删除文档分段'
  1258. name='#delete_segment'
  1259. />
  1260. <Row>
  1261. <Col>
  1262. ### Path
  1263. <Properties>
  1264. <Property name='dataset_id' type='string' key='dataset_id'>
  1265. 知识库 ID
  1266. </Property>
  1267. <Property name='document_id' type='string' key='document_id'>
  1268. 文档 ID
  1269. </Property>
  1270. <Property name='segment_id' type='string' key='segment_id'>
  1271. 文档分段 ID
  1272. </Property>
  1273. </Properties>
  1274. </Col>
  1275. <Col sticky>
  1276. <CodeGroup
  1277. title="Request"
  1278. tag="DELETE"
  1279. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1280. 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'`}
  1281. >
  1282. ```bash {{ title: 'cURL' }}
  1283. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1284. --header 'Authorization: Bearer {api_key}' \
  1285. --header 'Content-Type: application/json'
  1286. ```
  1287. </CodeGroup>
  1288. <CodeGroup title="Response">
  1289. ```text {{ title: 'Response' }}
  1290. 204 No Content
  1291. ```
  1292. </CodeGroup>
  1293. </Col>
  1294. </Row>
  1295. <hr className='ml-0 mr-0' />
  1296. <Heading
  1297. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1298. method='GET'
  1299. title='查看文档分段详情'
  1300. name='#view_document_segment'
  1301. />
  1302. <Row>
  1303. <Col>
  1304. 查看指定知识库中特定文档的分段详情
  1305. ### Path
  1306. <Properties>
  1307. <Property name='dataset_id' type='string' key='dataset_id'>
  1308. 知识库 ID
  1309. </Property>
  1310. <Property name='document_id' type='string' key='document_id'>
  1311. 文档 ID
  1312. </Property>
  1313. <Property name='segment_id' type='string' key='segment_id'>
  1314. 分段 ID
  1315. </Property>
  1316. </Properties>
  1317. </Col>
  1318. <Col sticky>
  1319. <CodeGroup
  1320. title="Request"
  1321. tag="GET"
  1322. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1323. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1324. >
  1325. ```bash {{ title: 'cURL' }}
  1326. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1327. --header 'Authorization: Bearer {api_key}'
  1328. ```
  1329. </CodeGroup>
  1330. <CodeGroup title="Response">
  1331. ```json {{ title: 'Response' }}
  1332. {
  1333. "data": {
  1334. "id": "分段唯一ID",
  1335. "position": 2,
  1336. "document_id": "所属文档ID",
  1337. "content": "分段内容文本",
  1338. "sign_content": "签名内容文本",
  1339. "answer": "答案内容(如果有)",
  1340. "word_count": 470,
  1341. "tokens": 382,
  1342. "keywords": ["关键词1", "关键词2"],
  1343. "index_node_id": "索引节点ID",
  1344. "index_node_hash": "索引节点哈希值",
  1345. "hit_count": 0,
  1346. "enabled": true,
  1347. "status": "completed",
  1348. "created_by": "创建者ID",
  1349. "created_at": 创建时间戳,
  1350. "updated_at": 更新时间戳,
  1351. "indexing_at": 索引时间戳,
  1352. "completed_at": 完成时间戳,
  1353. "error": null,
  1354. "child_chunks": []
  1355. },
  1356. "doc_form": "text_model"
  1357. }
  1358. ```
  1359. </CodeGroup>
  1360. </Col>
  1361. </Row>
  1362. <hr className='ml-0 mr-0' />
  1363. <Heading
  1364. method='POST'
  1365. title='更新文档分段'
  1366. name='#update_segment'
  1367. />
  1368. <Row>
  1369. <Col>
  1370. ### POST
  1371. <Properties>
  1372. <Property name='dataset_id' type='string' key='dataset_id'>
  1373. 知识库 ID
  1374. </Property>
  1375. <Property name='document_id' type='string' key='document_id'>
  1376. 文档 ID
  1377. </Property>
  1378. <Property name='segment_id' type='string' key='segment_id'>
  1379. 文档分段 ID
  1380. </Property>
  1381. </Properties>
  1382. ### Request Body
  1383. <Properties>
  1384. <Property name='segment' type='object' key='segment'>
  1385. - <code>content</code> (text) 文本内容/问题内容,必填
  1386. - <code>answer</code> (text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
  1387. - <code>keywords</code> (list) 关键字,非必填
  1388. - <code>enabled</code> (bool) false/true,非必填
  1389. - <code>regenerate_child_chunks</code> (bool) 是否重新生成子分段,非必填
  1390. </Property>
  1391. </Properties>
  1392. </Col>
  1393. <Col sticky>
  1394. <CodeGroup
  1395. title="Request"
  1396. tag="POST"
  1397. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1398. 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}}'`}
  1399. >
  1400. ```bash {{ title: 'cURL' }}
  1401. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1402. --header 'Authorization: Bearer {api_key}' \
  1403. --header 'Content-Type: application/json' \
  1404. --data-raw '{
  1405. "segment": {
  1406. "content": "1",
  1407. "answer": "1",
  1408. "keywords": ["a"],
  1409. "enabled": false
  1410. }
  1411. }'
  1412. ```
  1413. </CodeGroup>
  1414. <CodeGroup title="Response">
  1415. ```json {{ title: 'Response' }}
  1416. {
  1417. "data": {
  1418. "id": "",
  1419. "position": 1,
  1420. "document_id": "",
  1421. "content": "1",
  1422. "answer": "1",
  1423. "word_count": 25,
  1424. "tokens": 0,
  1425. "keywords": [
  1426. "a"
  1427. ],
  1428. "index_node_id": "",
  1429. "index_node_hash": "",
  1430. "hit_count": 0,
  1431. "enabled": true,
  1432. "disabled_at": null,
  1433. "disabled_by": null,
  1434. "status": "completed",
  1435. "created_by": "",
  1436. "created_at": 1695312007,
  1437. "indexing_at": 1695312007,
  1438. "completed_at": 1695312007,
  1439. "error": null,
  1440. "stopped_at": null
  1441. },
  1442. "doc_form": "text_model"
  1443. }
  1444. ```
  1445. </CodeGroup>
  1446. </Col>
  1447. </Row>
  1448. <hr className='ml-0 mr-0' />
  1449. <Heading
  1450. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1451. method='POST'
  1452. title='新增文档子分段'
  1453. name='#create_child_chunk'
  1454. />
  1455. <Row>
  1456. <Col>
  1457. ### Path
  1458. <Properties>
  1459. <Property name='dataset_id' type='string' key='dataset_id'>
  1460. 知识库 ID
  1461. </Property>
  1462. <Property name='document_id' type='string' key='document_id'>
  1463. 文档 ID
  1464. </Property>
  1465. <Property name='segment_id' type='string' key='segment_id'>
  1466. 分段 ID
  1467. </Property>
  1468. </Properties>
  1469. ### Request Body
  1470. <Properties>
  1471. <Property name='content' type='string' key='content'>
  1472. 子分段内容
  1473. </Property>
  1474. </Properties>
  1475. </Col>
  1476. <Col sticky>
  1477. <CodeGroup
  1478. title="Request"
  1479. tag="POST"
  1480. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1481. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"content": "子分段内容"}'`}
  1482. >
  1483. ```bash {{ title: 'cURL' }}
  1484. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \
  1485. --header 'Authorization: Bearer {api_key}' \
  1486. --header 'Content-Type: application/json' \
  1487. --data-raw '{
  1488. "content": "子分段内容"
  1489. }'
  1490. ```
  1491. </CodeGroup>
  1492. <CodeGroup title="Response">
  1493. ```json {{ title: 'Response' }}
  1494. {
  1495. "data": {
  1496. "id": "",
  1497. "segment_id": "",
  1498. "content": "子分段内容",
  1499. "word_count": 25,
  1500. "tokens": 0,
  1501. "index_node_id": "",
  1502. "index_node_hash": "",
  1503. "status": "completed",
  1504. "created_by": "",
  1505. "created_at": 1695312007,
  1506. "indexing_at": 1695312007,
  1507. "completed_at": 1695312007,
  1508. "error": null,
  1509. "stopped_at": null
  1510. }
  1511. }
  1512. ```
  1513. </CodeGroup>
  1514. </Col>
  1515. </Row>
  1516. <hr className='ml-0 mr-0' />
  1517. <Heading
  1518. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1519. method='GET'
  1520. title='查询文档子分段'
  1521. name='#get_child_chunks'
  1522. />
  1523. <Row>
  1524. <Col>
  1525. ### Path
  1526. <Properties>
  1527. <Property name='dataset_id' type='string' key='dataset_id'>
  1528. 知识库 ID
  1529. </Property>
  1530. <Property name='document_id' type='string' key='document_id'>
  1531. 文档 ID
  1532. </Property>
  1533. <Property name='segment_id' type='string' key='segment_id'>
  1534. 分段 ID
  1535. </Property>
  1536. </Properties>
  1537. ### Query
  1538. <Properties>
  1539. <Property name='keyword' type='string' key='keyword'>
  1540. 搜索关键词(选填)
  1541. </Property>
  1542. <Property name='page' type='integer' key='page'>
  1543. 页码(选填,默认1)
  1544. </Property>
  1545. <Property name='limit' type='integer' key='limit'>
  1546. 每页数量(选填,默认20,最大100)
  1547. </Property>
  1548. </Properties>
  1549. </Col>
  1550. <Col sticky>
  1551. <CodeGroup
  1552. title="Request"
  1553. tag="GET"
  1554. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1555. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  1556. >
  1557. ```bash {{ title: 'cURL' }}
  1558. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \
  1559. --header 'Authorization: Bearer {api_key}'
  1560. ```
  1561. </CodeGroup>
  1562. <CodeGroup title="Response">
  1563. ```json {{ title: 'Response' }}
  1564. {
  1565. "data": [{
  1566. "id": "",
  1567. "segment_id": "",
  1568. "content": "子分段内容",
  1569. "word_count": 25,
  1570. "tokens": 0,
  1571. "index_node_id": "",
  1572. "index_node_hash": "",
  1573. "status": "completed",
  1574. "created_by": "",
  1575. "created_at": 1695312007,
  1576. "indexing_at": 1695312007,
  1577. "completed_at": 1695312007,
  1578. "error": null,
  1579. "stopped_at": null
  1580. }],
  1581. "total": 1,
  1582. "total_pages": 1,
  1583. "page": 1,
  1584. "limit": 20
  1585. }
  1586. ```
  1587. </CodeGroup>
  1588. </Col>
  1589. </Row>
  1590. <hr className='ml-0 mr-0' />
  1591. <Heading
  1592. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1593. method='DELETE'
  1594. title='删除文档子分段'
  1595. name='#delete_child_chunk'
  1596. />
  1597. <Row>
  1598. <Col>
  1599. ### Path
  1600. <Properties>
  1601. <Property name='dataset_id' type='string' key='dataset_id'>
  1602. 知识库 ID
  1603. </Property>
  1604. <Property name='document_id' type='string' key='document_id'>
  1605. 文档 ID
  1606. </Property>
  1607. <Property name='segment_id' type='string' key='segment_id'>
  1608. 分段 ID
  1609. </Property>
  1610. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1611. 子分段 ID
  1612. </Property>
  1613. </Properties>
  1614. </Col>
  1615. <Col sticky>
  1616. <CodeGroup
  1617. title="Request"
  1618. tag="DELETE"
  1619. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1620. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1621. >
  1622. ```bash {{ title: 'cURL' }}
  1623. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1624. --header 'Authorization: Bearer {api_key}'
  1625. ```
  1626. </CodeGroup>
  1627. <CodeGroup title="Response">
  1628. ```text {{ title: 'Response' }}
  1629. 204 No Content
  1630. ```
  1631. </CodeGroup>
  1632. </Col>
  1633. </Row>
  1634. <hr className='ml-0 mr-0' />
  1635. <Row>
  1636. <Col>
  1637. ### 错误信息
  1638. <Properties>
  1639. <Property name='code' type='string' key='code'>
  1640. 返回的错误代码
  1641. </Property>
  1642. </Properties>
  1643. <Properties>
  1644. <Property name='status' type='number' key='status'>
  1645. 返回的错误状态
  1646. </Property>
  1647. </Properties>
  1648. <Properties>
  1649. <Property name='message' type='string' key='message'>
  1650. 返回的错误信息
  1651. </Property>
  1652. </Properties>
  1653. </Col>
  1654. <Col>
  1655. <CodeGroup title="Example">
  1656. ```json {{ title: 'Response' }}
  1657. {
  1658. "code": "no_file_uploaded",
  1659. "message": "Please upload your file.",
  1660. "status": 400
  1661. }
  1662. ```
  1663. </CodeGroup>
  1664. </Col>
  1665. </Row>
  1666. <hr className='ml-0 mr-0' />
  1667. <Heading
  1668. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1669. method='PATCH'
  1670. title='更新文档子分段'
  1671. name='#update_child_chunk'
  1672. />
  1673. <Row>
  1674. <Col>
  1675. ### Path
  1676. <Properties>
  1677. <Property name='dataset_id' type='string' key='dataset_id'>
  1678. 知识库 ID
  1679. </Property>
  1680. <Property name='document_id' type='string' key='document_id'>
  1681. 文档 ID
  1682. </Property>
  1683. <Property name='segment_id' type='string' key='segment_id'>
  1684. 分段 ID
  1685. </Property>
  1686. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1687. 子分段 ID
  1688. </Property>
  1689. </Properties>
  1690. ### Request Body
  1691. <Properties>
  1692. <Property name='content' type='string' key='content'>
  1693. 子分段内容
  1694. </Property>
  1695. </Properties>
  1696. </Col>
  1697. <Col sticky>
  1698. <CodeGroup
  1699. title="Request"
  1700. tag="PATCH"
  1701. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1702. targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"content": "更新的子分段内容"}'`}
  1703. >
  1704. ```bash {{ title: 'cURL' }}
  1705. curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1706. --header 'Authorization: Bearer {api_key}' \
  1707. --header 'Content-Type: application/json' \
  1708. --data-raw '{
  1709. "content": "更新的子分段内容"
  1710. }'
  1711. ```
  1712. </CodeGroup>
  1713. <CodeGroup title="Response">
  1714. ```json {{ title: 'Response' }}
  1715. {
  1716. "data": {
  1717. "id": "",
  1718. "segment_id": "",
  1719. "content": "更新的子分段内容",
  1720. "word_count": 25,
  1721. "tokens": 0,
  1722. "index_node_id": "",
  1723. "index_node_hash": "",
  1724. "status": "completed",
  1725. "created_by": "",
  1726. "created_at": 1695312007,
  1727. "indexing_at": 1695312007,
  1728. "completed_at": 1695312007,
  1729. "error": null,
  1730. "stopped_at": null
  1731. }
  1732. }
  1733. ```
  1734. </CodeGroup>
  1735. </Col>
  1736. </Row>
  1737. <hr className='ml-0 mr-0' />
  1738. <Heading
  1739. url='/datasets/{dataset_id}/documents/{document_id}/upload-file'
  1740. method='GET'
  1741. title='获取上传文件'
  1742. name='#get_upload_file'
  1743. />
  1744. <Row>
  1745. <Col>
  1746. ### Path
  1747. <Properties>
  1748. <Property name='dataset_id' type='string' key='dataset_id'>
  1749. 知识库 ID
  1750. </Property>
  1751. <Property name='document_id' type='string' key='document_id'>
  1752. 文档 ID
  1753. </Property>
  1754. </Properties>
  1755. </Col>
  1756. <Col sticky>
  1757. <CodeGroup
  1758. title="Request"
  1759. tag="GET"
  1760. label="/datasets/{dataset_id}/documents/{document_id}/upload-file"
  1761. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1762. >
  1763. ```bash {{ title: 'cURL' }}
  1764. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \
  1765. --header 'Authorization: Bearer {api_key}' \
  1766. --header 'Content-Type: application/json'
  1767. ```
  1768. </CodeGroup>
  1769. <CodeGroup title="Response">
  1770. ```json {{ title: 'Response' }}
  1771. {
  1772. "id": "file_id",
  1773. "name": "file_name",
  1774. "size": 1024,
  1775. "extension": "txt",
  1776. "url": "preview_url",
  1777. "download_url": "download_url",
  1778. "mime_type": "text/plain",
  1779. "created_by": "user_id",
  1780. "created_at": 1728734540,
  1781. }
  1782. ```
  1783. </CodeGroup>
  1784. </Col>
  1785. </Row>
  1786. <hr className='ml-0 mr-0' />
  1787. <Heading
  1788. url='/datasets/{dataset_id}/retrieve'
  1789. method='POST'
  1790. title='检索知识库'
  1791. name='#dataset_retrieval'
  1792. />
  1793. <Row>
  1794. <Col>
  1795. ### Path
  1796. <Properties>
  1797. <Property name='dataset_id' type='string' key='dataset_id'>
  1798. 知识库 ID
  1799. </Property>
  1800. </Properties>
  1801. ### Request Body
  1802. <Properties>
  1803. <Property name='query' type='string' key='query'>
  1804. 检索关键词
  1805. </Property>
  1806. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1807. 检索参数(选填,如不填,按照默认方式召回)
  1808. - <code>search_method</code> (text) 检索方法:以下四个关键字之一,必填
  1809. - <code>keyword_search</code> 关键字检索
  1810. - <code>semantic_search</code> 语义检索
  1811. - <code>full_text_search</code> 全文检索
  1812. - <code>hybrid_search</code> 混合检索
  1813. - <code>reranking_enable</code> (bool) 是否启用 Reranking,非必填,如果检索模式为 semantic_search 模式或者 hybrid_search 则传值
  1814. - <code>reranking_mode</code> (object) Rerank 模型配置,非必填,如果启用了 reranking 则传值
  1815. - <code>reranking_provider_name</code> (string) Rerank 模型提供商
  1816. - <code>reranking_model_name</code> (string) Rerank 模型名称
  1817. - <code>weights</code> (float) 混合检索模式下语意检索的权重设置
  1818. - <code>top_k</code> (integer) 返回结果数量,非必填
  1819. - <code>score_threshold_enabled</code> (bool) 是否开启 score 阈值
  1820. - <code>score_threshold</code> (float) Score 阈值
  1821. - <code>metadata_filtering_conditions</code> (object) 元数据过滤条件
  1822. - <code>logical_operator</code> (string) 逻辑运算符: <code>and</code> | <code>or</code>
  1823. - <code>conditions</code> (array[object]) 条件列表
  1824. - <code>name</code> (string) 元数据字段名
  1825. - <code>comparison_operator</code> (string) 比较运算符,可选值:
  1826. - 字符串比较:
  1827. - <code>contains</code>: 包含
  1828. - <code>not contains</code>: 不包含
  1829. - <code>start with</code>: 以...开头
  1830. - <code>end with</code>: 以...结尾
  1831. - <code>is</code>: 等于
  1832. - <code>is not</code>: 不等于
  1833. - <code>empty</code>: 为空
  1834. - <code>not empty</code>: 不为空
  1835. - 数值比较:
  1836. - <code>=</code>: 等于
  1837. - <code>≠</code>: 不等于
  1838. - <code>></code>: 大于
  1839. - <code> < </code>: 小于
  1840. - <code>≥</code>: 大于等于
  1841. - <code>≤</code>: 小于等于
  1842. - 时间比较:
  1843. - <code>before</code>: 早于
  1844. - <code>after</code>: 晚于
  1845. - <code>value</code> (string|number|null) 比较值
  1846. </Property>
  1847. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1848. 未启用字段
  1849. </Property>
  1850. </Properties>
  1851. </Col>
  1852. <Col sticky>
  1853. <CodeGroup
  1854. title="Request"
  1855. tag="POST"
  1856. label="/datasets/{dataset_id}/retrieve"
  1857. 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 '{
  1858. "query": "test",
  1859. "retrieval_model": {
  1860. "search_method": "keyword_search",
  1861. "reranking_enable": false,
  1862. "reranking_mode": null,
  1863. "reranking_model": {
  1864. "reranking_provider_name": "",
  1865. "reranking_model_name": ""
  1866. },
  1867. "weights": null,
  1868. "top_k": 1,
  1869. "score_threshold_enabled": false,
  1870. "score_threshold": null,
  1871. "metadata_filtering_conditions": {
  1872. "logical_operator": "and",
  1873. "conditions": [
  1874. {
  1875. "name": "document_name",
  1876. "comparison_operator": "contains",
  1877. "value": "test"
  1878. }
  1879. ]
  1880. }
  1881. }
  1882. }'`}
  1883. >
  1884. ```bash {{ title: 'cURL' }}
  1885. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1886. --header 'Authorization: Bearer {api_key}' \
  1887. --header 'Content-Type: application/json' \
  1888. --data-raw '{
  1889. "query": "test",
  1890. "retrieval_model": {
  1891. "search_method": "keyword_search",
  1892. "reranking_enable": false,
  1893. "reranking_mode": null,
  1894. "reranking_model": {
  1895. "reranking_provider_name": "",
  1896. "reranking_model_name": ""
  1897. },
  1898. "weights": null,
  1899. "top_k": 2,
  1900. "score_threshold_enabled": false,
  1901. "score_threshold": null
  1902. }
  1903. }'
  1904. ```
  1905. </CodeGroup>
  1906. <CodeGroup title="Response">
  1907. ```json {{ title: 'Response' }}
  1908. {
  1909. "query": {
  1910. "content": "test"
  1911. },
  1912. "records": [
  1913. {
  1914. "segment": {
  1915. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1916. "position": 1,
  1917. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1918. "content": "Operation guide",
  1919. "answer": null,
  1920. "word_count": 847,
  1921. "tokens": 280,
  1922. "keywords": [
  1923. "install",
  1924. "java",
  1925. "base",
  1926. "scripts",
  1927. "jdk",
  1928. "manual",
  1929. "internal",
  1930. "opens",
  1931. "add",
  1932. "vmoptions"
  1933. ],
  1934. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1935. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1936. "hit_count": 0,
  1937. "enabled": true,
  1938. "disabled_at": null,
  1939. "disabled_by": null,
  1940. "status": "completed",
  1941. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1942. "created_at": 1728734540,
  1943. "indexing_at": 1728734552,
  1944. "completed_at": 1728734584,
  1945. "error": null,
  1946. "stopped_at": null,
  1947. "document": {
  1948. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1949. "data_source_type": "upload_file",
  1950. "name": "readme.txt",
  1951. }
  1952. },
  1953. "score": 3.730463140527718e-05,
  1954. "tsne_position": null
  1955. }
  1956. ]
  1957. }
  1958. ```
  1959. </CodeGroup>
  1960. </Col>
  1961. </Row>
  1962. <hr className='ml-0 mr-0' />
  1963. <Heading
  1964. url='/datasets/{dataset_id}/metadata'
  1965. method='POST'
  1966. title='新增元数据'
  1967. name='#create_metadata'
  1968. />
  1969. <Row>
  1970. <Col>
  1971. ### Params
  1972. <Properties>
  1973. <Property name='dataset_id' type='string' key='dataset_id'>
  1974. 知识库 ID
  1975. </Property>
  1976. </Properties>
  1977. ### Request Body
  1978. <Properties>
  1979. <Property name='segment' type='object' key='segment'>
  1980. - <code>type</code> (string) 元数据类型,必填
  1981. - <code>name</code> (string) 元数据名称,必填
  1982. </Property>
  1983. </Properties>
  1984. </Col>
  1985. <Col sticky>
  1986. <CodeGroup
  1987. title="Request"
  1988. tag="POST"
  1989. label="/datasets/{dataset_id}/metadata"
  1990. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"type": "string", "name": "test"}'`}
  1991. >
  1992. ```bash {{ title: 'cURL' }}
  1993. ```
  1994. </CodeGroup>
  1995. <CodeGroup title="Response">
  1996. ```json {{ title: 'Response' }}
  1997. {
  1998. "id": "abc",
  1999. "type": "string",
  2000. "name": "test",
  2001. }
  2002. ```
  2003. </CodeGroup>
  2004. </Col>
  2005. </Row>
  2006. <hr className='ml-0 mr-0' />
  2007. <Heading
  2008. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  2009. method='PATCH'
  2010. title='更新元数据'
  2011. name='#update_metadata'
  2012. />
  2013. <Row>
  2014. <Col>
  2015. ### Path
  2016. <Properties>
  2017. <Property name='dataset_id' type='string' key='dataset_id'>
  2018. 知识库 ID
  2019. </Property>
  2020. <Property name='metadata_id' type='string' key='metadata_id'>
  2021. 元数据 ID
  2022. </Property>
  2023. </Properties>
  2024. ### Request Body
  2025. <Properties>
  2026. <Property name='segment' type='object' key='segment'>
  2027. - <code>name</code> (string) 元数据名称,必填
  2028. </Property>
  2029. </Properties>
  2030. </Col>
  2031. <Col sticky>
  2032. <CodeGroup
  2033. title="Request"
  2034. tag="PATCH"
  2035. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  2036. targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"name": "test"}'`}
  2037. >
  2038. ```bash {{ title: 'cURL' }}
  2039. ```
  2040. </CodeGroup>
  2041. <CodeGroup title="Response">
  2042. ```json {{ title: 'Response' }}
  2043. {
  2044. "id": "abc",
  2045. "type": "string",
  2046. "name": "test",
  2047. }
  2048. ```
  2049. </CodeGroup>
  2050. </Col>
  2051. </Row>
  2052. <hr className='ml-0 mr-0' />
  2053. <Heading
  2054. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  2055. method='DELETE'
  2056. title='删除元数据'
  2057. name='#delete_metadata'
  2058. />
  2059. <Row>
  2060. <Col>
  2061. ### Path
  2062. <Properties>
  2063. <Property name='dataset_id' type='string' key='dataset_id'>
  2064. 知识库 ID
  2065. </Property>
  2066. <Property name='metadata_id' type='string' key='metadata_id'>
  2067. 元数据 ID
  2068. </Property>
  2069. </Properties>
  2070. </Col>
  2071. <Col sticky>
  2072. <CodeGroup
  2073. title="Request"
  2074. tag="DELETE"
  2075. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  2076. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  2077. >
  2078. ```bash {{ title: 'cURL' }}
  2079. ```
  2080. </CodeGroup>
  2081. </Col>
  2082. </Row>
  2083. <hr className='ml-0 mr-0' />
  2084. <Heading
  2085. url='/datasets/{dataset_id}/metadata/built-in/{action}'
  2086. method='POST'
  2087. title='启用/禁用内置元数据'
  2088. name='#toggle_metadata'
  2089. />
  2090. <Row>
  2091. <Col>
  2092. ### Path
  2093. <Properties>
  2094. <Property name='dataset_id' type='string' key='dataset_id'>
  2095. 知识库 ID
  2096. </Property>
  2097. <Property name='action' type='string' key='action'>
  2098. disable/enable
  2099. </Property>
  2100. </Properties>
  2101. </Col>
  2102. <Col sticky>
  2103. <CodeGroup
  2104. title="Request"
  2105. tag="POST"
  2106. label="/datasets/{dataset_id}/metadata/built-in/{action}"
  2107. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
  2108. >
  2109. ```bash {{ title: 'cURL' }}
  2110. ```
  2111. </CodeGroup>
  2112. </Col>
  2113. </Row>
  2114. <hr className='ml-0 mr-0' />
  2115. <Heading
  2116. url='/datasets/{dataset_id}/documents/metadata'
  2117. method='POST'
  2118. title='更新文档元数据'
  2119. name='#update_documents_metadata'
  2120. />
  2121. <Row>
  2122. <Col>
  2123. ### Path
  2124. <Properties>
  2125. <Property name='dataset_id' type='string' key='dataset_id'>
  2126. 知识库 ID
  2127. </Property>
  2128. </Properties>
  2129. ### Request Body
  2130. <Properties>
  2131. <Property name='operation_data' type='object list' key='segments'>
  2132. - <code>document_id</code> (string) 文档 ID
  2133. - <code>metadata_list</code> (list) 元数据列表
  2134. - <code>id</code> (string) 元数据 ID
  2135. - <code>value</code> (string) 元数据值
  2136. - <code>name</code> (string) 元数据名称
  2137. </Property>
  2138. </Properties>
  2139. </Col>
  2140. <Col sticky>
  2141. <CodeGroup
  2142. title="Request"
  2143. tag="POST"
  2144. label="/datasets/{dataset_id}/documents/metadata"
  2145. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"operation_data": [{"document_id": "document_id", "metadata_list": [{"id": "id", "value": "value", "name": "name"}]}]}'`}
  2146. >
  2147. ```bash {{ title: 'cURL' }}
  2148. ```
  2149. </CodeGroup>
  2150. </Col>
  2151. </Row>
  2152. <hr className='ml-0 mr-0' />
  2153. <Heading
  2154. url='/datasets/{dataset_id}/metadata'
  2155. method='GET'
  2156. title='查询知识库元数据列表'
  2157. name='#dataset_metadata_list'
  2158. />
  2159. <Row>
  2160. <Col>
  2161. ### Path
  2162. <Properties>
  2163. <Property name='dataset_id' type='string' key='dataset_id'>
  2164. 知识库 ID
  2165. </Property>
  2166. </Properties>
  2167. </Col>
  2168. <Col sticky>
  2169. <CodeGroup
  2170. title="Request"
  2171. tag="GET"
  2172. label="/datasets/{dataset_id}/metadata"
  2173. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
  2174. >
  2175. ```bash {{ title: 'cURL' }}
  2176. ```
  2177. </CodeGroup>
  2178. <CodeGroup title="Response">
  2179. ```json {{ title: 'Response' }}
  2180. {
  2181. "doc_metadata": [
  2182. {
  2183. "id": "",
  2184. "name": "name",
  2185. "type": "string",
  2186. "use_count": 0,
  2187. },
  2188. ...
  2189. ],
  2190. "built_in_field_enabled": true
  2191. }
  2192. ```
  2193. </CodeGroup>
  2194. </Col>
  2195. </Row>
  2196. <hr className='ml-0 mr-0' />
  2197. <Heading
  2198. url='/workspaces/current/models/model-types/text-embedding'
  2199. method='GET'
  2200. title='获取嵌入模型列表'
  2201. name='#model_type_list'
  2202. />
  2203. <Row>
  2204. <Col>
  2205. ### Query
  2206. <Properties>
  2207. </Properties>
  2208. </Col>
  2209. <Col sticky>
  2210. <CodeGroup
  2211. title="Request"
  2212. tag="GET"
  2213. label="/datasets/{dataset_id}"
  2214. targetCode={`curl --location --location --request GET '${props.apiBaseUrl}/workspaces/current/models/model-types/text-embedding' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' `}
  2215. >
  2216. ```bash {{ title: 'cURL' }}
  2217. curl --location --request GET '${props.apiBaseUrl}/workspaces/current/models/model-types/text-embedding' \
  2218. --header 'Authorization: Bearer {api_key}' \
  2219. --header 'Content-Type: application/json' \
  2220. ```
  2221. </CodeGroup>
  2222. <CodeGroup title="Response">
  2223. ```json {{ title: 'Response' }}
  2224. {
  2225. "data": [
  2226. {
  2227. "provider": "zhipuai",
  2228. "label": {
  2229. "zh_Hans": "智谱 AI",
  2230. "en_US": "ZHIPU AI"
  2231. },
  2232. "icon_small": {
  2233. "zh_Hans": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/zh_Hans",
  2234. "en_US": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/en_US"
  2235. },
  2236. "icon_large": {
  2237. "zh_Hans": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/zh_Hans",
  2238. "en_US": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/en_US"
  2239. },
  2240. "status": "active",
  2241. "models": [
  2242. {
  2243. "model": "embedding-3",
  2244. "label": {
  2245. "zh_Hans": "embedding-3",
  2246. "en_US": "embedding-3"
  2247. },
  2248. "model_type": "text-embedding",
  2249. "features": null,
  2250. "fetch_from": "predefined-model",
  2251. "model_properties": {
  2252. "context_size": 8192
  2253. },
  2254. "deprecated": false,
  2255. "status": "active",
  2256. "load_balancing_enabled": false
  2257. },
  2258. {
  2259. "model": "embedding-2",
  2260. "label": {
  2261. "zh_Hans": "embedding-2",
  2262. "en_US": "embedding-2"
  2263. },
  2264. "model_type": "text-embedding",
  2265. "features": null,
  2266. "fetch_from": "predefined-model",
  2267. "model_properties": {
  2268. "context_size": 8192
  2269. },
  2270. "deprecated": false,
  2271. "status": "active",
  2272. "load_balancing_enabled": false
  2273. },
  2274. {
  2275. "model": "text_embedding",
  2276. "label": {
  2277. "zh_Hans": "text_embedding",
  2278. "en_US": "text_embedding"
  2279. },
  2280. "model_type": "text-embedding",
  2281. "features": null,
  2282. "fetch_from": "predefined-model",
  2283. "model_properties": {
  2284. "context_size": 512
  2285. },
  2286. "deprecated": false,
  2287. "status": "active",
  2288. "load_balancing_enabled": false
  2289. }
  2290. ]
  2291. }
  2292. ]
  2293. }
  2294. ```
  2295. </CodeGroup>
  2296. </Col>
  2297. </Row>
  2298. <hr className='ml-0 mr-0' />
  2299. <Heading
  2300. url='/datasets/tags'
  2301. method='POST'
  2302. title='新增知识库类型标签'
  2303. name='#create_new_knowledge_tag'
  2304. />
  2305. <Row>
  2306. <Col>
  2307. ### Request Body
  2308. <Properties>
  2309. <Property name='name' type='string'>
  2310. (text) 新标签名称,必填,最大长度为 50
  2311. </Property>
  2312. </Properties>
  2313. </Col>
  2314. <Col sticky>
  2315. <CodeGroup
  2316. title="Request"
  2317. tag="POST"
  2318. label="/datasets/tags"
  2319. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "testtag1"}'`}
  2320. >
  2321. ```bash {{ title: 'cURL' }}
  2322. curl --location --request POST '${props.apiBaseUrl}/datasets/tags' \
  2323. --header 'Authorization: Bearer {api_key}' \
  2324. --header 'Content-Type: application/json' \
  2325. --data-raw '{"name": "testtag1"}'
  2326. ```
  2327. </CodeGroup>
  2328. <CodeGroup title="Response">
  2329. ```json {{ title: 'Response' }}
  2330. {
  2331. "id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
  2332. "name": "testtag1",
  2333. "type": "knowledge",
  2334. "binding_count": 0
  2335. }
  2336. ```
  2337. </CodeGroup>
  2338. </Col>
  2339. </Row>
  2340. <hr className='ml-0 mr-0' />
  2341. <Heading
  2342. url='/datasets/tags'
  2343. method='GET'
  2344. title='获取知识库类型标签'
  2345. name='#get_knowledge_type_tags'
  2346. />
  2347. <Row>
  2348. <Col>
  2349. ### Request Body
  2350. </Col>
  2351. <Col sticky>
  2352. <CodeGroup
  2353. title="Request"
  2354. tag="GET"
  2355. label="/datasets/tags"
  2356. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  2357. >
  2358. ```bash {{ title: 'cURL' }}
  2359. curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \
  2360. --header 'Authorization: Bearer {api_key}' \
  2361. --header 'Content-Type: application/json'
  2362. ```
  2363. </CodeGroup>
  2364. <CodeGroup title="Response">
  2365. ```json {{ title: 'Response' }}
  2366. [
  2367. {
  2368. "id": "39d6934c-ed36-463d-b4a7-377fa1503dc0",
  2369. "name": "testtag1",
  2370. "type": "knowledge",
  2371. "binding_count": "0"
  2372. },
  2373. ...
  2374. ]
  2375. ```
  2376. </CodeGroup>
  2377. </Col>
  2378. </Row>
  2379. <hr className='ml-0 mr-0' />
  2380. <Heading
  2381. url='/datasets/tags'
  2382. method='PATCH'
  2383. title='修改知识库类型标签名称'
  2384. name='#modify_knowledge_tag_name'
  2385. />
  2386. <Row>
  2387. <Col>
  2388. ### Request Body
  2389. <Properties>
  2390. <Property name='name' type='string'>
  2391. (text) 修改后的标签名称,必填,最大长度为 50
  2392. </Property>
  2393. <Property name='tag_id' type='string'>
  2394. (text) 标签 ID,必填
  2395. </Property>
  2396. </Properties>
  2397. </Col>
  2398. <Col sticky>
  2399. <CodeGroup
  2400. title="Request"
  2401. tag="PATCH"
  2402. label="/datasets/tags"
  2403. targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "testtag2", "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}`}
  2404. >
  2405. ```bash {{ title: 'cURL' }}
  2406. curl --location --request PATCH '${props.apiBaseUrl}/datasets/tags' \
  2407. --header 'Authorization: Bearer {api_key}' \
  2408. --header 'Content-Type: application/json' \
  2409. --data-raw '{"name": "testtag2", "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
  2410. ```
  2411. </CodeGroup>
  2412. <CodeGroup title="Response">
  2413. ```json {{ title: 'Response' }}
  2414. {
  2415. "id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
  2416. "name": "tag-renamed",
  2417. "type": "knowledge",
  2418. "binding_count": 0
  2419. }
  2420. ```
  2421. </CodeGroup>
  2422. </Col>
  2423. </Row>
  2424. <hr className='ml-0 mr-0' />
  2425. <Heading
  2426. url='/datasets/tags'
  2427. method='DELETE'
  2428. title='删除知识库类型标签'
  2429. name='#delete_knowledge_tag'
  2430. />
  2431. <Row>
  2432. <Col>
  2433. ### Request Body
  2434. <Properties>
  2435. <Property name='tag_id' type='string'>
  2436. (text) 标签 ID,必填
  2437. </Property>
  2438. </Properties>
  2439. </Col>
  2440. <Col sticky>
  2441. <CodeGroup
  2442. title="Request"
  2443. tag="DELETE"
  2444. label="/datasets/tags"
  2445. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}`}
  2446. >
  2447. ```bash {{ title: 'cURL' }}
  2448. curl --location --request DELETE '${props.apiBaseUrl}/datasets/tags' \
  2449. --header 'Authorization: Bearer {api_key}' \
  2450. --header 'Content-Type: application/json' \
  2451. --data-raw '{"tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
  2452. ```
  2453. </CodeGroup>
  2454. <CodeGroup title="Response">
  2455. ```json {{ title: 'Response' }}
  2456. {"result": "success"}
  2457. ```
  2458. </CodeGroup>
  2459. </Col>
  2460. </Row>
  2461. <hr className='ml-0 mr-0' />
  2462. <Heading
  2463. url='/datasets/tags/binding'
  2464. method='POST'
  2465. title='绑定知识库到知识库类型标签'
  2466. name='#bind_dataset_to_knowledge_tag'
  2467. />
  2468. <Row>
  2469. <Col>
  2470. ### Request Body
  2471. <Properties>
  2472. <Property name='tag_ids' type='list'>
  2473. (list) 标签 ID 列表,必填
  2474. </Property>
  2475. <Property name='target_id' type='string'>
  2476. (text) 知识库 ID,必填
  2477. </Property>
  2478. </Properties>
  2479. </Col>
  2480. <Col sticky>
  2481. <CodeGroup
  2482. title="Request"
  2483. tag="POST"
  2484. label="/datasets/tags/binding"
  2485. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags/binding' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"tag_ids": ["65cc29be-d072-4e26-adf4-2f727644da29","1e5348f3-d3ff-42b8-a1b7-0a86d518001a"], "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'`}
  2486. >
  2487. ```bash {{ title: 'cURL' }}
  2488. curl --location --request POST '${props.apiBaseUrl}/datasets/tags/binding' \
  2489. --header 'Authorization: Bearer {api_key}' \
  2490. --header 'Content-Type: application/json' \
  2491. --data-raw '{"tag_ids": ["65cc29be-d072-4e26-adf4-2f727644da29","1e5348f3-d3ff-42b8-a1b7-0a86d518001a"], "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
  2492. ```
  2493. </CodeGroup>
  2494. <CodeGroup title="Response">
  2495. ```json {{ title: 'Response' }}
  2496. {"result": "success"}
  2497. ```
  2498. </CodeGroup>
  2499. </Col>
  2500. </Row>
  2501. <hr className='ml-0 mr-0' />
  2502. <Heading
  2503. url='/datasets/tags/unbinding'
  2504. method='POST'
  2505. title='解绑知识库和知识库类型标签'
  2506. name='#unbind_dataset_and_knowledge_tag'
  2507. />
  2508. <Row>
  2509. <Col>
  2510. ### Request Body
  2511. <Properties>
  2512. <Property name='tag_id' type='string'>
  2513. (text) 标签 ID,必填
  2514. </Property>
  2515. <Property name='target_id' type='string'>
  2516. (text) 知识库 ID,必填
  2517. </Property>
  2518. </Properties>
  2519. </Col>
  2520. <Col sticky>
  2521. <CodeGroup
  2522. title="Request"
  2523. tag="POST"
  2524. label="/datasets/tags/unbinding"
  2525. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags/unbinding' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"tag_id": "1e5348f3-d3ff-42b8-a1b7-0a86d518001a", "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'`}
  2526. >
  2527. ```bash {{ title: 'cURL' }}
  2528. curl --location --request POST '${props.apiBaseUrl}/datasets/tags/unbinding' \
  2529. --header 'Authorization: Bearer {api_key}' \
  2530. --header 'Content-Type: application/json' \
  2531. --data-raw '{"tag_id": "1e5348f3-d3ff-42b8-a1b7-0a86d518001a", "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
  2532. ```
  2533. </CodeGroup>
  2534. <CodeGroup title="Response">
  2535. ```json {{ title: 'Response' }}
  2536. {"result": "success"}
  2537. ```
  2538. </CodeGroup>
  2539. </Col>
  2540. </Row>
  2541. <hr className='ml-0 mr-0' />
  2542. <Heading
  2543. url='/datasets/<uuid:dataset_id>/tags'
  2544. method='POST'
  2545. title='查询知识库已绑定的标签'
  2546. name='#query_dataset_tags'
  2547. />
  2548. <Row>
  2549. <Col>
  2550. ### Path
  2551. <Properties>
  2552. <Property name='dataset_id' type='string'>
  2553. (text) 知识库 ID
  2554. </Property>
  2555. </Properties>
  2556. </Col>
  2557. <Col sticky>
  2558. <CodeGroup
  2559. title="Request"
  2560. tag="POST"
  2561. label="/datasets/<uuid:dataset_id>/tags"
  2562. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/<uuid:dataset_id>/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n`}
  2563. >
  2564. ```bash {{ title: 'cURL' }}
  2565. curl --location --request POST '${props.apiBaseUrl}/datasets/<uuid:dataset_id>/tags' \
  2566. --header 'Authorization: Bearer {api_key}' \
  2567. --header 'Content-Type: application/json' \
  2568. ```
  2569. </CodeGroup>
  2570. <CodeGroup title="Response">
  2571. ```json {{ title: 'Response' }}
  2572. {
  2573. "data":
  2574. [
  2575. {"id": "4a601f4f-f8a2-4166-ae7c-58c3b252a524",
  2576. "name": "123"
  2577. },
  2578. ...
  2579. ],
  2580. "total": 3
  2581. }
  2582. ```
  2583. </CodeGroup>
  2584. </Col>
  2585. </Row>
  2586. <hr className='ml-0 mr-0' />
  2587. <Row>
  2588. <Col>
  2589. ### 错误信息
  2590. <Properties>
  2591. <Property name='code' type='string' key='code'>
  2592. 返回的错误代码
  2593. </Property>
  2594. </Properties>
  2595. <Properties>
  2596. <Property name='status' type='number' key='status'>
  2597. 返回的错误状态
  2598. </Property>
  2599. </Properties>
  2600. <Properties>
  2601. <Property name='message' type='string' key='message'>
  2602. 返回的错误信息
  2603. </Property>
  2604. </Properties>
  2605. </Col>
  2606. <Col>
  2607. <CodeGroup title="Example">
  2608. ```json {{ title: 'Response' }}
  2609. {
  2610. "code": "no_file_uploaded",
  2611. "message": "Please upload your file.",
  2612. "status": 400
  2613. }
  2614. ```
  2615. </CodeGroup>
  2616. </Col>
  2617. </Row>
  2618. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  2619. <thead style={{ background: '#f9fafc' }}>
  2620. <tr>
  2621. <th className="p-2 border border-slate-300">code</th>
  2622. <th className="p-2 border border-slate-300">status</th>
  2623. <th className="p-2 border border-slate-300">message</th>
  2624. </tr>
  2625. </thead>
  2626. <tbody>
  2627. <tr>
  2628. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  2629. <td className="p-2 border border-slate-300">400</td>
  2630. <td className="p-2 border border-slate-300">Please upload your file.</td>
  2631. </tr>
  2632. <tr>
  2633. <td className="p-2 border border-slate-300">too_many_files</td>
  2634. <td className="p-2 border border-slate-300">400</td>
  2635. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  2636. </tr>
  2637. <tr>
  2638. <td className="p-2 border border-slate-300">file_too_large</td>
  2639. <td className="p-2 border border-slate-300">413</td>
  2640. <td className="p-2 border border-slate-300">File size exceeded.</td>
  2641. </tr>
  2642. <tr>
  2643. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  2644. <td className="p-2 border border-slate-300">415</td>
  2645. <td className="p-2 border border-slate-300">File type not allowed.</td>
  2646. </tr>
  2647. <tr>
  2648. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  2649. <td className="p-2 border border-slate-300">400</td>
  2650. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  2651. </tr>
  2652. <tr>
  2653. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  2654. <td className="p-2 border border-slate-300">400</td>
  2655. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  2656. </tr>
  2657. <tr>
  2658. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  2659. <td className="p-2 border border-slate-300">403</td>
  2660. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  2661. </tr>
  2662. <tr>
  2663. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  2664. <td className="p-2 border border-slate-300">409</td>
  2665. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  2666. </tr>
  2667. <tr>
  2668. <td className="p-2 border border-slate-300">invalid_action</td>
  2669. <td className="p-2 border border-slate-300">400</td>
  2670. <td className="p-2 border border-slate-300">Invalid action.</td>
  2671. </tr>
  2672. <tr>
  2673. <td className="p-2 border border-slate-300">document_already_finished</td>
  2674. <td className="p-2 border border-slate-300">400</td>
  2675. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  2676. </tr>
  2677. <tr>
  2678. <td className="p-2 border border-slate-300">document_indexing</td>
  2679. <td className="p-2 border border-slate-300">400</td>
  2680. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  2681. </tr>
  2682. <tr>
  2683. <td className="p-2 border border-slate-300">invalid_metadata</td>
  2684. <td className="p-2 border border-slate-300">400</td>
  2685. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  2686. </tr>
  2687. </tbody>
  2688. </table>
  2689. <div className="pb-4" />