template.ja.mdx 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978
  1. import { CodeGroup } from '@/app/components/develop/code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstruction, Paragraph } from '@/app/components/develop/md.tsx'
  3. # ナレッジ API
  4. <div>
  5. ### 認証
  6. Dify のサービス API は `API-Key` を使用して認証します。
  7. 開発者は、`API-Key` をクライアント側で共有または保存するのではなく、バックエンドに保存することを推奨します。これにより、`API-Key` の漏洩による財産損失を防ぐことができます。
  8. すべての API リクエストには、以下のように **`Authorization`** HTTP ヘッダーに `API-Key` を含める必要があります:
  9. <CodeGroup title="コード">
  10. ```javascript
  11. Authorization: Bearer {API_KEY}
  12. ```
  13. </CodeGroup>
  14. </div>
  15. <hr className='ml-0 mr-0' />
  16. <Heading
  17. url='/datasets/{dataset_id}/document/create-by-text'
  18. method='POST'
  19. title='テキストからドキュメントを作成'
  20. name='#create-by-text'
  21. />
  22. <Row>
  23. <Col>
  24. この API は既存のナレッジに基づいており、このナレッジを基にテキストを使用して新しいドキュメントを作成します。
  25. ### パラメータ
  26. <Properties>
  27. <Property name='dataset_id' type='string' key='dataset_id'>
  28. ナレッジ ID
  29. </Property>
  30. </Properties>
  31. ### リクエストボディ
  32. <Properties>
  33. <Property name='name' type='string' key='name'>
  34. ドキュメント名
  35. </Property>
  36. <Property name='text' type='string' key='text'>
  37. ドキュメント内容
  38. </Property>
  39. <Property name='indexing_technique' type='string' key='indexing_technique'>
  40. インデックスモード
  41. - <code>high_quality</code> 高品質: 埋め込みモデルを使用してベクトルデータベースインデックスを構築
  42. - <code>economy</code> 経済: キーワードテーブルインデックスの反転インデックスを構築
  43. </Property>
  44. <Property name='doc_form' type='string' key='doc_form'>
  45. インデックス化された内容の形式
  46. - <code>text_model</code> テキストドキュメントは直接埋め込まれます; `economy` モードではこの形式がデフォルト
  47. - <code>hierarchical_model</code> 親子モード
  48. - <code>qa_model</code> Q&A モード: 分割されたドキュメントの質問と回答ペアを生成し、質問を埋め込みます
  49. </Property>
  50. <Property name='doc_language' type='string' key='doc_language'>
  51. Q&A モードでは、ドキュメントの言語を指定します。例: <code>English</code>, <code>Chinese</code>
  52. </Property>
  53. <Property name='process_rule' type='object' key='process_rule'>
  54. 処理ルール
  55. - <code>mode</code> (string) クリーニング、セグメンテーションモード、自動 / カスタム
  56. - <code>rules</code> (object) カスタムルール (自動モードでは、このフィールドは空)
  57. - <code>pre_processing_rules</code> (array[object]) 前処理ルール
  58. - <code>id</code> (string) 前処理ルールの一意識別子
  59. - 列挙
  60. - <code>remove_extra_spaces</code> 連続するスペース、改行、タブを置換
  61. - <code>remove_urls_emails</code> URL、メールアドレスを削除
  62. - <code>enabled</code> (bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
  63. - <code>segmentation</code> (object) セグメンテーションルール
  64. - <code>separator</code> カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
  65. - <code>max_tokens</code> 最大長 (トークン) デフォルトは 1000
  66. - <code>parent_mode</code> 親チャンクの検索モード: <code>full-doc</code> 全文検索 / <code>paragraph</code> 段落検索
  67. - <code>subchunk_segmentation</code> (object) 子チャンクルール
  68. - <code>separator</code> セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは <code>***</code>
  69. - <code>max_tokens</code> 最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
  70. - <code>chunk_overlap</code> 隣接するチャンク間の重複を定義 (オプション)
  71. </Property>
  72. <PropertyInstruction>ナレッジベースにパラメータが設定されていない場合、最初のアップロードには以下のパラメータを提供する必要があります。提供されない場合、デフォルトパラメータが使用されます。</PropertyInstruction>
  73. <Property name='retrieval_model' type='object' key='retrieval_model'>
  74. 検索モデル
  75. - <code>search_method</code> (string) 検索方法
  76. - <code>hybrid_search</code> ハイブリッド検索
  77. - <code>semantic_search</code> セマンティック検索
  78. - <code>full_text_search</code> 全文検索
  79. - <code>reranking_enable</code> (bool) 再ランキングを有効にするかどうか
  80. - <code>reranking_mode</code> (object) 再ランキングモデル構成
  81. - <code>reranking_provider_name</code> (string) 再ランキングモデルプロバイダー
  82. - <code>reranking_model_name</code> (string) 再ランキングモデル名
  83. - <code>top_k</code> (int) 返される結果の数
  84. - <code>score_threshold_enabled</code> (bool) スコア閾値を有効にするかどうか
  85. - <code>score_threshold</code> (float) スコア閾値
  86. </Property>
  87. <Property name='embedding_model' type='string' key='embedding_model'>
  88. 埋め込みモデル名
  89. </Property>
  90. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  91. 埋め込みモデルプロバイダー
  92. </Property>
  93. </Properties>
  94. </Col>
  95. <Col sticky>
  96. <CodeGroup
  97. title="リクエスト"
  98. tag="POST"
  99. label="/datasets/{dataset_id}/document/create-by-text"
  100. 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"}}'`}
  101. >
  102. ```bash {{ title: 'cURL' }}
  103. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
  104. --header 'Authorization: Bearer {api_key}' \
  105. --header 'Content-Type: application/json' \
  106. --data-raw '{
  107. "name": "text",
  108. "text": "text",
  109. "indexing_technique": "high_quality",
  110. "process_rule": {
  111. "mode": "automatic"
  112. }
  113. }'
  114. ```
  115. </CodeGroup>
  116. <CodeGroup title="レスポンス">
  117. ```json {{ title: 'Response' }}
  118. {
  119. "document": {
  120. "id": "",
  121. "position": 1,
  122. "data_source_type": "upload_file",
  123. "data_source_info": {
  124. "upload_file_id": ""
  125. },
  126. "dataset_process_rule_id": "",
  127. "name": "text.txt",
  128. "created_from": "api",
  129. "created_by": "",
  130. "created_at": 1695690280,
  131. "tokens": 0,
  132. "indexing_status": "waiting",
  133. "error": null,
  134. "enabled": true,
  135. "disabled_at": null,
  136. "disabled_by": null,
  137. "archived": false,
  138. "display_status": "queuing",
  139. "word_count": 0,
  140. "hit_count": 0,
  141. "doc_form": "text_model"
  142. },
  143. "batch": ""
  144. }
  145. ```
  146. </CodeGroup>
  147. </Col>
  148. </Row>
  149. <hr className='ml-0 mr-0' />
  150. <Heading
  151. url='/datasets/{dataset_id}/document/create-by-file'
  152. method='POST'
  153. title='ファイルからドキュメントを作成'
  154. name='#create-by-file'
  155. />
  156. <Row>
  157. <Col>
  158. この API は既存のナレッジに基づいており、このナレッジを基にファイルを使用して新しいドキュメントを作成します。
  159. ### パラメータ
  160. <Properties>
  161. <Property name='dataset_id' type='string' key='dataset_id'>
  162. ナレッジ ID
  163. </Property>
  164. </Properties>
  165. ### リクエストボディ
  166. <Properties>
  167. <Property name='data' type='multipart/form-data json string' key='data'>
  168. - <code>original_document_id</code> 元のドキュメント ID (オプション)
  169. - ドキュメントを再アップロードまたはクリーニングとセグメンテーション構成を変更するために使用されます。欠落している情報は元のドキュメントからコピーされます。
  170. - 元のドキュメントはアーカイブされたドキュメントであってはなりません。
  171. - original_document_id が渡された場合、更新操作が実行されます。process_rule は入力可能な項目です。入力されない場合、元のドキュメントのセグメンテーション方法がデフォルトで使用されます。
  172. - original_document_id が渡されない場合、新しい操作が実行され、process_rule が必要です。
  173. - <code>indexing_technique</code> インデックスモード
  174. - <code>high_quality</code> 高品質: 埋め込みモデルを使用してベクトルデータベースインデックスを構築
  175. - <code>economy</code> 経済: キーワードテーブルインデックスの反転インデックスを構築
  176. - <code>doc_form</code> インデックス化された内容の形式
  177. - <code>text_model</code> テキストドキュメントは直接埋め込まれます; `economy` モードではこの形式がデフォルト
  178. - <code>hierarchical_model</code> 親子モード
  179. - <code>qa_model</code> Q&A モード: 分割されたドキュメントの質問と回答ペアを生成し、質問を埋め込みます
  180. - <code>doc_language</code> Q&A モードでは、ドキュメントの言語を指定します。例: <code>English</code>, <code>Chinese</code>
  181. - <code>process_rule</code> 処理ルール
  182. - <code>mode</code> (string) クリーニング、セグメンテーションモード、自動 / カスタム
  183. - <code>rules</code> (object) カスタムルール (自動モードでは、このフィールドは空)
  184. - <code>pre_processing_rules</code> (array[object]) 前処理ルール
  185. - <code>id</code> (string) 前処理ルールの一意識別子
  186. - 列挙
  187. - <code>remove_extra_spaces</code> 連続するスペース、改行、タブを置換
  188. - <code>remove_urls_emails</code> URL、メールアドレスを削除
  189. - <code>enabled</code> (bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
  190. - <code>segmentation</code> (object) セグメンテーションルール
  191. - <code>separator</code> カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
  192. - <code>max_tokens</code> 最大長 (トークン) デフォルトは 1000
  193. - <code>parent_mode</code> 親チャンクの検索モード: <code>full-doc</code> 全文検索 / <code>paragraph</code> 段落検索
  194. - <code>subchunk_segmentation</code> (object) 子チャンクルール
  195. - <code>separator</code> セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは <code>***</code>
  196. - <code>max_tokens</code> 最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
  197. - <code>chunk_overlap</code> 隣接するチャンク間の重複を定義 (オプション)
  198. </Property>
  199. <Property name='file' type='multipart/form-data' key='file'>
  200. アップロードする必要があるファイル。
  201. </Property>
  202. <PropertyInstruction>ナレッジベースにパラメータが設定されていない場合、最初のアップロードには以下のパラメータを提供する必要があります。提供されない場合、デフォルトパラメータが使用されます。</PropertyInstruction>
  203. <Property name='retrieval_model' type='object' key='retrieval_model'>
  204. 検索モデル
  205. - <code>search_method</code> (string) 検索方法
  206. - <code>hybrid_search</code> ハイブリッド検索
  207. - <code>semantic_search</code> セマンティック検索
  208. - <code>full_text_search</code> 全文検索
  209. - <code>reranking_enable</code> (bool) 再ランキングを有効にするかどうか
  210. - <code>reranking_mode</code> (object) 再ランキングモデル構成
  211. - <code>reranking_provider_name</code> (string) 再ランキングモデルプロバイダー
  212. - <code>reranking_model_name</code> (string) 再ランキングモデル名
  213. - <code>top_k</code> (int) 返される結果の数
  214. - <code>score_threshold_enabled</code> (bool) スコア閾値を有効にするかどうか
  215. - <code>score_threshold</code> (float) スコア閾値
  216. </Property>
  217. <Property name='embedding_model' type='string' key='embedding_model'>
  218. 埋め込みモデル名
  219. </Property>
  220. <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>
  221. 埋め込みモデルプロバイダー
  222. </Property>
  223. </Properties>
  224. </Col>
  225. <Col sticky>
  226. <CodeGroup
  227. title="リクエスト"
  228. tag="POST"
  229. label="/datasets/{dataset_id}/document/create-by-file"
  230. 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"'`}
  231. >
  232. ```bash {{ title: 'cURL' }}
  233. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
  234. --header 'Authorization: Bearer {api_key}' \
  235. --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' \
  236. --form 'file=@"/path/to/file"'
  237. ```
  238. </CodeGroup>
  239. <CodeGroup title="レスポンス">
  240. ```json {{ title: 'Response' }}
  241. {
  242. "document": {
  243. "id": "",
  244. "position": 1,
  245. "data_source_type": "upload_file",
  246. "data_source_info": {
  247. "upload_file_id": ""
  248. },
  249. "dataset_process_rule_id": "",
  250. "name": "Dify.txt",
  251. "created_from": "api",
  252. "created_by": "",
  253. "created_at": 1695308667,
  254. "tokens": 0,
  255. "indexing_status": "waiting",
  256. "error": null,
  257. "enabled": true,
  258. "disabled_at": null,
  259. "disabled_by": null,
  260. "archived": false,
  261. "display_status": "queuing",
  262. "word_count": 0,
  263. "hit_count": 0,
  264. "doc_form": "text_model"
  265. },
  266. "batch": ""
  267. }
  268. ```
  269. </CodeGroup>
  270. </Col>
  271. </Row>
  272. <hr className='ml-0 mr-0' />
  273. <Heading
  274. url='/datasets'
  275. method='POST'
  276. title='空のナレッジベースを作成'
  277. name='#create_empty_dataset'
  278. />
  279. <Row>
  280. <Col>
  281. ### リクエストボディ
  282. <Properties>
  283. <Property name='name' type='string' key='name'>
  284. ナレッジ名
  285. </Property>
  286. <Property name='description' type='string' key='description'>
  287. ナレッジの説明 (オプション)
  288. </Property>
  289. <Property name='indexing_technique' type='string' key='indexing_technique'>
  290. インデックス技術 (オプション)
  291. - <code>high_quality</code> 高品質
  292. - <code>economy</code> 経済
  293. </Property>
  294. <Property name='permission' type='string' key='permission'>
  295. 権限
  296. - <code>only_me</code> 自分のみ
  297. - <code>all_team_members</code> すべてのチームメンバー
  298. - <code>partial_members</code> 一部のメンバー
  299. </Property>
  300. <Property name='provider' type='string' key='provider'>
  301. プロバイダー (オプション、デフォルト: vendor)
  302. - <code>vendor</code> ベンダー
  303. - <code>external</code> 外部ナレッジ
  304. </Property>
  305. <Property name='external_knowledge_api_id' type='str' key='external_knowledge_api_id'>
  306. 外部ナレッジ API ID (オプション)
  307. </Property>
  308. <Property name='external_knowledge_id' type='str' key='external_knowledge_id'>
  309. 外部ナレッジ ID (オプション)
  310. </Property>
  311. </Properties>
  312. </Col>
  313. <Col sticky>
  314. <CodeGroup
  315. title="リクエスト"
  316. tag="POST"
  317. label="/datasets"
  318. 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"}'`}
  319. >
  320. ```bash {{ title: 'cURL' }}
  321. curl --location --request POST '${apiBaseUrl}/v1/datasets' \
  322. --header 'Authorization: Bearer {api_key}' \
  323. --header 'Content-Type: application/json' \
  324. --data-raw '{
  325. "name": "name",
  326. "permission": "only_me"
  327. }'
  328. ```
  329. </CodeGroup>
  330. <CodeGroup title="レスポンス">
  331. ```json {{ title: 'Response' }}
  332. {
  333. "id": "",
  334. "name": "name",
  335. "description": null,
  336. "provider": "vendor",
  337. "permission": "only_me",
  338. "data_source_type": null,
  339. "indexing_technique": null,
  340. "app_count": 0,
  341. "document_count": 0,
  342. "word_count": 0,
  343. "created_by": "",
  344. "created_at": 1695636173,
  345. "updated_by": "",
  346. "updated_at": 1695636173,
  347. "embedding_model": null,
  348. "embedding_model_provider": null,
  349. "embedding_available": null
  350. }
  351. ```
  352. </CodeGroup>
  353. </Col>
  354. </Row>
  355. <hr className='ml-0 mr-0' />
  356. <Heading
  357. url='/datasets'
  358. method='GET'
  359. title='ナレッジベースリストを取得'
  360. name='#dataset_list'
  361. />
  362. <Row>
  363. <Col>
  364. ### クエリ
  365. <Properties>
  366. <Property name='page' type='string' key='page'>
  367. ページ番号
  368. </Property>
  369. <Property name='limit' type='string' key='limit'>
  370. 返されるアイテム数、デフォルトは 20、範囲は 1-100
  371. </Property>
  372. </Properties>
  373. </Col>
  374. <Col sticky>
  375. <CodeGroup
  376. title="リクエスト"
  377. tag="GET"
  378. label="/datasets"
  379. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  380. >
  381. ```bash {{ title: 'cURL' }}
  382. curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
  383. --header 'Authorization: Bearer {api_key}'
  384. ```
  385. </CodeGroup>
  386. <CodeGroup title="レスポンス">
  387. ```json {{ title: 'Response' }}
  388. {
  389. "data": [
  390. {
  391. "id": "",
  392. "name": "name",
  393. "description": "desc",
  394. "permission": "only_me",
  395. "data_source_type": "upload_file",
  396. "indexing_technique": "",
  397. "app_count": 2,
  398. "document_count": 10,
  399. "word_count": 1200,
  400. "created_by": "",
  401. "created_at": "",
  402. "updated_by": "",
  403. "updated_at": ""
  404. },
  405. ...
  406. ],
  407. "has_more": true,
  408. "limit": 20,
  409. "total": 50,
  410. "page": 1
  411. }
  412. ```
  413. </CodeGroup>
  414. </Col>
  415. </Row>
  416. <hr className='ml-0 mr-0' />
  417. <Heading
  418. url='/datasets/{dataset_id}'
  419. method='DELETE'
  420. title='ナレッジベースを削除'
  421. name='#delete_dataset'
  422. />
  423. <Row>
  424. <Col>
  425. ### パラメータ
  426. <Properties>
  427. <Property name='dataset_id' type='string' key='dataset_id'>
  428. ナレッジ ID
  429. </Property>
  430. </Properties>
  431. </Col>
  432. <Col sticky>
  433. <CodeGroup
  434. title="リクエスト"
  435. tag="DELETE"
  436. label="/datasets/{dataset_id}"
  437. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  438. >
  439. ```bash {{ title: 'cURL' }}
  440. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
  441. --header 'Authorization: Bearer {api_key}'
  442. ```
  443. </CodeGroup>
  444. <CodeGroup title="レスポンス">
  445. ```text {{ title: 'Response' }}
  446. 204 No Content
  447. ```
  448. </CodeGroup>
  449. </Col>
  450. </Row>
  451. <hr className='ml-0 mr-0' />
  452. <Heading
  453. url='/datasets/{dataset_id}/documents/{document_id}/update-by-text'
  454. method='POST'
  455. title='テキストでドキュメントを更新'
  456. name='#update-by-text'
  457. />
  458. <Row>
  459. <Col>
  460. この API は既存のナレッジに基づいており、このナレッジを基にテキストを使用してドキュメントを更新します。
  461. ### パラメータ
  462. <Properties>
  463. <Property name='dataset_id' type='string' key='dataset_id'>
  464. ナレッジ ID
  465. </Property>
  466. <Property name='document_id' type='string' key='document_id'>
  467. ドキュメント ID
  468. </Property>
  469. </Properties>
  470. ### リクエストボディ
  471. <Properties>
  472. <Property name='name' type='string' key='name'>
  473. ドキュメント名 (オプション)
  474. </Property>
  475. <Property name='text' type='string' key='text'>
  476. ドキュメント内容 (オプション)
  477. </Property>
  478. <Property name='process_rule' type='object' key='process_rule'>
  479. 処理ルール
  480. - <code>mode</code> (string) クリーニング、セグメンテーションモード、自動 / カスタム
  481. - <code>rules</code> (object) カスタムルール (自動モードでは、このフィールドは空)
  482. - <code>pre_processing_rules</code> (array[object]) 前処理ルール
  483. - <code>id</code> (string) 前処理ルールの一意識別子
  484. - 列挙
  485. - <code>remove_extra_spaces</code> 連続するスペース、改行、タブを置換
  486. - <code>remove_urls_emails</code> URL、メールアドレスを削除
  487. - <code>enabled</code> (bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
  488. - <code>segmentation</code> (object) セグメンテーションルール
  489. - <code>separator</code> カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
  490. - <code>max_tokens</code> 最大長 (トークン) デフォルトは 1000
  491. - <code>parent_mode</code> 親チャンクの検索モード: <code>full-doc</code> 全文検索 / <code>paragraph</code> 段落検索
  492. - <code>subchunk_segmentation</code> (object) 子チャンクルール
  493. - <code>separator</code> セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは <code>***</code>
  494. - <code>max_tokens</code> 最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
  495. - <code>chunk_overlap</code> 隣接するチャンク間の重複を定義 (オプション)
  496. </Property>
  497. </Properties>
  498. </Col>
  499. <Col sticky>
  500. <CodeGroup
  501. title="リクエスト"
  502. tag="POST"
  503. label="/datasets/{dataset_id}/documents/{document_id}/update-by-text"
  504. 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"}'`}
  505. >
  506. ```bash {{ title: 'cURL' }}
  507. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
  508. --header 'Authorization: Bearer {api_key}' \
  509. --header 'Content-Type: application/json' \
  510. --data-raw '{
  511. "name": "name",
  512. "text": "text"
  513. }'
  514. ```
  515. </CodeGroup>
  516. <CodeGroup title="レスポンス">
  517. ```json {{ title: 'Response' }}
  518. {
  519. "document": {
  520. "id": "",
  521. "position": 1,
  522. "data_source_type": "upload_file",
  523. "data_source_info": {
  524. "upload_file_id": ""
  525. },
  526. "dataset_process_rule_id": "",
  527. "name": "name.txt",
  528. "created_from": "api",
  529. "created_by": "",
  530. "created_at": 1695308667,
  531. "tokens": 0,
  532. "indexing_status": "waiting",
  533. "error": null,
  534. "enabled": true,
  535. "disabled_at": null,
  536. "disabled_by": null,
  537. "archived": false,
  538. "display_status": "queuing",
  539. "word_count": 0,
  540. "hit_count": 0,
  541. "doc_form": "text_model"
  542. },
  543. "batch": ""
  544. }
  545. ```
  546. </CodeGroup>
  547. </Col>
  548. </Row>
  549. <hr className='ml-0 mr-0' />
  550. <Heading
  551. url='/datasets/{dataset_id}/documents/{document_id}/update-by-file'
  552. method='POST'
  553. title='ファイルでドキュメントを更新'
  554. name='#update-by-file'
  555. />
  556. <Row>
  557. <Col>
  558. この API は既存のナレッジに基づいており、このナレッジを基にファイルを使用してドキュメントを更新します。
  559. ### パラメータ
  560. <Properties>
  561. <Property name='dataset_id' type='string' key='dataset_id'>
  562. ナレッジ ID
  563. </Property>
  564. <Property name='document_id' type='string' key='document_id'>
  565. ドキュメント ID
  566. </Property>
  567. </Properties>
  568. ### リクエストボディ
  569. <Properties>
  570. <Property name='name' type='string' key='name'>
  571. ドキュメント名 (オプション)
  572. </Property>
  573. <Property name='file' type='multipart/form-data' key='file'>
  574. アップロードするファイル
  575. </Property>
  576. <Property name='process_rule' type='object' key='process_rule'>
  577. 処理ルール
  578. - <code>mode</code> (string) クリーニング、セグメンテーションモード、自動 / カスタム
  579. - <code>rules</code> (object) カスタムルール (自動モードでは、このフィールドは空)
  580. - <code>pre_processing_rules</code> (array[object]) 前処理ルール
  581. - <code>id</code> (string) 前処理ルールの一意識別子
  582. - 列挙
  583. - <code>remove_extra_spaces</code> 連続するスペース、改行、タブを置換
  584. - <code>remove_urls_emails</code> URL、メールアドレスを削除
  585. - <code>enabled</code> (bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
  586. - <code>segmentation</code> (object) セグメンテーションルール
  587. - <code>separator</code> カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
  588. - <code>max_tokens</code> 最大長 (トークン) デフォルトは 1000
  589. - <code>parent_mode</code> 親チャンクの検索モード: <code>full-doc</code> 全文検索 / <code>paragraph</code> 段落検索
  590. - <code>subchunk_segmentation</code> (object) 子チャンクルール
  591. - <code>separator</code> セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは <code>***</code>
  592. - <code>max_tokens</code> 最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
  593. - <code>chunk_overlap</code> 隣接するチャンク間の重複を定義 (オプション)
  594. </Property>
  595. </Properties>
  596. </Col>
  597. <Col sticky>
  598. <CodeGroup
  599. title="リクエスト"
  600. tag="POST"
  601. label="/datasets/{dataset_id}/documents/{document_id}/update-by-file"
  602. 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"'`}
  603. >
  604. ```bash {{ title: 'cURL' }}
  605. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
  606. --header 'Authorization: Bearer {api_key}' \
  607. --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' \
  608. --form 'file=@"/path/to/file"'
  609. ```
  610. </CodeGroup>
  611. <CodeGroup title="レスポンス">
  612. ```json {{ title: 'Response' }}
  613. {
  614. "document": {
  615. "id": "",
  616. "position": 1,
  617. "data_source_type": "upload_file",
  618. "data_source_info": {
  619. "upload_file_id": ""
  620. },
  621. "dataset_process_rule_id": "",
  622. "name": "Dify.txt",
  623. "created_from": "api",
  624. "created_by": "",
  625. "created_at": 1695308667,
  626. "tokens": 0,
  627. "indexing_status": "waiting",
  628. "error": null,
  629. "enabled": true,
  630. "disabled_at": null,
  631. "disabled_by": null,
  632. "archived": false,
  633. "display_status": "queuing",
  634. "word_count": 0,
  635. "hit_count": 0,
  636. "doc_form": "text_model"
  637. },
  638. "batch": "20230921150427533684"
  639. }
  640. ```
  641. </CodeGroup>
  642. </Col>
  643. </Row>
  644. <hr className='ml-0 mr-0' />
  645. <Heading
  646. url='/datasets/{dataset_id}/documents/{batch}/indexing-status'
  647. method='GET'
  648. title='ドキュメントの埋め込みステータス (進行状況) を取得'
  649. name='#indexing_status'
  650. />
  651. <Row>
  652. <Col>
  653. ### パラメータ
  654. <Properties>
  655. <Property name='dataset_id' type='string' key='dataset_id'>
  656. ナレッジ ID
  657. </Property>
  658. <Property name='batch' type='string' key='batch'>
  659. アップロードされたドキュメントのバッチ番号
  660. </Property>
  661. </Properties>
  662. </Col>
  663. <Col sticky>
  664. <CodeGroup
  665. title="リクエスト"
  666. tag="GET"
  667. label="/datasets/{dataset_id}/documents/{batch}/indexing-status"
  668. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \\\n--header 'Authorization: Bearer {api_key}'`}
  669. >
  670. ```bash {{ title: 'cURL' }}
  671. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
  672. --header 'Authorization: Bearer {api_key}' \
  673. ```
  674. </CodeGroup>
  675. <CodeGroup title="レスポンス">
  676. ```json {{ title: 'Response' }}
  677. {
  678. "data":[{
  679. "id": "",
  680. "indexing_status": "indexing",
  681. "processing_started_at": 1681623462.0,
  682. "parsing_completed_at": 1681623462.0,
  683. "cleaning_completed_at": 1681623462.0,
  684. "splitting_completed_at": 1681623462.0,
  685. "completed_at": null,
  686. "paused_at": null,
  687. "error": null,
  688. "stopped_at": null,
  689. "completed_segments": 24,
  690. "total_segments": 100
  691. }]
  692. }
  693. ```
  694. </CodeGroup>
  695. </Col>
  696. </Row>
  697. <hr className='ml-0 mr-0' />
  698. <Heading
  699. url='/datasets/{dataset_id}/documents/{document_id}'
  700. method='DELETE'
  701. title='ドキュメントを削除'
  702. name='#delete_document'
  703. />
  704. <Row>
  705. <Col>
  706. ### パラメータ
  707. <Properties>
  708. <Property name='dataset_id' type='string' key='dataset_id'>
  709. ナレッジ ID
  710. </Property>
  711. <Property name='document_id' type='string' key='document_id'>
  712. ドキュメント ID
  713. </Property>
  714. </Properties>
  715. </Col>
  716. <Col sticky>
  717. <CodeGroup
  718. title="リクエスト"
  719. tag="DELETE"
  720. label="/datasets/{dataset_id}/documents/{document_id}"
  721. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  722. >
  723. ```bash {{ title: 'cURL' }}
  724. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
  725. --header 'Authorization: Bearer {api_key}' \
  726. ```
  727. </CodeGroup>
  728. <CodeGroup title="レスポンス">
  729. ```json {{ title: 'Response' }}
  730. {
  731. "result": "success"
  732. }
  733. ```
  734. </CodeGroup>
  735. </Col>
  736. </Row>
  737. <hr className='ml-0 mr-0' />
  738. <Heading
  739. url='/datasets/{dataset_id}/documents'
  740. method='GET'
  741. title='ナレッジベースのドキュメントリストを取得'
  742. name='#dataset_document_list'
  743. />
  744. <Row>
  745. <Col>
  746. ### パラメータ
  747. <Properties>
  748. <Property name='dataset_id' type='string' key='dataset_id'>
  749. ナレッジ ID
  750. </Property>
  751. </Properties>
  752. ### クエリ
  753. <Properties>
  754. <Property name='keyword' type='string' key='keyword'>
  755. 検索キーワード、現在はドキュメント名のみ検索 (オプション)
  756. </Property>
  757. <Property name='page' type='string' key='page'>
  758. ページ番号 (オプション)
  759. </Property>
  760. <Property name='limit' type='string' key='limit'>
  761. 返されるアイテム数、デフォルトは 20、範囲は 1-100 (オプション)
  762. </Property>
  763. </Properties>
  764. </Col>
  765. <Col sticky>
  766. <CodeGroup
  767. title="リクエスト"
  768. tag="GET"
  769. label="/datasets/{dataset_id}/documents"
  770. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \\\n--header 'Authorization: Bearer {api_key}'`}
  771. >
  772. ```bash {{ title: 'cURL' }}
  773. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
  774. --header 'Authorization: Bearer {api_key}' \
  775. ```
  776. </CodeGroup>
  777. <CodeGroup title="レスポンス">
  778. ```json {{ title: 'Response' }}
  779. {
  780. "data": [
  781. {
  782. "id": "",
  783. "position": 1,
  784. "data_source_type": "file_upload",
  785. "data_source_info": null,
  786. "dataset_process_rule_id": null,
  787. "name": "dify",
  788. "created_from": "",
  789. "created_by": "",
  790. "created_at": 1681623639,
  791. "tokens": 0,
  792. "indexing_status": "waiting",
  793. "error": null,
  794. "enabled": true,
  795. "disabled_at": null,
  796. "disabled_by": null,
  797. "archived": false
  798. },
  799. ],
  800. "has_more": false,
  801. "limit": 20,
  802. "total": 9,
  803. "page": 1
  804. }
  805. ```
  806. </CodeGroup>
  807. </Col>
  808. </Row>
  809. <hr className='ml-0 mr-0' />
  810. <Heading
  811. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  812. method='POST'
  813. title='ドキュメントにチャンクを追加'
  814. name='#create_new_segment'
  815. />
  816. <Row>
  817. <Col>
  818. ### パラメータ
  819. <Properties>
  820. <Property name='dataset_id' type='string' key='dataset_id'>
  821. ナレッジ ID
  822. </Property>
  823. <Property name='document_id' type='string' key='document_id'>
  824. ドキュメント ID
  825. </Property>
  826. </Properties>
  827. ### リクエストボディ
  828. <Properties>
  829. <Property name='segments' type='object list' key='segments'>
  830. - <code>content</code> (text) テキスト内容 / 質問内容、必須
  831. - <code>answer</code> (text) 回答内容、ナレッジのモードが Q&A モードの場合に値を渡します (オプション)
  832. - <code>keywords</code> (list) キーワード (オプション)
  833. </Property>
  834. </Properties>
  835. </Col>
  836. <Col sticky>
  837. <CodeGroup
  838. title="リクエスト"
  839. tag="POST"
  840. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  841. 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"]}]}'`}
  842. >
  843. ```bash {{ title: 'cURL' }}
  844. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  845. --header 'Authorization: Bearer {api_key}' \
  846. --header 'Content-Type: application/json' \
  847. --data-raw '{
  848. "segments": [
  849. {
  850. "content": "1",
  851. "answer": "1",
  852. "keywords": ["a"]
  853. }
  854. ]
  855. }'
  856. ```
  857. </CodeGroup>
  858. <CodeGroup title="レスポンス">
  859. ```json {{ title: 'Response' }}
  860. {
  861. "data": [{
  862. "id": "",
  863. "position": 1,
  864. "document_id": "",
  865. "content": "1",
  866. "answer": "1",
  867. "word_count": 25,
  868. "tokens": 0,
  869. "keywords": [
  870. "a"
  871. ],
  872. "index_node_id": "",
  873. "index_node_hash": "",
  874. "hit_count": 0,
  875. "enabled": true,
  876. "disabled_at": null,
  877. "disabled_by": null,
  878. "status": "completed",
  879. "created_by": "",
  880. "created_at": 1695312007,
  881. "indexing_at": 1695312007,
  882. "completed_at": 1695312007,
  883. "error": null,
  884. "stopped_at": null
  885. }],
  886. "doc_form": "text_model"
  887. }
  888. ```
  889. </CodeGroup>
  890. </Col>
  891. </Row>
  892. <hr className='ml-0 mr-0' />
  893. <Heading
  894. url='/datasets/{dataset_id}/documents/{document_id}/segments'
  895. method='GET'
  896. title='ドキュメントからチャンクを取得'
  897. name='#get_segment'
  898. />
  899. <Row>
  900. <Col>
  901. ### パス
  902. <Properties>
  903. <Property name='dataset_id' type='string' key='dataset_id'>
  904. ナレッジ ID
  905. </Property>
  906. <Property name='document_id' type='string' key='document_id'>
  907. ドキュメント ID
  908. </Property>
  909. </Properties>
  910. ### クエリ
  911. <Properties>
  912. <Property name='keyword' type='string' key='keyword'>
  913. キーワード (オプション)
  914. </Property>
  915. <Property name='status' type='string' key='status'>
  916. 検索ステータス、completed
  917. </Property>
  918. <Property name='page' type='string' key='page'>
  919. ページ番号 (オプション)
  920. </Property>
  921. <Property name='limit' type='string' key='limit'>
  922. 返されるアイテム数、デフォルトは 20、範囲は 1-100 (オプション)
  923. </Property>
  924. </Properties>
  925. </Col>
  926. <Col sticky>
  927. <CodeGroup
  928. title="リクエスト"
  929. tag="GET"
  930. label="/datasets/{dataset_id}/documents/{document_id}/segments"
  931. 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'`}
  932. >
  933. ```bash {{ title: 'cURL' }}
  934. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
  935. --header 'Authorization: Bearer {api_key}' \
  936. --header 'Content-Type: application/json'
  937. ```
  938. </CodeGroup>
  939. <CodeGroup title="レスポンス">
  940. ```json {{ title: 'Response' }}
  941. {
  942. "data": [{
  943. "id": "",
  944. "position": 1,
  945. "document_id": "",
  946. "content": "1",
  947. "answer": "1",
  948. "word_count": 25,
  949. "tokens": 0,
  950. "keywords": [
  951. "a"
  952. ],
  953. "index_node_id": "",
  954. "index_node_hash": "",
  955. "hit_count": 0,
  956. "enabled": true,
  957. "disabled_at": null,
  958. "disabled_by": null,
  959. "status": "completed",
  960. "created_by": "",
  961. "created_at": 1695312007,
  962. "indexing_at": 1695312007,
  963. "completed_at": 1695312007,
  964. "error": null,
  965. "stopped_at": null
  966. }],
  967. "doc_form": "text_model",
  968. "has_more": false,
  969. "limit": 20,
  970. "total": 9,
  971. "page": 1
  972. }
  973. ```
  974. </CodeGroup>
  975. </Col>
  976. </Row>
  977. <hr className='ml-0 mr-0' />
  978. <Heading
  979. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  980. method='DELETE'
  981. title='ドキュメント内のチャンクを削除'
  982. name='#delete_segment'
  983. />
  984. <Row>
  985. <Col>
  986. ### パス
  987. <Properties>
  988. <Property name='dataset_id' type='string' key='dataset_id'>
  989. ナレッジ ID
  990. </Property>
  991. <Property name='document_id' type='string' key='document_id'>
  992. ドキュメント ID
  993. </Property>
  994. <Property name='segment_id' type='string' key='segment_id'>
  995. ドキュメントセグメント ID
  996. </Property>
  997. </Properties>
  998. </Col>
  999. <Col sticky>
  1000. <CodeGroup
  1001. title="リクエスト"
  1002. tag="DELETE"
  1003. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1004. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1005. >
  1006. ```bash {{ title: 'cURL' }}
  1007. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \
  1008. --header 'Authorization: Bearer {api_key}' \
  1009. --header 'Content-Type: application/json'
  1010. ```
  1011. </CodeGroup>
  1012. <CodeGroup title="レスポンス">
  1013. ```json {{ title: 'Response' }}
  1014. {
  1015. "result": "success"
  1016. }
  1017. ```
  1018. </CodeGroup>
  1019. </Col>
  1020. </Row>
  1021. <hr className='ml-0 mr-0' />
  1022. <Heading
  1023. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
  1024. method='POST'
  1025. title='ドキュメント内のチャンクを更新'
  1026. name='#update_segment'
  1027. />
  1028. <Row>
  1029. <Col>
  1030. ### POST
  1031. <Properties>
  1032. <Property name='dataset_id' type='string' key='dataset_id'>
  1033. ナレッジ ID
  1034. </Property>
  1035. <Property name='document_id' type='string' key='document_id'>
  1036. ドキュメント ID
  1037. </Property>
  1038. <Property name='segment_id' type='string' key='segment_id'>
  1039. ドキュメントセグメント ID
  1040. </Property>
  1041. </Properties>
  1042. ### リクエストボディ
  1043. <Properties>
  1044. <Property name='segment' type='object' key='segment'>
  1045. - <code>content</code> (text) テキスト内容 / 質問内容、必須
  1046. - <code>answer</code> (text) 回答内容、ナレッジが Q&A モードの場合に値を渡します (オプション)
  1047. - <code>keywords</code> (list) キーワード (オプション)
  1048. - <code>enabled</code> (bool) False / true (オプション)
  1049. - <code>regenerate_child_chunks</code> (bool) 子チャンクを再生成するかどうか (オプション)
  1050. </Property>
  1051. </Properties>
  1052. </Col>
  1053. <Col sticky>
  1054. <CodeGroup
  1055. title="リクエスト"
  1056. tag="POST"
  1057. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
  1058. 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}}'`}
  1059. >
  1060. ```bash {{ title: 'cURL' }}
  1061. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
  1062. --header 'Content-Type: application/json' \
  1063. --data-raw '{
  1064. "segment": {
  1065. "content": "1",
  1066. "answer": "1",
  1067. "keywords": ["a"],
  1068. "enabled": false
  1069. }
  1070. }'
  1071. ```
  1072. </CodeGroup>
  1073. <CodeGroup title="レスポンス">
  1074. ```json {{ title: 'Response' }}
  1075. {
  1076. "data": {
  1077. "id": "",
  1078. "position": 1,
  1079. "document_id": "",
  1080. "content": "1",
  1081. "answer": "1",
  1082. "word_count": 25,
  1083. "tokens": 0,
  1084. "keywords": [
  1085. "a"
  1086. ],
  1087. "index_node_id": "",
  1088. "index_node_hash": "",
  1089. "hit_count": 0,
  1090. "enabled": true,
  1091. "disabled_at": null,
  1092. "disabled_by": null,
  1093. "status": "completed",
  1094. "created_by": "",
  1095. "created_at": 1695312007,
  1096. "indexing_at": 1695312007,
  1097. "completed_at": 1695312007,
  1098. "error": null,
  1099. "stopped_at": null
  1100. },
  1101. "doc_form": "text_model"
  1102. }
  1103. ```
  1104. </CodeGroup>
  1105. </Col>
  1106. </Row>
  1107. <hr className='ml-0 mr-0' />
  1108. <Heading
  1109. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1110. method='POST'
  1111. title='子チャンクを作成'
  1112. name='#create_child_chunk'
  1113. />
  1114. <Row>
  1115. <Col>
  1116. ### パラメータ
  1117. <Properties>
  1118. <Property name='dataset_id' type='string' key='dataset_id'>
  1119. ナレッジ ID
  1120. </Property>
  1121. <Property name='document_id' type='string' key='document_id'>
  1122. ドキュメント ID
  1123. </Property>
  1124. <Property name='segment_id' type='string' key='segment_id'>
  1125. セグメント ID
  1126. </Property>
  1127. </Properties>
  1128. ### リクエストボディ
  1129. <Properties>
  1130. <Property name='content' type='string' key='content'>
  1131. 子チャンクの内容
  1132. </Property>
  1133. </Properties>
  1134. </Col>
  1135. <Col sticky>
  1136. <CodeGroup
  1137. title="リクエスト"
  1138. tag="POST"
  1139. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1140. 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"}'`}
  1141. >
  1142. ```bash {{ title: 'cURL' }}
  1143. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \
  1144. --header 'Authorization: Bearer {api_key}' \
  1145. --header 'Content-Type: application/json' \
  1146. --data-raw '{
  1147. "content": "Child chunk content"
  1148. }'
  1149. ```
  1150. </CodeGroup>
  1151. <CodeGroup title="レスポンス">
  1152. ```json {{ title: 'Response' }}
  1153. {
  1154. "data": {
  1155. "id": "",
  1156. "segment_id": "",
  1157. "content": "Child chunk content",
  1158. "word_count": 25,
  1159. "tokens": 0,
  1160. "index_node_id": "",
  1161. "index_node_hash": "",
  1162. "status": "completed",
  1163. "created_by": "",
  1164. "created_at": 1695312007,
  1165. "indexing_at": 1695312007,
  1166. "completed_at": 1695312007,
  1167. "error": null,
  1168. "stopped_at": null
  1169. }
  1170. }
  1171. ```
  1172. </CodeGroup>
  1173. </Col>
  1174. </Row>
  1175. <hr className='ml-0 mr-0' />
  1176. <Heading
  1177. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks'
  1178. method='GET'
  1179. title='子チャンクを取得'
  1180. name='#get_child_chunks'
  1181. />
  1182. <Row>
  1183. <Col>
  1184. ### パラメータ
  1185. <Properties>
  1186. <Property name='dataset_id' type='string' key='dataset_id'>
  1187. ナレッジ ID
  1188. </Property>
  1189. <Property name='document_id' type='string' key='document_id'>
  1190. ドキュメント ID
  1191. </Property>
  1192. <Property name='segment_id' type='string' key='segment_id'>
  1193. セグメント ID
  1194. </Property>
  1195. </Properties>
  1196. ### クエリ
  1197. <Properties>
  1198. <Property name='keyword' type='string' key='keyword'>
  1199. 検索キーワード (オプション)
  1200. </Property>
  1201. <Property name='page' type='integer' key='page'>
  1202. ページ番号 (オプション、デフォルト: 1)
  1203. </Property>
  1204. <Property name='limit' type='integer' key='limit'>
  1205. ページあたりのアイテム数 (オプション、デフォルト: 20、最大: 100)
  1206. </Property>
  1207. </Properties>
  1208. </Col>
  1209. <Col sticky>
  1210. <CodeGroup
  1211. title="リクエスト"
  1212. tag="GET"
  1213. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks"
  1214. 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}'`}
  1215. >
  1216. ```bash {{ title: 'cURL' }}
  1217. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \
  1218. --header 'Authorization: Bearer {api_key}'
  1219. ```
  1220. </CodeGroup>
  1221. <CodeGroup title="レスポンス">
  1222. ```json {{ title: 'Response' }}
  1223. {
  1224. "data": [{
  1225. "id": "",
  1226. "segment_id": "",
  1227. "content": "Child chunk content",
  1228. "word_count": 25,
  1229. "tokens": 0,
  1230. "index_node_id": "",
  1231. "index_node_hash": "",
  1232. "status": "completed",
  1233. "created_by": "",
  1234. "created_at": 1695312007,
  1235. "indexing_at": 1695312007,
  1236. "completed_at": 1695312007,
  1237. "error": null,
  1238. "stopped_at": null
  1239. }],
  1240. "total": 1,
  1241. "total_pages": 1,
  1242. "page": 1,
  1243. "limit": 20
  1244. }
  1245. ```
  1246. </CodeGroup>
  1247. </Col>
  1248. </Row>
  1249. <hr className='ml-0 mr-0' />
  1250. <Heading
  1251. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1252. method='DELETE'
  1253. title='子チャンクを削除'
  1254. name='#delete_child_chunk'
  1255. />
  1256. <Row>
  1257. <Col>
  1258. ### パラメータ
  1259. <Properties>
  1260. <Property name='dataset_id' type='string' key='dataset_id'>
  1261. ナレッジ ID
  1262. </Property>
  1263. <Property name='document_id' type='string' key='document_id'>
  1264. ドキュメント ID
  1265. </Property>
  1266. <Property name='segment_id' type='string' key='segment_id'>
  1267. セグメント ID
  1268. </Property>
  1269. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1270. 子チャンク ID
  1271. </Property>
  1272. </Properties>
  1273. </Col>
  1274. <Col sticky>
  1275. <CodeGroup
  1276. title="リクエスト"
  1277. tag="DELETE"
  1278. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1279. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1280. >
  1281. ```bash {{ title: 'cURL' }}
  1282. curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1283. --header 'Authorization: Bearer {api_key}'
  1284. ```
  1285. </CodeGroup>
  1286. <CodeGroup title="レスポンス">
  1287. ```json {{ title: 'Response' }}
  1288. {
  1289. "result": "success"
  1290. }
  1291. ```
  1292. </CodeGroup>
  1293. </Col>
  1294. </Row>
  1295. <hr className='ml-0 mr-0' />
  1296. <Heading
  1297. url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}'
  1298. method='PATCH'
  1299. title='子チャンクを更新'
  1300. name='#update_child_chunk'
  1301. />
  1302. <Row>
  1303. <Col>
  1304. ### パラメータ
  1305. <Properties>
  1306. <Property name='dataset_id' type='string' key='dataset_id'>
  1307. ナレッジ ID
  1308. </Property>
  1309. <Property name='document_id' type='string' key='document_id'>
  1310. ドキュメント ID
  1311. </Property>
  1312. <Property name='segment_id' type='string' key='segment_id'>
  1313. セグメント ID
  1314. </Property>
  1315. <Property name='child_chunk_id' type='string' key='child_chunk_id'>
  1316. 子チャンク ID
  1317. </Property>
  1318. </Properties>
  1319. ### リクエストボディ
  1320. <Properties>
  1321. <Property name='content' type='string' key='content'>
  1322. 子チャンクの内容
  1323. </Property>
  1324. </Properties>
  1325. </Col>
  1326. <Col sticky>
  1327. <CodeGroup
  1328. title="リクエスト"
  1329. tag="PATCH"
  1330. label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}"
  1331. 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"}'`}
  1332. >
  1333. ```bash {{ title: 'cURL' }}
  1334. curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
  1335. --header 'Authorization: Bearer {api_key}' \
  1336. --header 'Content-Type: application/json' \
  1337. --data-raw '{
  1338. "content": "Updated child chunk content"
  1339. }'
  1340. ```
  1341. </CodeGroup>
  1342. <CodeGroup title="レスポンス">
  1343. ```json {{ title: 'Response' }}
  1344. {
  1345. "data": {
  1346. "id": "",
  1347. "segment_id": "",
  1348. "content": "Updated child chunk content",
  1349. "word_count": 25,
  1350. "tokens": 0,
  1351. "index_node_id": "",
  1352. "index_node_hash": "",
  1353. "status": "completed",
  1354. "created_by": "",
  1355. "created_at": 1695312007,
  1356. "indexing_at": 1695312007,
  1357. "completed_at": 1695312007,
  1358. "error": null,
  1359. "stopped_at": null
  1360. }
  1361. }
  1362. ```
  1363. </CodeGroup>
  1364. </Col>
  1365. </Row>
  1366. <hr className='ml-0 mr-0' />
  1367. <Heading
  1368. url='/datasets/{dataset_id}/documents/{document_id}/upload-file'
  1369. method='GET'
  1370. title='アップロードファイルを取得'
  1371. name='#get_upload_file'
  1372. />
  1373. <Row>
  1374. <Col>
  1375. ### パス
  1376. <Properties>
  1377. <Property name='dataset_id' type='string' key='dataset_id'>
  1378. ナレッジ ID
  1379. </Property>
  1380. <Property name='document_id' type='string' key='document_id'>
  1381. ドキュメント ID
  1382. </Property>
  1383. </Properties>
  1384. </Col>
  1385. <Col sticky>
  1386. <CodeGroup
  1387. title="リクエスト"
  1388. tag="GET"
  1389. label="/datasets/{dataset_id}/documents/{document_id}/upload-file"
  1390. 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'`}
  1391. >
  1392. ```bash {{ title: 'cURL' }}
  1393. curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \
  1394. --header 'Authorization: Bearer {api_key}' \
  1395. --header 'Content-Type: application/json'
  1396. ```
  1397. </CodeGroup>
  1398. <CodeGroup title="レスポンス">
  1399. ```json {{ title: 'Response' }}
  1400. {
  1401. "id": "file_id",
  1402. "name": "file_name",
  1403. "size": 1024,
  1404. "extension": "txt",
  1405. "url": "preview_url",
  1406. "download_url": "download_url",
  1407. "mime_type": "text/plain",
  1408. "created_by": "user_id",
  1409. "created_at": 1728734540,
  1410. }
  1411. ```
  1412. </CodeGroup>
  1413. </Col>
  1414. </Row>
  1415. <hr className='ml-0 mr-0' />
  1416. <Heading
  1417. url='/datasets/{dataset_id}/retrieve'
  1418. method='POST'
  1419. title='ナレッジベースからチャンクを取得'
  1420. name='#dataset_retrieval'
  1421. />
  1422. <Row>
  1423. <Col>
  1424. ### パス
  1425. <Properties>
  1426. <Property name='dataset_id' type='string' key='dataset_id'>
  1427. ナレッジ ID
  1428. </Property>
  1429. </Properties>
  1430. ### リクエストボディ
  1431. <Properties>
  1432. <Property name='query' type='string' key='query'>
  1433. クエリキーワード
  1434. </Property>
  1435. <Property name='retrieval_model' type='object' key='retrieval_model'>
  1436. 検索モデル (オプション、入力されない場合はデフォルトの方法でリコールされます)
  1437. - <code>search_method</code> (text) 検索方法: 以下の 4 つのキーワードのいずれかが必要です
  1438. - <code>keyword_search</code> キーワード検索
  1439. - <code>semantic_search</code> セマンティック検索
  1440. - <code>full_text_search</code> 全文検索
  1441. - <code>hybrid_search</code> ハイブリッド検索
  1442. - <code>reranking_enable</code> (bool) 再ランキングを有効にするかどうか、検索モードが semantic_search または hybrid_search の場合に必須 (オプション)
  1443. - <code>reranking_mode</code> (object) 再ランキングモデル構成、再ランキングが有効な場合に必須
  1444. - <code>reranking_provider_name</code> (string) 再ランキングモデルプロバイダー
  1445. - <code>reranking_model_name</code> (string) 再ランキングモデル名
  1446. - <code>weights</code> (float) ハイブリッド検索モードでのセマンティック検索の重み設定
  1447. - <code>top_k</code> (integer) 返される結果の数 (オプション)
  1448. - <code>score_threshold_enabled</code> (bool) スコア閾値を有効にするかどうか
  1449. - <code>score_threshold</code> (float) スコア閾値
  1450. </Property>
  1451. <Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
  1452. 未使用フィールド
  1453. </Property>
  1454. </Properties>
  1455. </Col>
  1456. <Col sticky>
  1457. <CodeGroup
  1458. title="リクエスト"
  1459. tag="POST"
  1460. label="/datasets/{dataset_id}/retrieve"
  1461. 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 '{
  1462. "query": "test",
  1463. "retrieval_model": {
  1464. "search_method": "keyword_search",
  1465. "reranking_enable": false,
  1466. "reranking_mode": null,
  1467. "reranking_model": {
  1468. "reranking_provider_name": "",
  1469. "reranking_model_name": ""
  1470. },
  1471. "weights": null,
  1472. "top_k": 1,
  1473. "score_threshold_enabled": false,
  1474. "score_threshold": null
  1475. }
  1476. }'`}
  1477. >
  1478. ```bash {{ title: 'cURL' }}
  1479. curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
  1480. --header 'Authorization: Bearer {api_key}' \
  1481. --header 'Content-Type: application/json' \
  1482. --data-raw '{
  1483. "query": "test",
  1484. "retrieval_model": {
  1485. "search_method": "keyword_search",
  1486. "reranking_enable": false,
  1487. "reranking_mode": null,
  1488. "reranking_model": {
  1489. "reranking_provider_name": "",
  1490. "reranking_model_name": ""
  1491. },
  1492. "weights": null,
  1493. "top_k": 2,
  1494. "score_threshold_enabled": false,
  1495. "score_threshold": null
  1496. }
  1497. }'
  1498. ```
  1499. </CodeGroup>
  1500. <CodeGroup title="レスポンス">
  1501. ```json {{ title: 'Response' }}
  1502. {
  1503. "query": {
  1504. "content": "test"
  1505. },
  1506. "records": [
  1507. {
  1508. "segment": {
  1509. "id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
  1510. "position": 1,
  1511. "document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1512. "content": "Operation guide",
  1513. "answer": null,
  1514. "word_count": 847,
  1515. "tokens": 280,
  1516. "keywords": [
  1517. "install",
  1518. "java",
  1519. "base",
  1520. "scripts",
  1521. "jdk",
  1522. "manual",
  1523. "internal",
  1524. "opens",
  1525. "add",
  1526. "vmoptions"
  1527. ],
  1528. "index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
  1529. "index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
  1530. "hit_count": 0,
  1531. "enabled": true,
  1532. "disabled_at": null,
  1533. "disabled_by": null,
  1534. "status": "completed",
  1535. "created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
  1536. "created_at": 1728734540,
  1537. "indexing_at": 1728734552,
  1538. "completed_at": 1728734584,
  1539. "error": null,
  1540. "stopped_at": null,
  1541. "document": {
  1542. "id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
  1543. "data_source_type": "upload_file",
  1544. "name": "readme.txt",
  1545. }
  1546. },
  1547. "score": 3.730463140527718e-05,
  1548. "tsne_position": null
  1549. }
  1550. ]
  1551. }
  1552. ```
  1553. </CodeGroup>
  1554. </Col>
  1555. </Row>
  1556. <hr className='ml-0 mr-0' />
  1557. <Heading
  1558. url='/datasets/{dataset_id}/metadata'
  1559. method='POST'
  1560. title='ナレッジメタデータを作成'
  1561. name='#create_metadata'
  1562. />
  1563. <Row>
  1564. <Col>
  1565. ### パラメータ
  1566. <Properties>
  1567. <Property name='dataset_id' type='string' key='dataset_id'>
  1568. ナレッジ ID
  1569. </Property>
  1570. </Properties>
  1571. ### リクエストボディ
  1572. <Properties>
  1573. <Property name='segment' type='object' key='segment'>
  1574. - <code>type</code> (string) メタデータの種類、必須
  1575. - <code>name</code> (string) メタデータの名前、必須
  1576. </Property>
  1577. </Properties>
  1578. </Col>
  1579. <Col sticky>
  1580. <CodeGroup
  1581. title="リクエスト"
  1582. tag="POST"
  1583. label="/datasets/{dataset_id}/metadata"
  1584. 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"}'`}
  1585. >
  1586. ```bash {{ title: 'cURL' }}
  1587. ```
  1588. </CodeGroup>
  1589. <CodeGroup title="レスポンス">
  1590. ```json {{ title: 'Response' }}
  1591. {
  1592. "id": "abc",
  1593. "type": "string",
  1594. "name": "test",
  1595. }
  1596. ```
  1597. </CodeGroup>
  1598. </Col>
  1599. </Row>
  1600. <hr className='ml-0 mr-0' />
  1601. <Heading
  1602. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  1603. method='PATCH'
  1604. title='ナレッジメタデータを更新'
  1605. name='#update_metadata'
  1606. />
  1607. <Row>
  1608. <Col>
  1609. ### パラメータ
  1610. <Properties>
  1611. <Property name='dataset_id' type='string' key='dataset_id'>
  1612. ナレッジ ID
  1613. </Property>
  1614. <Property name='metadata_id' type='string' key='metadata_id'>
  1615. メタデータ ID
  1616. </Property>
  1617. </Properties>
  1618. ### リクエストボディ
  1619. <Properties>
  1620. <Property name='segment' type='object' key='segment'>
  1621. - <code>name</code> (string) メタデータの名前、必須
  1622. </Property>
  1623. </Properties>
  1624. </Col>
  1625. <Col sticky>
  1626. <CodeGroup
  1627. title="リクエスト"
  1628. tag="POST"
  1629. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  1630. targetCode={`curl --location --request POST '${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"}'`}
  1631. >
  1632. ```bash {{ title: 'cURL' }}
  1633. ```
  1634. </CodeGroup>
  1635. <CodeGroup title="レスポンス">
  1636. ```json {{ title: 'Response' }}
  1637. {
  1638. "id": "abc",
  1639. "type": "string",
  1640. "name": "test",
  1641. }
  1642. ```
  1643. </CodeGroup>
  1644. </Col>
  1645. </Row>
  1646. <hr className='ml-0 mr-0' />
  1647. <Heading
  1648. url='/datasets/{dataset_id}/metadata/{metadata_id}'
  1649. method='DELETE'
  1650. title='ナレッジメタデータを削除'
  1651. name='#delete_metadata'
  1652. />
  1653. <Row>
  1654. <Col>
  1655. ### パラメータ
  1656. <Properties>
  1657. <Property name='dataset_id' type='string' key='dataset_id'>
  1658. ナレッジ ID
  1659. </Property>
  1660. <Property name='metadata_id' type='string' key='metadata_id'>
  1661. メタデータ ID
  1662. </Property>
  1663. </Properties>
  1664. </Col>
  1665. <Col sticky>
  1666. <CodeGroup
  1667. title="リクエスト"
  1668. tag="DELETE"
  1669. label="/datasets/{dataset_id}/metadata/{metadata_id}"
  1670. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1671. >
  1672. ```bash {{ title: 'cURL' }}
  1673. ```
  1674. </CodeGroup>
  1675. </Col>
  1676. </Row>
  1677. <hr className='ml-0 mr-0' />
  1678. <Heading
  1679. url='/datasets/{dataset_id}/metadata/built-in/{action}'
  1680. method='POST'
  1681. title='組み込みメタデータを無効化または有効化'
  1682. name='#toggle_metadata'
  1683. />
  1684. <Row>
  1685. <Col>
  1686. ### パラメータ
  1687. <Properties>
  1688. <Property name='dataset_id' type='string' key='dataset_id'>
  1689. ナレッジ ID
  1690. </Property>
  1691. <Property name='action' type='string' key='action'>
  1692. disable/enable
  1693. </Property>
  1694. </Properties>
  1695. </Col>
  1696. <Col sticky>
  1697. <CodeGroup
  1698. title="リクエスト"
  1699. tag="POST"
  1700. label="/datasets/{dataset_id}/metadata/built-in/{action}"
  1701. targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1702. >
  1703. ```bash {{ title: 'cURL' }}
  1704. ```
  1705. </CodeGroup>
  1706. </Col>
  1707. </Row>
  1708. <hr className='ml-0 mr-0' />
  1709. <Heading
  1710. url='/datasets/{dataset_id}/documents/metadata'
  1711. method='POST'
  1712. title='ドキュメントメタデータを更新'
  1713. name='#update_documents_metadata'
  1714. />
  1715. <Row>
  1716. <Col>
  1717. ### パラメータ
  1718. <Properties>
  1719. <Property name='dataset_id' type='string' key='dataset_id'>
  1720. ナレッジ ID
  1721. </Property>
  1722. </Properties>
  1723. ### リクエストボディ
  1724. <Properties>
  1725. <Property name='operation_data' type='object list' key='segments'>
  1726. - <code>document_id</code> (string) ドキュメント ID
  1727. - <code>metadata_list</code> (list) メタデータリスト
  1728. - <code>id</code> (string) メタデータ ID
  1729. - <code>value</code> (string) メタデータの値
  1730. - <code>name</code> (string) メタデータの名前
  1731. </Property>
  1732. </Properties>
  1733. </Col>
  1734. <Col sticky>
  1735. <CodeGroup
  1736. title="リクエスト"
  1737. tag="POST"
  1738. label="/datasets/{dataset_id}/documents/metadata"
  1739. 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"}]}]}'`}
  1740. >
  1741. ```bash {{ title: 'cURL' }}
  1742. ```
  1743. </CodeGroup>
  1744. </Col>
  1745. </Row>
  1746. <hr className='ml-0 mr-0' />
  1747. <Heading
  1748. url='/datasets/{dataset_id}/metadata'
  1749. method='GET'
  1750. title='ナレッジメタデータリストを取得'
  1751. name='#dataset_metadata_list'
  1752. />
  1753. <Row>
  1754. <Col>
  1755. ### パラメータ
  1756. <Properties>
  1757. <Property name='dataset_id' type='string' key='dataset_id'>
  1758. ナレッジ ID
  1759. </Property>
  1760. </Properties>
  1761. </Col>
  1762. <Col sticky>
  1763. <CodeGroup
  1764. title="リクエスト"
  1765. tag="GET"
  1766. label="/datasets/{dataset_id}/metadata"
  1767. targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
  1768. >
  1769. ```bash {{ title: 'cURL' }}
  1770. ```
  1771. </CodeGroup>
  1772. <CodeGroup title="レスポンス">
  1773. ```json {{ title: 'Response' }}
  1774. {
  1775. "doc_metadata": [
  1776. {
  1777. "id": "",
  1778. "name": "name",
  1779. "type": "string",
  1780. "use_count": 0,
  1781. },
  1782. ...
  1783. ],
  1784. "built_in_field_enabled": true
  1785. }
  1786. ```
  1787. </CodeGroup>
  1788. </Col>
  1789. </Row>
  1790. <hr className='ml-0 mr-0' />
  1791. <Row>
  1792. <Col>
  1793. ### エラーメッセージ
  1794. <Properties>
  1795. <Property name='code' type='string' key='code'>
  1796. エラーコード
  1797. </Property>
  1798. </Properties>
  1799. <Properties>
  1800. <Property name='status' type='number' key='status'>
  1801. エラーステータス
  1802. </Property>
  1803. </Properties>
  1804. <Properties>
  1805. <Property name='message' type='string' key='message'>
  1806. エラーメッセージ
  1807. </Property>
  1808. </Properties>
  1809. </Col>
  1810. <Col>
  1811. <CodeGroup title="例">
  1812. ```json {{ title: 'Response' }}
  1813. {
  1814. "code": "no_file_uploaded",
  1815. "message": "Please upload your file.",
  1816. "status": 400
  1817. }
  1818. ```
  1819. </CodeGroup>
  1820. </Col>
  1821. </Row>
  1822. <table className="max-w-auto border-collapse border border-slate-400" style={{ maxWidth: 'none', width: 'auto' }}>
  1823. <thead style={{ background: '#f9fafc' }}>
  1824. <tr>
  1825. <th className="p-2 border border-slate-300">code</th>
  1826. <th className="p-2 border border-slate-300">status</th>
  1827. <th className="p-2 border border-slate-300">message</th>
  1828. </tr>
  1829. </thead>
  1830. <tbody>
  1831. <tr>
  1832. <td className="p-2 border border-slate-300">no_file_uploaded</td>
  1833. <td className="p-2 border border-slate-300">400</td>
  1834. <td className="p-2 border border-slate-300">Please upload your file.</td>
  1835. </tr>
  1836. <tr>
  1837. <td className="p-2 border border-slate-300">too_many_files</td>
  1838. <td className="p-2 border border-slate-300">400</td>
  1839. <td className="p-2 border border-slate-300">Only one file is allowed.</td>
  1840. </tr>
  1841. <tr>
  1842. <td className="p-2 border border-slate-300">file_too_large</td>
  1843. <td className="p-2 border border-slate-300">413</td>
  1844. <td className="p-2 border border-slate-300">File size exceeded.</td>
  1845. </tr>
  1846. <tr>
  1847. <td className="p-2 border border-slate-300">unsupported_file_type</td>
  1848. <td className="p-2 border border-slate-300">415</td>
  1849. <td className="p-2 border border-slate-300">File type not allowed.</td>
  1850. </tr>
  1851. <tr>
  1852. <td className="p-2 border border-slate-300">high_quality_dataset_only</td>
  1853. <td className="p-2 border border-slate-300">400</td>
  1854. <td className="p-2 border border-slate-300">Current operation only supports 'high-quality' datasets.</td>
  1855. </tr>
  1856. <tr>
  1857. <td className="p-2 border border-slate-300">dataset_not_initialized</td>
  1858. <td className="p-2 border border-slate-300">400</td>
  1859. <td className="p-2 border border-slate-300">The dataset is still being initialized or indexing. Please wait a moment.</td>
  1860. </tr>
  1861. <tr>
  1862. <td className="p-2 border border-slate-300">archived_document_immutable</td>
  1863. <td className="p-2 border border-slate-300">403</td>
  1864. <td className="p-2 border border-slate-300">The archived document is not editable.</td>
  1865. </tr>
  1866. <tr>
  1867. <td className="p-2 border border-slate-300">dataset_name_duplicate</td>
  1868. <td className="p-2 border border-slate-300">409</td>
  1869. <td className="p-2 border border-slate-300">The dataset name already exists. Please modify your dataset name.</td>
  1870. </tr>
  1871. <tr>
  1872. <td className="p-2 border border-slate-300">invalid_action</td>
  1873. <td className="p-2 border border-slate-300">400</td>
  1874. <td className="p-2 border border-slate-300">Invalid action.</td>
  1875. </tr>
  1876. <tr>
  1877. <td className="p-2 border border-slate-300">document_already_finished</td>
  1878. <td className="p-2 border border-slate-300">400</td>
  1879. <td className="p-2 border border-slate-300">The document has been processed. Please refresh the page or go to the document details.</td>
  1880. </tr>
  1881. <tr>
  1882. <td className="p-2 border border-slate-300">document_indexing</td>
  1883. <td className="p-2 border border-slate-300">400</td>
  1884. <td className="p-2 border border-slate-300">The document is being processed and cannot be edited.</td>
  1885. </tr>
  1886. <tr>
  1887. <td className="p-2 border border-slate-300">invalid_metadata</td>
  1888. <td className="p-2 border border-slate-300">400</td>
  1889. <td className="p-2 border border-slate-300">The metadata content is incorrect. Please check and verify.</td>
  1890. </tr>
  1891. </tbody>
  1892. </table>
  1893. <div className="pb-4" />