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

template.en.mdx 92KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765
  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/{document_id}/segments'
  1082. method='POST'
  1083. title='Add Chunks to a Document'
  1084. name='#create_new_segment'
  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='document_id' type='string' key='document_id'>
  1094. Document ID
  1095. </Property>
  1096. </Properties>
  1097. ### Request Body
  1098. <Properties>
  1099. <Property name='segments' type='object list' key='segments'>
  1100. - <code>content</code> (text) Text content / question content, required
  1101. - <code>answer</code> (text) Answer content, if the mode of the knowledge is Q&A mode, pass the value (optional)
  1102. - <code>keywords</code> (list) Keywords (optional)
  1103. </Property>
  1104. </Properties>
  1105. </Col>
  1106. <Col sticky>
  1107. <CodeGroup
  1108. title="Request"
  1109. tag="POST"
  1110. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  1111. 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"]}]}'`}
  1112. >
  1113. ```bash {{ title: 'cURL' }}
  1114. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  1115. --header 'Authorization: Bearer {api_key}' \
  1116. --header 'Content-Type: application/json' \
  1117. --data-raw '{
  1118. "segments": [
  1119. {
  1120. "content": "1",
  1121. "answer": "1",
  1122. "keywords": ["a"]
  1123. }
  1124. ]
  1125. }'
  1126. ```
  1127. </CodeGroup>
  1128. <CodeGroup title="Response">
  1129. ```json {{ title: 'Response' }}
  1130. {
  1131. "data": [{
  1132. "id": "",
  1133. "position": 1,
  1134. "document_id": "",
  1135. "content": "1",
  1136. "answer": "1",
  1137. "word_count": 25,
  1138. "tokens": 0,
  1139. "keywords": [
  1140. "a"
  1141. ],
  1142. "index_node_id": "",
  1143. "index_node_hash": "",
  1144. "hit_count": 0,
  1145. "enabled": true,
  1146. "disabled_at": null,
  1147. "disabled_by": null,
  1148. "status": "completed",
  1149. "created_by": "",
  1150. "created_at": 1695312007,
  1151. "indexing_at": 1695312007,
  1152. "completed_at": 1695312007,
  1153. "error": null,
  1154. "stopped_at": null
  1155. }],
  1156. "doc_form": "text_model"
  1157. }
  1158. ```
  1159. </CodeGroup>
  1160. </Col>
  1161. </Row>
  1162. <hr className='ml-0 mr-0' />
  1163. <Heading
  1164. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  1165. method='GET'
  1166. title='Get Chunks from a Document'
  1167. name='#get_segment'
  1168. />
  1169. <Row>
  1170. <Col>
  1171. ### Path
  1172. <Properties>
  1173. <Property name='dataset_id' type='string' key='dataset_id'>
  1174. Knowledge ID
  1175. </Property>
  1176. <Property name='document_id' type='string' key='document_id'>
  1177. Document ID
  1178. </Property>
  1179. </Properties>
  1180. ### Query
  1181. <Properties>
  1182. <Property name='keyword' type='string' key='keyword'>
  1183. Keyword (optional)
  1184. </Property>
  1185. <Property name='status' type='string' key='status'>
  1186. Search status, completed
  1187. </Property>
  1188. <Property name='page' type='string' key='page'>
  1189. Page number (optional)
  1190. </Property>
  1191. <Property name='limit' type='string' key='limit'>
  1192. Number of items returned, default 20, range 1-100 (optional)
  1193. </Property>
  1194. </Properties>
  1195. </Col>
  1196. <Col sticky>
  1197. <CodeGroup
  1198. title="Request"
  1199. tag="GET"
  1200. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  1201. 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'`}
  1202. >
  1203. ```bash {{ title: 'cURL' }}
  1204. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  1205. --header 'Authorization: Bearer {api_key}' \
  1206. --header 'Content-Type: application/json'
  1207. ```
  1208. </CodeGroup>
  1209. <CodeGroup title="Response">
  1210. ```json {{ title: 'Response' }}
  1211. {
  1212. "data": [{
  1213. "id": "",
  1214. "position": 1,
  1215. "document_id": "",
  1216. "content": "1",
  1217. "answer": "1",
  1218. "word_count": 25,
  1219. "tokens": 0,
  1220. "keywords": [
  1221. "a"
  1222. ],
  1223. "index_node_id": "",
  1224. "index_node_hash": "",
  1225. "hit_count": 0,
  1226. "enabled": true,
  1227. "disabled_at": null,
  1228. "disabled_by": null,
  1229. "status": "completed",
  1230. "created_by": "",
  1231. "created_at": 1695312007,
  1232. "indexing_at": 1695312007,
  1233. "completed_at": 1695312007,
  1234. "error": null,
  1235. "stopped_at": null
  1236. }],
  1237. "doc_form": "text_model",
  1238. "has_more": false,
  1239. "limit": 20,
  1240. "total": 9,
  1241. "page": 1
  1242. }
  1243. ```
  1244. </CodeGroup>
  1245. </Col>
  1246. </Row>
  1247. <hr className='ml-0 mr-0' />
  1248. <Heading
  1249. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1250. method='GET'
  1251. title='Get a Chunk Details in a Document'
  1252. name='#view_document_chunk'
  1253. />
  1254. <Row>
  1255. <Col>
  1256. Get details of a specific document segment in the specified knowledge base
  1257. ### Path
  1258. <Properties>
  1259. <Property name='dataset_id' type='string' key='dataset_id'>
  1260. Knowledge Base ID
  1261. </Property>
  1262. <Property name='document_id' type='string' key='document_id'>
  1263. Document ID
  1264. </Property>
  1265. <Property name='segment_id' type='string' key='segment_id'>
  1266. Segment ID
  1267. </Property>
  1268. </Properties>
  1269. </Col>
  1270. <Col sticky>
  1271. <CodeGroup
  1272. title="Request"
  1273. tag="GET"
  1274. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1275. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1276. >
  1277. ```bash {{ title: 'cURL' }}
  1278. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1279. --header 'Authorization: Bearer {api_key}'
  1280. ```
  1281. </CodeGroup>
  1282. <CodeGroup title="Response">
  1283. ```json {{ title: 'Response' }}
  1284. {
  1285. "data": {
  1286. "id": "chunk_id",
  1287. "position": 2,
  1288. "document_id": "document_id",
  1289. "content": "Segment content text",
  1290. "sign_content": "Signature content text",
  1291. "answer": "Answer content (if in Q&A mode)",
  1292. "word_count": 470,
  1293. "tokens": 382,
  1294. "keywords": ["keyword1", "keyword2"],
  1295. "index_node_id": "index_node_id",
  1296. "index_node_hash": "index_node_hash",
  1297. "hit_count": 0,
  1298. "enabled": true,
  1299. "status": "completed",
  1300. "created_by": "creator_id",
  1301. "created_at": creation_timestamp,
  1302. "updated_at": update_timestamp,
  1303. "indexing_at": indexing_timestamp,
  1304. "completed_at": completion_timestamp,
  1305. "error": null,
  1306. "child_chunks": []
  1307. },
  1308. "doc_form": "text_model"
  1309. }
  1310. ```
  1311. </CodeGroup>
  1312. </Col>
  1313. </Row>
  1314. <hr className='ml-0 mr-0' />
  1315. <Heading
  1316. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1317. method='DELETE'
  1318. title='Delete a Chunk in a Document'
  1319. name='#delete_segment'
  1320. />
  1321. <Row>
  1322. <Col>
  1323. ### Path
  1324. <Properties>
  1325. <Property name='dataset_id' type='string' key='dataset_id'>
  1326. Knowledge ID
  1327. </Property>
  1328. <Property name='document_id' type='string' key='document_id'>
  1329. Document ID
  1330. </Property>
  1331. <Property name='segment_id' type='string' key='segment_id'>
  1332. Document Segment ID
  1333. </Property>
  1334. </Properties>
  1335. </Col>
  1336. <Col sticky>
  1337. <CodeGroup
  1338. title="Request"
  1339. tag="DELETE"
  1340. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1341. 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'`}
  1342. >
  1343. ```bash {{ title: 'cURL' }}
  1344. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1345. --header 'Authorization: Bearer {api_key}' \
  1346. --header 'Content-Type: application/json'
  1347. ```
  1348. </CodeGroup>
  1349. <CodeGroup title="Response">
  1350. ```text {{ title: 'Response' }}
  1351. 204 No Content
  1352. ```
  1353. </CodeGroup>
  1354. </Col>
  1355. </Row>
  1356. <hr className='ml-0 mr-0' />
  1357. <Heading
  1358. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1359. method='POST'
  1360. title='Update a Chunk in a Document'
  1361. name='#update_segment'
  1362. />
  1363. <Row>
  1364. <Col>
  1365. ### POST
  1366. <Properties>
  1367. <Property name='dataset_id' type='string' key='dataset_id'>
  1368. Knowledge ID
  1369. </Property>
  1370. <Property name='document_id' type='string' key='document_id'>
  1371. Document ID
  1372. </Property>
  1373. <Property name='segment_id' type='string' key='segment_id'>
  1374. Document Segment ID
  1375. </Property>
  1376. </Properties>
  1377. ### Request Body
  1378. <Properties>
  1379. <Property name='segment' type='object' key='segment'>
  1380. - <code>content</code> (text) Text content / question content, required
  1381. - <code>answer</code> (text) Answer content, passed if the knowledge is in Q&A mode (optional)
  1382. - <code>keywords</code> (list) Keyword (optional)
  1383. - <code>enabled</code> (bool) False / true (optional)
  1384. - <code>regenerate_child_chunks</code> (bool) Whether to regenerate child chunks (optional)
  1385. </Property>
  1386. </Properties>
  1387. </Col>
  1388. <Col sticky>
  1389. <CodeGroup
  1390. title="Request"
  1391. tag="POST"
  1392. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1393. 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}}'`}
  1394. >
  1395. ```bash {{ title: 'cURL' }}
  1396. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1397. --header 'Content-Type: application/json' \
  1398. --data-raw '{
  1399. "segment": {
  1400. "content": "1",
  1401. "answer": "1",
  1402. "keywords": ["a"],
  1403. "enabled": false
  1404. }
  1405. }'
  1406. ```
  1407. </CodeGroup>
  1408. <CodeGroup title="Response">
  1409. ```json {{ title: 'Response' }}
  1410. {
  1411. "data": {
  1412. "id": "",
  1413. "position": 1,
  1414. "document_id": "",
  1415. "content": "1",
  1416. "answer": "1",
  1417. "word_count": 25,
  1418. "tokens": 0,
  1419. "keywords": [
  1420. "a"
  1421. ],
  1422. "index_node_id": "",
  1423. "index_node_hash": "",
  1424. "hit_count": 0,
  1425. "enabled": true,
  1426. "disabled_at": null,
  1427. "disabled_by": null,
  1428. "status": "completed",
  1429. "created_by": "",
  1430. "created_at": 1695312007,
  1431. "indexing_at": 1695312007,
  1432. "completed_at": 1695312007,
  1433. "error": null,
  1434. "stopped_at": null
  1435. },
  1436. "doc_form": "text_model"
  1437. }
  1438. ```
  1439. </CodeGroup>
  1440. </Col>
  1441. </Row>
  1442. <hr className='ml-0 mr-0' />
  1443. <Heading
  1444. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1445. method='POST'
  1446. title='Create Child Chunk'
  1447. name='#create_child_chunk'
  1448. />
  1449. <Row>
  1450. <Col>
  1451. ### Path
  1452. <Properties>
  1453. <Property name='dataset_id' type='string' key='dataset_id'>
  1454. Knowledge ID
  1455. </Property>
  1456. <Property name='document_id' type='string' key='document_id'>
  1457. Document ID
  1458. </Property>
  1459. <Property name='segment_id' type='string' key='segment_id'>
  1460. Segment ID
  1461. </Property>
  1462. </Properties>
  1463. ### Request Body
  1464. <Properties>
  1465. <Property name='content' type='string' key='content'>
  1466. Child chunk content
  1467. </Property>
  1468. </Properties>
  1469. </Col>
  1470. <Col sticky>
  1471. <CodeGroup
  1472. title="Request"
  1473. tag="POST"
  1474. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1475. 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"}'`}
  1476. >
  1477. ```bash {{ title: 'cURL' }}
  1478. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \
  1479. --header 'Authorization: Bearer {api_key}' \
  1480. --header 'Content-Type: application/json' \
  1481. --data-raw '{
  1482. "content": "Child chunk content"
  1483. }'
  1484. ```
  1485. </CodeGroup>
  1486. <CodeGroup title="Response">
  1487. ```json {{ title: 'Response' }}
  1488. {
  1489. "data": {
  1490. "id": "",
  1491. "segment_id": "",
  1492. "content": "Child chunk content",
  1493. "word_count": 25,
  1494. "tokens": 0,
  1495. "index_node_id": "",
  1496. "index_node_hash": "",
  1497. "status": "completed",
  1498. "created_by": "",
  1499. "created_at": 1695312007,
  1500. "indexing_at": 1695312007,
  1501. "completed_at": 1695312007,
  1502. "error": null,
  1503. "stopped_at": null
  1504. }
  1505. }
  1506. ```
  1507. </CodeGroup>
  1508. </Col>
  1509. </Row>
  1510. <hr className='ml-0 mr-0' />
  1511. <Heading
  1512. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1513. method='GET'
  1514. title='Get Child Chunks'
  1515. name='#get_child_chunks'
  1516. />
  1517. <Row>
  1518. <Col>
  1519. ### Path
  1520. <Properties>
  1521. <Property name='dataset_id' type='string' key='dataset_id'>
  1522. Knowledge ID
  1523. </Property>
  1524. <Property name='document_id' type='string' key='document_id'>
  1525. Document ID
  1526. </Property>
  1527. <Property name='segment_id' type='string' key='segment_id'>
  1528. Segment ID
  1529. </Property>
  1530. </Properties>
  1531. ### Query
  1532. <Properties>
  1533. <Property name='keyword' type='string' key='keyword'>
  1534. Search keyword (optional)
  1535. </Property>
  1536. <Property name='page' type='integer' key='page'>
  1537. Page number (optional, default: 1)
  1538. </Property>
  1539. <Property name='limit' type='integer' key='limit'>
  1540. Items per page (optional, default: 20, max: 100)
  1541. </Property>
  1542. </Properties>
  1543. </Col>
  1544. <Col sticky>
  1545. <CodeGroup
  1546. title="Request"
  1547. tag="GET"
  1548. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1549. 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}'`}
  1550. >
  1551. ```bash {{ title: 'cURL' }}
  1552. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \
  1553. --header 'Authorization: Bearer {api_key}'
  1554. ```
  1555. </CodeGroup>
  1556. <CodeGroup title="Response">
  1557. ```json {{ title: 'Response' }}
  1558. {
  1559. "data": [{
  1560. "id": "",
  1561. "segment_id": "",
  1562. "content": "Child chunk content",
  1563. "word_count": 25,
  1564. "tokens": 0,
  1565. "index_node_id": "",
  1566. "index_node_hash": "",
  1567. "status": "completed",
  1568. "created_by": "",
  1569. "created_at": 1695312007,
  1570. "indexing_at": 1695312007,
  1571. "completed_at": 1695312007,
  1572. "error": null,
  1573. "stopped_at": null
  1574. }],
  1575. "total": 1,
  1576. "total_pages": 1,
  1577. "page": 1,
  1578. "limit": 20
  1579. }
  1580. ```
  1581. </CodeGroup>
  1582. </Col>
  1583. </Row>
  1584. <hr className='ml-0 mr-0' />
  1585. <Heading
  1586. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1587. method='DELETE'
  1588. title='Delete Child Chunk'
  1589. name='#delete_child_chunk'
  1590. />
  1591. <Row>
  1592. <Col>
  1593. ### Path
  1594. <Properties>
  1595. <Property name='dataset_id' type='string' key='dataset_id'>
  1596. Knowledge ID
  1597. </Property>
  1598. <Property name='document_id' type='string' key='document_id'>
  1599. Document ID
  1600. </Property>
  1601. <Property name='segment_id' type='string' key='segment_id'>
  1602. Segment ID
  1603. </Property>
  1604. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1605. Child Chunk ID
  1606. </Property>
  1607. </Properties>
  1608. </Col>
  1609. <Col sticky>
  1610. <CodeGroup
  1611. title="Request"
  1612. tag="DELETE"
  1613. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1614. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1615. >
  1616. ```bash {{ title: 'cURL' }}
  1617. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1618. --header 'Authorization: Bearer {api_key}'
  1619. ```
  1620. </CodeGroup>
  1621. <CodeGroup title="Response">
  1622. ```text {{ title: 'Response' }}
  1623. 204 No Content
  1624. ```
  1625. </CodeGroup>
  1626. </Col>
  1627. </Row>
  1628. <hr className='ml-0 mr-0' />
  1629. <Heading
  1630. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1631. method='PATCH'
  1632. title='Update Child Chunk'
  1633. name='#update_child_chunk'
  1634. />
  1635. <Row>
  1636. <Col>
  1637. ### Path
  1638. <Properties>
  1639. <Property name='dataset_id' type='string' key='dataset_id'>
  1640. Knowledge ID
  1641. </Property>
  1642. <Property name='document_id' type='string' key='document_id'>
  1643. Document ID
  1644. </Property>
  1645. <Property name='segment_id' type='string' key='segment_id'>
  1646. Segment ID
  1647. </Property>
  1648. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1649. Child Chunk ID
  1650. </Property>
  1651. </Properties>
  1652. ### Request Body
  1653. <Properties>
  1654. <Property name='content' type='string' key='content'>
  1655. Child chunk content
  1656. </Property>
  1657. </Properties>
  1658. </Col>
  1659. <Col sticky>
  1660. <CodeGroup
  1661. title="Request"
  1662. tag="PATCH"
  1663. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1664. 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"}'`}
  1665. >
  1666. ```bash {{ title: 'cURL' }}
  1667. curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1668. --header 'Authorization: Bearer {api_key}' \
  1669. --header 'Content-Type: application/json' \
  1670. --data-raw '{
  1671. "content": "Updated child chunk content"
  1672. }'
  1673. ```
  1674. </CodeGroup>
  1675. <CodeGroup title="Response">
  1676. ```json {{ title: 'Response' }}
  1677. {
  1678. "data": {
  1679. "id": "",
  1680. "segment_id": "",
  1681. "content": "Updated child chunk content",
  1682. "word_count": 25,
  1683. "tokens": 0,
  1684. "index_node_id": "",
  1685. "index_node_hash": "",
  1686. "status": "completed",
  1687. "created_by": "",
  1688. "created_at": 1695312007,
  1689. "indexing_at": 1695312007,
  1690. "completed_at": 1695312007,
  1691. "error": null,
  1692. "stopped_at": null
  1693. }
  1694. }
  1695. ```
  1696. </CodeGroup>
  1697. </Col>
  1698. </Row>
  1699. <hr className='ml-0 mr-0' />
  1700. <Heading
  1701. url='/datasets/{dataset_id}/documents/{document_id}/upload-file'
  1702. method='GET'
  1703. title='Get Upload File'
  1704. name='#get_upload_file'
  1705. />
  1706. <Row>
  1707. <Col>
  1708. ### Path
  1709. <Properties>
  1710. <Property name='dataset_id' type='string' key='dataset_id'>
  1711. Knowledge ID
  1712. </Property>
  1713. <Property name='document_id' type='string' key='document_id'>
  1714. Document ID
  1715. </Property>
  1716. </Properties>
  1717. </Col>
  1718. <Col sticky>
  1719. <CodeGroup
  1720. title="Request"
  1721. tag="GET"
  1722. label="/datasets/{dataset_id}/documents/{document_id}/upload-file"
  1723. 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'`}
  1724. >
  1725. ```bash {{ title: 'cURL' }}
  1726. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \
  1727. --header 'Authorization: Bearer {api_key}' \
  1728. --header 'Content-Type: application/json'
  1729. ```
  1730. </CodeGroup>
  1731. <CodeGroup title="Response">
  1732. ```json {{ title: 'Response' }}
  1733. {
  1734. "id": "file_id",
  1735. "name": "file_name",
  1736. "size": 1024,
  1737. "extension": "txt",
  1738. "url": "preview_url",
  1739. "download_url": "download_url",
  1740. "mime_type": "text/plain",
  1741. "created_by": "user_id",
  1742. "created_at": 1728734540,
  1743. }
  1744. ```
  1745. </CodeGroup>
  1746. </Col>
  1747. </Row>
  1748. <hr className='ml-0 mr-0' />
  1749. <Heading
  1750. url='/datasets/{dataset_id}/retrieve'
  1751. method='POST'
  1752. title='Retrieve Chunks from a Knowledge Base'
  1753. name='#dataset_retrieval'
  1754. />
  1755. <Row>
  1756. <Col>
  1757. ### Path
  1758. <Properties>
  1759. <Property name='dataset_id' type='string' key='dataset_id'>
  1760. Knowledge ID
  1761. </Property>
  1762. </Properties>
  1763. ### Request Body
  1764. <Properties>
  1765. <Property name='query' type='string' key='query'>
  1766. Query keyword
  1767. </Property>
  1768. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1769. Retrieval parameters (optional, if not filled, it will be recalled according to the default method)
  1770. - <code>search_method</code> (text) Search method: One of the following four keywords is required
  1771. - <code>keyword_search</code> Keyword search
  1772. - <code>semantic_search</code> Semantic search
  1773. - <code>full_text_search</code> Full-text search
  1774. - <code>hybrid_search</code> Hybrid search
  1775. - <code>reranking_enable</code> (bool) Whether to enable reranking, required if the search mode is semantic_search or hybrid_search (optional)
  1776. - <code>reranking_mode</code> (object) Rerank model configuration, required if reranking is enabled
  1777. - <code>reranking_provider_name</code> (string) Rerank model provider
  1778. - <code>reranking_model_name</code> (string) Rerank model name
  1779. - <code>weights</code> (float) Semantic search weight setting in hybrid search mode
  1780. - <code>top_k</code> (integer) Number of results to return (optional)
  1781. - <code>score_threshold_enabled</code> (bool) Whether to enable score threshold
  1782. - <code>score_threshold</code> (float) Score threshold
  1783. - <code>metadata_filtering_conditions</code> (object) Metadata filtering conditions
  1784. - <code>logical_operator</code> (string) Logical operator: <code>and</code> | <code>or</code>
  1785. - <code>conditions</code> (array[object]) Conditions list
  1786. - <code>name</code> (string) Metadata field name
  1787. - <code>comparison_operator</code> (string) Comparison operator, allowed values:
  1788. - String comparison:
  1789. - <code>contains</code>: Contains
  1790. - <code>not contains</code>: Does not contain
  1791. - <code>start with</code>: Starts with
  1792. - <code>end with</code>: Ends with
  1793. - <code>is</code>: Equals
  1794. - <code>is not</code>: Does not equal
  1795. - <code>empty</code>: Is empty
  1796. - <code>not empty</code>: Is not empty
  1797. - Numeric comparison:
  1798. - <code>=</code>: Equals
  1799. - <code>≠</code>: Does not equal
  1800. - <code>></code>: Greater than
  1801. - <code>< </code>: Less than
  1802. - <code>≥</code>: Greater than or equal
  1803. - <code>≤</code>: Less than or equal
  1804. - Time comparison:
  1805. - <code>before</code>: Before
  1806. - <code>after</code>: After
  1807. - <code>value</code> (string|number|null) Comparison value
  1808. </Property>
  1809. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1810. Unused field
  1811. </Property>
  1812. </Properties>
  1813. </Col>
  1814. <Col sticky>
  1815. <CodeGroup
  1816. title="Request"
  1817. tag="POST"
  1818. label="/datasets/{dataset_id}/retrieve"
  1819. 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 '{
  1820. "query": "test",
  1821. "retrieval_model": {
  1822. "search_method": "keyword_search",
  1823. "reranking_enable": false,
  1824. "reranking_mode": null,
  1825. "reranking_model": {
  1826. "reranking_provider_name": "",
  1827. "reranking_model_name": ""
  1828. },
  1829. "weights": null,
  1830. "top_k": 1,
  1831. "score_threshold_enabled": false,
  1832. "score_threshold": null,
  1833. "metadata_filtering_conditions": {
  1834. "logical_operator": "and",
  1835. "conditions": [
  1836. {
  1837. "name": "document_name",
  1838. "comparison_operator": "contains",
  1839. "value": "test"
  1840. }
  1841. ]
  1842. }
  1843. }
  1844. }'`}
  1845. >
  1846. ```bash {{ title: 'cURL' }}
  1847. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1848. --header 'Authorization: Bearer {api_key}' \
  1849. --header 'Content-Type: application/json' \
  1850. --data-raw '{
  1851. "query": "test",
  1852. "retrieval_model": {
  1853. "search_method": "keyword_search",
  1854. "reranking_enable": false,
  1855. "reranking_mode": null,
  1856. "reranking_model": {
  1857. "reranking_provider_name": "",
  1858. "reranking_model_name": ""
  1859. },
  1860. "weights": null,
  1861. "top_k": 2,
  1862. "score_threshold_enabled": false,
  1863. "score_threshold": null
  1864. }
  1865. }'
  1866. ```
  1867. </CodeGroup>
  1868. <CodeGroup title="Response">
  1869. ```json {{ title: 'Response' }}
  1870. {
  1871. "query": {
  1872. "content": "test"
  1873. },
  1874. "records": [
  1875. {
  1876. "segment": {
  1877. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1878. "position": 1,
  1879. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1880. "content": "Operation guide",
  1881. "answer": null,
  1882. "word_count": 847,
  1883. "tokens": 280,
  1884. "keywords": [
  1885. "install",
  1886. "java",
  1887. "base",
  1888. "scripts",
  1889. "jdk",
  1890. "manual",
  1891. "internal",
  1892. "opens",
  1893. "add",
  1894. "vmoptions"
  1895. ],
  1896. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1897. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1898. "hit_count": 0,
  1899. "enabled": true,
  1900. "disabled_at": null,
  1901. "disabled_by": null,
  1902. "status": "completed",
  1903. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1904. "created_at": 1728734540,
  1905. "indexing_at": 1728734552,
  1906. "completed_at": 1728734584,
  1907. "error": null,
  1908. "stopped_at": null,
  1909. "document": {
  1910. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1911. "data_source_type": "upload_file",
  1912. "name": "readme.txt",
  1913. }
  1914. },
  1915. "score": 3.730463140527718e-05,
  1916. "tsne_position": null
  1917. }
  1918. ]
  1919. }
  1920. ```
  1921. </CodeGroup>
  1922. </Col>
  1923. </Row>
  1924. <hr className='ml-0 mr-0' />
  1925. <Heading
  1926. url='/datasets/{dataset_id}/metadata'
  1927. method='POST'
  1928. title='Create a Knowledge Metadata'
  1929. name='#create_metadata'
  1930. />
  1931. <Row>
  1932. <Col>
  1933. ### Path
  1934. <Properties>
  1935. <Property name='dataset_id' type='string' key='dataset_id'>
  1936. Knowledge ID
  1937. </Property>
  1938. </Properties>
  1939. ### Request Body
  1940. <Properties>
  1941. <Property name='segment' type='object' key='segment'>
  1942. - <code>type</code> (string) Metadata type, required
  1943. - <code>name</code> (string) Metadata name, required
  1944. </Property>
  1945. </Properties>
  1946. </Col>
  1947. <Col sticky>
  1948. <CodeGroup
  1949. title="Request"
  1950. tag="POST"
  1951. label="/datasets/{dataset_id}/metadata"
  1952. 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"}'`}
  1953. >
  1954. ```bash {{ title: 'cURL' }}
  1955. ```
  1956. </CodeGroup>
  1957. <CodeGroup title="Response">
  1958. ```json {{ title: 'Response' }}
  1959. {
  1960. "id": "abc",
  1961. "type": "string",
  1962. "name": "test",
  1963. }
  1964. ```
  1965. </CodeGroup>
  1966. </Col>
  1967. </Row>
  1968. <hr className='ml-0 mr-0' />
  1969. <Heading
  1970. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  1971. method='PATCH'
  1972. title='Update a Knowledge Metadata'
  1973. name='#update_metadata'
  1974. />
  1975. <Row>
  1976. <Col>
  1977. ### Path
  1978. <Properties>
  1979. <Property name='dataset_id' type='string' key='dataset_id'>
  1980. Knowledge ID
  1981. </Property>
  1982. <Property name='metadata_id' type='string' key='metadata_id'>
  1983. Metadata ID
  1984. </Property>
  1985. </Properties>
  1986. ### Request Body
  1987. <Properties>
  1988. <Property name='segment' type='object' key='segment'>
  1989. - <code>name</code> (string) Metadata name, required
  1990. </Property>
  1991. </Properties>
  1992. </Col>
  1993. <Col sticky>
  1994. <CodeGroup
  1995. title="Request"
  1996. tag="PATCH"
  1997. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  1998. 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"}'`}
  1999. >
  2000. ```bash {{ title: 'cURL' }}
  2001. ```
  2002. </CodeGroup>
  2003. <CodeGroup title="Response">
  2004. ```json {{ title: 'Response' }}
  2005. {
  2006. "id": "abc",
  2007. "type": "string",
  2008. "name": "test",
  2009. }
  2010. ```
  2011. </CodeGroup>
  2012. </Col>
  2013. </Row>
  2014. <hr className='ml-0 mr-0' />
  2015. <Heading
  2016. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  2017. method='DELETE'
  2018. title='Delete a Knowledge Metadata'
  2019. name='#delete_metadata'
  2020. />
  2021. <Row>
  2022. <Col>
  2023. ### Path
  2024. <Properties>
  2025. <Property name='dataset_id' type='string' key='dataset_id'>
  2026. Knowledge ID
  2027. </Property>
  2028. <Property name='metadata_id' type='string' key='metadata_id'>
  2029. Metadata ID
  2030. </Property>
  2031. </Properties>
  2032. </Col>
  2033. <Col sticky>
  2034. <CodeGroup
  2035. title="Request"
  2036. tag="DELETE"
  2037. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  2038. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  2039. >
  2040. ```bash {{ title: 'cURL' }}
  2041. ```
  2042. </CodeGroup>
  2043. </Col>
  2044. </Row>
  2045. <hr className='ml-0 mr-0' />
  2046. <Heading
  2047. url='/datasets/{dataset_id}/metadata/built-in/{action}'
  2048. method='POST'
  2049. title='Disable Or Enable Built-in Metadata'
  2050. name='#toggle_metadata'
  2051. />
  2052. <Row>
  2053. <Col>
  2054. ### Path
  2055. <Properties>
  2056. <Property name='dataset_id' type='string' key='dataset_id'>
  2057. Knowledge ID
  2058. </Property>
  2059. <Property name='action' type='string' key='action'>
  2060. disable/enable
  2061. </Property>
  2062. </Properties>
  2063. </Col>
  2064. <Col sticky>
  2065. <CodeGroup
  2066. title="Request"
  2067. tag="POST"
  2068. label="/datasets/{dataset_id}/metadata/built-in/{action}"
  2069. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
  2070. >
  2071. ```bash {{ title: 'cURL' }}
  2072. ```
  2073. </CodeGroup>
  2074. </Col>
  2075. </Row>
  2076. <hr className='ml-0 mr-0' />
  2077. <Heading
  2078. url='/datasets/{dataset_id}/documents/metadata'
  2079. method='POST'
  2080. title='Update Documents Metadata'
  2081. name='#update_documents_metadata'
  2082. />
  2083. <Row>
  2084. <Col>
  2085. ### Path
  2086. <Properties>
  2087. <Property name='dataset_id' type='string' key='dataset_id'>
  2088. Knowledge ID
  2089. </Property>
  2090. </Properties>
  2091. ### Request Body
  2092. <Properties>
  2093. <Property name='operation_data' type='object list' key='segments'>
  2094. - <code>document_id</code> (string) Document ID
  2095. - <code>metadata_list</code> (list) Metadata list
  2096. - <code>id</code> (string) Metadata ID
  2097. - <code>value</code> (string) Metadata value
  2098. - <code>name</code> (string) Metadata name
  2099. </Property>
  2100. </Properties>
  2101. </Col>
  2102. <Col sticky>
  2103. <CodeGroup
  2104. title="Request"
  2105. tag="POST"
  2106. label="/datasets/{dataset_id}/documents/metadata"
  2107. 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"}]}]}'`}
  2108. >
  2109. ```bash {{ title: 'cURL' }} </CodeGroup>
  2110. </Col>
  2111. </Row>
  2112. <hr className='ml-0 mr-0' />
  2113. <Heading
  2114. url='/datasets/{dataset_id}/metadata'
  2115. method='GET'
  2116. title='Get Knowledge Metadata List'
  2117. name='#dataset_metadata_list'
  2118. />
  2119. <Row>
  2120. <Col>
  2121. ### Params
  2122. <Properties>
  2123. <Property name='dataset_id' type='string' key='dataset_id'>
  2124. Knowledge ID
  2125. </Property>
  2126. </Properties>
  2127. </Col>
  2128. <Col sticky>
  2129. <CodeGroup
  2130. title="Request"
  2131. tag="GET"
  2132. label="/datasets/{dataset_id}/metadata"
  2133. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
  2134. >
  2135. ```bash {{ title: 'cURL' }}
  2136. ```
  2137. </CodeGroup>
  2138. <CodeGroup title="Response">
  2139. ```json {{ title: 'Response' }}
  2140. {
  2141. "doc_metadata": [
  2142. {
  2143. "id": "",
  2144. "name": "name",
  2145. "type": "string",
  2146. "use_count": 0,
  2147. },
  2148. ...
  2149. ],
  2150. "built_in_field_enabled": true
  2151. }
  2152. ```
  2153. </CodeGroup>
  2154. </Col>
  2155. </Row>
  2156. <hr className='ml-0 mr-0' />
  2157. <Heading
  2158. url='/workspaces/current/models/model-types/text-embedding'
  2159. method='GET'
  2160. title='Get available embedding models'
  2161. name='#model_type_list'
  2162. />
  2163. <Row>
  2164. <Col>
  2165. ### Query
  2166. <Properties>
  2167. </Properties>
  2168. </Col>
  2169. <Col sticky>
  2170. <CodeGroup
  2171. title="Request"
  2172. tag="GET"
  2173. label="/datasets/{dataset_id}"
  2174. 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' `}
  2175. >
  2176. ```bash {{ title: 'cURL' }}
  2177. curl --location --request GET '${props.apiBaseUrl}/workspaces/current/models/model-types/text-embedding' \
  2178. --header 'Authorization: Bearer {api_key}' \
  2179. --header 'Content-Type: application/json' \
  2180. ```
  2181. </CodeGroup>
  2182. <CodeGroup title="Response">
  2183. ```json {{ title: 'Response' }}
  2184. {
  2185. "data": [
  2186. {
  2187. "provider": "zhipuai",
  2188. "label": {
  2189. "zh_Hans": "智谱 AI",
  2190. "en_US": "ZHIPU AI"
  2191. },
  2192. "icon_small": {
  2193. "zh_Hans": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/zh_Hans",
  2194. "en_US": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/en_US"
  2195. },
  2196. "icon_large": {
  2197. "zh_Hans": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/zh_Hans",
  2198. "en_US": "http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/en_US"
  2199. },
  2200. "status": "active",
  2201. "models": [
  2202. {
  2203. "model": "embedding-3",
  2204. "label": {
  2205. "zh_Hans": "embedding-3",
  2206. "en_US": "embedding-3"
  2207. },
  2208. "model_type": "text-embedding",
  2209. "features": null,
  2210. "fetch_from": "predefined-model",
  2211. "model_properties": {
  2212. "context_size": 8192
  2213. },
  2214. "deprecated": false,
  2215. "status": "active",
  2216. "load_balancing_enabled": false
  2217. },
  2218. {
  2219. "model": "embedding-2",
  2220. "label": {
  2221. "zh_Hans": "embedding-2",
  2222. "en_US": "embedding-2"
  2223. },
  2224. "model_type": "text-embedding",
  2225. "features": null,
  2226. "fetch_from": "predefined-model",
  2227. "model_properties": {
  2228. "context_size": 8192
  2229. },
  2230. "deprecated": false,
  2231. "status": "active",
  2232. "load_balancing_enabled": false
  2233. },
  2234. {
  2235. "model": "text_embedding",
  2236. "label": {
  2237. "zh_Hans": "text_embedding",
  2238. "en_US": "text_embedding"
  2239. },
  2240. "model_type": "text-embedding",
  2241. "features": null,
  2242. "fetch_from": "predefined-model",
  2243. "model_properties": {
  2244. "context_size": 512
  2245. },
  2246. "deprecated": false,
  2247. "status": "active",
  2248. "load_balancing_enabled": false
  2249. }
  2250. ]
  2251. }
  2252. ]
  2253. }
  2254. ```
  2255. </CodeGroup>
  2256. </Col>
  2257. </Row>
  2258. <hr className='ml-0 mr-0' />
  2259. Okay, I will translate the Chinese text in your document while keeping all formatting and code content unchanged.
  2260. <Heading
  2261. url='/datasets/tags'
  2262. method='POST'
  2263. title='Create New Knowledge Base Type Tag'
  2264. name='#create_new_knowledge_tag'
  2265. />
  2266. <Row>
  2267. <Col>
  2268. ### Request Body
  2269. <Properties>
  2270. <Property name='name' type='string'>
  2271. (text) New tag name, required, maximum length 50
  2272. </Property>
  2273. </Properties>
  2274. </Col>
  2275. <Col sticky>
  2276. <CodeGroup
  2277. title="Request"
  2278. tag="POST"
  2279. label="/datasets/tags"
  2280. 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"}'`}
  2281. >
  2282. ```bash {{ title: 'cURL' }}
  2283. curl --location --request POST '${props.apiBaseUrl}/datasets/tags' \
  2284. --header 'Authorization: Bearer {api_key}' \
  2285. --header 'Content-Type: application/json' \
  2286. --data-raw '{"name": "testtag1"}'
  2287. ```
  2288. </CodeGroup>
  2289. <CodeGroup title="Response">
  2290. ```json {{ title: 'Response' }}
  2291. {
  2292. "id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
  2293. "name": "testtag1",
  2294. "type": "knowledge",
  2295. "binding_count": 0
  2296. }
  2297. ```
  2298. </CodeGroup>
  2299. </Col>
  2300. </Row>
  2301. <hr className='ml-0 mr-0' />
  2302. <Heading
  2303. url='/datasets/tags'
  2304. method='GET'
  2305. title='Get Knowledge Base Type Tags'
  2306. name='#get_knowledge_type_tags'
  2307. />
  2308. <Row>
  2309. <Col>
  2310. ### Request Body
  2311. </Col>
  2312. <Col sticky>
  2313. <CodeGroup
  2314. title="Request"
  2315. tag="GET"
  2316. label="/datasets/tags"
  2317. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  2318. >
  2319. ```bash {{ title: 'cURL' }}
  2320. curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \
  2321. --header 'Authorization: Bearer {api_key}' \
  2322. --header 'Content-Type: application/json'
  2323. ```
  2324. </CodeGroup>
  2325. <CodeGroup title="Response">
  2326. ```json {{ title: 'Response' }}
  2327. [
  2328. {
  2329. "id": "39d6934c-ed36-463d-b4a7-377fa1503dc0",
  2330. "name": "testtag1",
  2331. "type": "knowledge",
  2332. "binding_count": "0"
  2333. },
  2334. ...
  2335. ]
  2336. ```
  2337. </CodeGroup>
  2338. </Col>
  2339. </Row>
  2340. <hr className='ml-0 mr-0' />
  2341. <Heading
  2342. url='/datasets/tags'
  2343. method='PATCH'
  2344. title='Modify Knowledge Base Type Tag Name'
  2345. name='#modify_knowledge_tag_name'
  2346. />
  2347. <Row>
  2348. <Col>
  2349. ### Request Body
  2350. <Properties>
  2351. <Property name='name' type='string'>
  2352. (text) Modified tag name, required, maximum length 50
  2353. </Property>
  2354. <Property name='tag_id' type='string'>
  2355. (text) Tag ID, required
  2356. </Property>
  2357. </Properties>
  2358. </Col>
  2359. <Col sticky>
  2360. <CodeGroup
  2361. title="Request"
  2362. tag="PATCH"
  2363. label="/datasets/tags"
  2364. 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"}`}
  2365. >
  2366. ```bash {{ title: 'cURL' }}
  2367. curl --location --request PATCH '${props.apiBaseUrl}/datasets/tags' \
  2368. --header 'Authorization: Bearer {api_key}' \
  2369. --header 'Content-Type: application/json' \
  2370. --data-raw '{"name": "testtag2", "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
  2371. ```
  2372. </CodeGroup>
  2373. <CodeGroup title="Response">
  2374. ```json {{ title: 'Response' }}
  2375. {
  2376. "id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
  2377. "name": "tag-renamed",
  2378. "type": "knowledge",
  2379. "binding_count": 0
  2380. }
  2381. ```
  2382. </CodeGroup>
  2383. </Col>
  2384. </Row>
  2385. <hr className='ml-0 mr-0' />
  2386. <Heading
  2387. url='/datasets/tags'
  2388. method='DELETE'
  2389. title='Delete Knowledge Base Type Tag'
  2390. name='#delete_knowledge_tag'
  2391. />
  2392. <Row>
  2393. <Col>
  2394. ### Request Body
  2395. <Properties>
  2396. <Property name='tag_id' type='string'>
  2397. (text) Tag ID, required
  2398. </Property>
  2399. </Properties>
  2400. </Col>
  2401. <Col sticky>
  2402. <CodeGroup
  2403. title="Request"
  2404. tag="DELETE"
  2405. label="/datasets/tags"
  2406. 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"}`}
  2407. >
  2408. ```bash {{ title: 'cURL' }}
  2409. curl --location --request DELETE '${props.apiBaseUrl}/datasets/tags' \
  2410. --header 'Authorization: Bearer {api_key}' \
  2411. --header 'Content-Type: application/json' \
  2412. --data-raw '{"tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
  2413. ```
  2414. </CodeGroup>
  2415. <CodeGroup title="Response">
  2416. ```json {{ title: 'Response' }}
  2417. {"result": "success"}
  2418. ```
  2419. </CodeGroup>
  2420. </Col>
  2421. </Row>
  2422. <hr className='ml-0 mr-0' />
  2423. <Heading
  2424. url='/datasets/tags/binding'
  2425. method='POST'
  2426. title='Bind Dataset to Knowledge Base Type Tag'
  2427. name='#bind_dataset_to_knowledge_tag'
  2428. />
  2429. <Row>
  2430. <Col>
  2431. ### Request Body
  2432. <Properties>
  2433. <Property name='tag_ids' type='list'>
  2434. (list) List of Tag IDs, required
  2435. </Property>
  2436. <Property name='target_id' type='string'>
  2437. (text) Dataset ID, required
  2438. </Property>
  2439. </Properties>
  2440. </Col>
  2441. <Col sticky>
  2442. <CodeGroup
  2443. title="Request"
  2444. tag="POST"
  2445. label="/datasets/tags/binding"
  2446. 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"}'`}
  2447. >
  2448. ```bash {{ title: 'cURL' }}
  2449. curl --location --request POST '${props.apiBaseUrl}/datasets/tags/binding' \
  2450. --header 'Authorization: Bearer {api_key}' \
  2451. --header 'Content-Type: application/json' \
  2452. --data-raw '{"tag_ids": ["65cc29be-d072-4e26-adf4-2f727644da29","1e5348f3-d3ff-42b8-a1b7-0a86d518001a"], "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
  2453. ```
  2454. </CodeGroup>
  2455. <CodeGroup title="Response">
  2456. ```json {{ title: 'Response' }}
  2457. {"result": "success"}
  2458. ```
  2459. </CodeGroup>
  2460. </Col>
  2461. </Row>
  2462. <hr className='ml-0 mr-0' />
  2463. <Heading
  2464. url='/datasets/tags/unbinding'
  2465. method='POST'
  2466. title='Unbind Dataset and Knowledge Base Type Tag'
  2467. name='#unbind_dataset_and_knowledge_tag'
  2468. />
  2469. <Row>
  2470. <Col>
  2471. ### Request Body
  2472. <Properties>
  2473. <Property name='tag_id' type='string'>
  2474. (text) Tag ID, required
  2475. </Property>
  2476. <Property name='target_id' type='string'>
  2477. (text) Dataset ID, required
  2478. </Property>
  2479. </Properties>
  2480. </Col>
  2481. <Col sticky>
  2482. <CodeGroup
  2483. title="Request"
  2484. tag="POST"
  2485. label="/datasets/tags/unbinding"
  2486. 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"}'`}
  2487. >
  2488. ```bash {{ title: 'cURL' }}
  2489. curl --location --request POST '${props.apiBaseUrl}/datasets/tags/unbinding' \
  2490. --header 'Authorization: Bearer {api_key}' \
  2491. --header 'Content-Type: application/json' \
  2492. --data-raw '{"tag_id": "1e5348f3-d3ff-42b8-a1b7-0a86d518001a", "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
  2493. ```
  2494. </CodeGroup>
  2495. <CodeGroup title="Response">
  2496. ```json {{ title: 'Response' }}
  2497. {"result": "success"}
  2498. ```
  2499. </CodeGroup>
  2500. </Col>
  2501. </Row>
  2502. <hr className='ml-0 mr-0' />
  2503. <Heading
  2504. url='/datasets/<uuid:dataset_id>/tags'
  2505. method='POST'
  2506. title='Query Tags Bound to a Dataset'
  2507. name='#query_dataset_tags'
  2508. />
  2509. <Row>
  2510. <Col>
  2511. ### Path
  2512. <Properties>
  2513. <Property name='dataset_id' type='string'>
  2514. (text) Dataset ID
  2515. </Property>
  2516. </Properties>
  2517. </Col>
  2518. <Col sticky>
  2519. <CodeGroup
  2520. title="Request"
  2521. tag="POST"
  2522. label="/datasets/<uuid:dataset_id>/tags"
  2523. 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`}
  2524. >
  2525. ```bash {{ title: 'cURL' }}
  2526. curl --location --request POST '${props.apiBaseUrl}/datasets/<uuid:dataset_id>/tags' \
  2527. --header 'Authorization: Bearer {api_key}' \
  2528. --header 'Content-Type: application/json' \
  2529. ```
  2530. </CodeGroup>
  2531. <CodeGroup title="Response">
  2532. ```json {{ title: 'Response' }}
  2533. {
  2534. "data":
  2535. [
  2536. {"id": "4a601f4f-f8a2-4166-ae7c-58c3b252a524",
  2537. "name": "123"
  2538. },
  2539. ...
  2540. ],
  2541. "total": 3
  2542. }
  2543. ```
  2544. </CodeGroup>
  2545. </Col>
  2546. </Row>
  2547. <hr className='ml-0 mr-0' />
  2548. <Row>
  2549. <Col>
  2550. ### Error message
  2551. <Properties>
  2552. <Property name='code' type='string' key='code'>
  2553. Error code
  2554. </Property>
  2555. </Properties>
  2556. <Properties>
  2557. <Property name='status' type='number' key='status'>
  2558. Error status
  2559. </Property>
  2560. </Properties>
  2561. <Properties>
  2562. <Property name='message' type='string' key='message'>
  2563. Error message
  2564. </Property>
  2565. </Properties>
  2566. </Col>
  2567. <Col>
  2568. <CodeGroup title="Example">
  2569. ```json {{ title: 'Response' }}
  2570. {
  2571. "code": "no_file_uploaded",
  2572. "message": "Please upload your file.",
  2573. "status": 400
  2574. }
  2575. ```
  2576. </CodeGroup>
  2577. </Col>
  2578. </Row>
  2579. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  2580. <thead style={{ background: '#f9fafc' }}>
  2581. <tr>
  2582. <th className="p-2 border border-slate-300">code</th>
  2583. <th className="p-2 border border-slate-300">status</th>
  2584. <th className="p-2 border border-slate-300">message</th>
  2585. </tr>
  2586. </thead>
  2587. <tbody>
  2588. <tr>
  2589. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  2590. <td className="p-2 border border-slate-300">400</td>
  2591. <td className="p-2 border border-slate-300">Please upload your file.</td>
  2592. </tr>
  2593. <tr>
  2594. <td className="p-2 border border-slate-300">too_many_files</td>
  2595. <td className="p-2 border border-slate-300">400</td>
  2596. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  2597. </tr>
  2598. <tr>
  2599. <td className="p-2 border border-slate-300">file_too_large</td>
  2600. <td className="p-2 border border-slate-300">413</td>
  2601. <td className="p-2 border border-slate-300">File size exceeded.</td>
  2602. </tr>
  2603. <tr>
  2604. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  2605. <td className="p-2 border border-slate-300">415</td>
  2606. <td className="p-2 border border-slate-300">File type not allowed.</td>
  2607. </tr>
  2608. <tr>
  2609. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  2610. <td className="p-2 border border-slate-300">400</td>
  2611. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  2612. </tr>
  2613. <tr>
  2614. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  2615. <td className="p-2 border border-slate-300">400</td>
  2616. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  2617. </tr>
  2618. <tr>
  2619. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  2620. <td className="p-2 border border-slate-300">403</td>
  2621. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  2622. </tr>
  2623. <tr>
  2624. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  2625. <td className="p-2 border border-slate-300">409</td>
  2626. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  2627. </tr>
  2628. <tr>
  2629. <td className="p-2 border border-slate-300">invalid_action</td>
  2630. <td className="p-2 border border-slate-300">400</td>
  2631. <td className="p-2 border border-slate-300">Invalid action.</td>
  2632. </tr>
  2633. <tr>
  2634. <td className="p-2 border border-slate-300">document_already_finished</td>
  2635. <td className="p-2 border border-slate-300">400</td>
  2636. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  2637. </tr>
  2638. <tr>
  2639. <td className="p-2 border border-slate-300">document_indexing</td>
  2640. <td className="p-2 border border-slate-300">400</td>
  2641. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  2642. </tr>
  2643. <tr>
  2644. <td className="p-2 border border-slate-300">invalid_metadata</td>
  2645. <td className="p-2 border border-slate-300">400</td>
  2646. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  2647. </tr>
  2648. </tbody>
  2649. </table>
  2650. <div className="pb-4" />