You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

template.zh.mdx 83KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498
  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>type</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. <Row>
  2300. <Col>
  2301. ### 错误信息
  2302. <Properties>
  2303. <Property name='code' type='string' key='code'>
  2304. 返回的错误代码
  2305. </Property>
  2306. </Properties>
  2307. <Properties>
  2308. <Property name='status' type='number' key='status'>
  2309. 返回的错误状态
  2310. </Property>
  2311. </Properties>
  2312. <Properties>
  2313. <Property name='message' type='string' key='message'>
  2314. 返回的错误信息
  2315. </Property>
  2316. </Properties>
  2317. </Col>
  2318. <Col>
  2319. <CodeGroup title="Example">
  2320. ```json {{ title: 'Response' }}
  2321. {
  2322. "code": "no_file_uploaded",
  2323. "message": "Please upload your file.",
  2324. "status": 400
  2325. }
  2326. ```
  2327. </CodeGroup>
  2328. </Col>
  2329. </Row>
  2330. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  2331. <thead style={{ background: '#f9fafc' }}>
  2332. <tr>
  2333. <th className="p-2 border border-slate-300">code</th>
  2334. <th className="p-2 border border-slate-300">status</th>
  2335. <th className="p-2 border border-slate-300">message</th>
  2336. </tr>
  2337. </thead>
  2338. <tbody>
  2339. <tr>
  2340. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  2341. <td className="p-2 border border-slate-300">400</td>
  2342. <td className="p-2 border border-slate-300">Please upload your file.</td>
  2343. </tr>
  2344. <tr>
  2345. <td className="p-2 border border-slate-300">too_many_files</td>
  2346. <td className="p-2 border border-slate-300">400</td>
  2347. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  2348. </tr>
  2349. <tr>
  2350. <td className="p-2 border border-slate-300">file_too_large</td>
  2351. <td className="p-2 border border-slate-300">413</td>
  2352. <td className="p-2 border border-slate-300">File size exceeded.</td>
  2353. </tr>
  2354. <tr>
  2355. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  2356. <td className="p-2 border border-slate-300">415</td>
  2357. <td className="p-2 border border-slate-300">File type not allowed.</td>
  2358. </tr>
  2359. <tr>
  2360. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  2361. <td className="p-2 border border-slate-300">400</td>
  2362. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  2363. </tr>
  2364. <tr>
  2365. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  2366. <td className="p-2 border border-slate-300">400</td>
  2367. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  2368. </tr>
  2369. <tr>
  2370. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  2371. <td className="p-2 border border-slate-300">403</td>
  2372. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  2373. </tr>
  2374. <tr>
  2375. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  2376. <td className="p-2 border border-slate-300">409</td>
  2377. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  2378. </tr>
  2379. <tr>
  2380. <td className="p-2 border border-slate-300">invalid_action</td>
  2381. <td className="p-2 border border-slate-300">400</td>
  2382. <td className="p-2 border border-slate-300">Invalid action.</td>
  2383. </tr>
  2384. <tr>
  2385. <td className="p-2 border border-slate-300">document_already_finished</td>
  2386. <td className="p-2 border border-slate-300">400</td>
  2387. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  2388. </tr>
  2389. <tr>
  2390. <td className="p-2 border border-slate-300">document_indexing</td>
  2391. <td className="p-2 border border-slate-300">400</td>
  2392. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  2393. </tr>
  2394. <tr>
  2395. <td className="p-2 border border-slate-300">invalid_metadata</td>
  2396. <td className="p-2 border border-slate-300">400</td>
  2397. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  2398. </tr>
  2399. </tbody>
  2400. </table>
  2401. <div className="pb-4" />