Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

template.en.mdx 94KB

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