import { CodeGroup } from '@/app/components/develop/code.tsx'
import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstruction, Paragraph } from '@/app/components/develop/md.tsx'
# ナレッジ API
### 認証
Dify のサービス API は `API-Key` を使用して認証します。
開発者は、`API-Key` をクライアント側で共有または保存するのではなく、バックエンドに保存することを推奨します。これにより、`API-Key` の漏洩による財産損失を防ぐことができます。
すべての API リクエストには、以下のように **`Authorization`** HTTP ヘッダーに `API-Key` を含める必要があります:
```javascript
Authorization: Bearer {API_KEY}
```
この API は既存のナレッジに基づいており、このナレッジを基にテキストを使用して新しいドキュメントを作成します。
### パラメータ
ナレッジ ID
### リクエストボディ
ドキュメント名
ドキュメント内容
インデックスモード
- high_quality
高品質: 埋め込みモデルを使用してベクトルデータベースインデックスを構築
- economy
経済: キーワードテーブルインデックスの反転インデックスを構築
インデックス化された内容の形式
- text_model
テキストドキュメントは直接埋め込まれます; `economy` モードではこの形式がデフォルト
- hierarchical_model
親子モード
- qa_model
Q&A モード: 分割されたドキュメントの質問と回答ペアを生成し、質問を埋め込みます
Q&A モードでは、ドキュメントの言語を指定します。例: English
, Chinese
処理ルール
- mode
(string) クリーニング、セグメンテーションモード、自動 / カスタム
- rules
(object) カスタムルール (自動モードでは、このフィールドは空)
- pre_processing_rules
(array[object]) 前処理ルール
- id
(string) 前処理ルールの一意識別子
- 列挙
- remove_extra_spaces
連続するスペース、改行、タブを置換
- remove_urls_emails
URL、メールアドレスを削除
- enabled
(bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
- segmentation
(object) セグメンテーションルール
- separator
カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
- max_tokens
最大長 (トークン) デフォルトは 1000
- parent_mode
親チャンクの検索モード: full-doc
全文検索 / paragraph
段落検索
- subchunk_segmentation
(object) 子チャンクルール
- separator
セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは ***
- max_tokens
最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
- chunk_overlap
隣接するチャンク間の重複を定義 (オプション)
ナレッジベースにパラメータが設定されていない場合、最初のアップロードには以下のパラメータを提供する必要があります。提供されない場合、デフォルトパラメータが使用されます。
検索モデル
- search_method
(string) 検索方法
- hybrid_search
ハイブリッド検索
- semantic_search
セマンティック検索
- full_text_search
全文検索
- reranking_enable
(bool) 再ランキングを有効にするかどうか
- reranking_mode
(object) 再ランキングモデル構成
- reranking_provider_name
(string) 再ランキングモデルプロバイダー
- reranking_model_name
(string) 再ランキングモデル名
- top_k
(int) 返される結果の数
- score_threshold_enabled
(bool) スコア閾値を有効にするかどうか
- score_threshold
(float) スコア閾値
埋め込みモデル名
埋め込みモデルプロバイダー
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-text' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "text",
"text": "text",
"indexing_technique": "high_quality",
"process_rule": {
"mode": "automatic"
}
}'
```
```json {{ title: 'Response' }}
{
"document": {
"id": "",
"position": 1,
"data_source_type": "upload_file",
"data_source_info": {
"upload_file_id": ""
},
"dataset_process_rule_id": "",
"name": "text.txt",
"created_from": "api",
"created_by": "",
"created_at": 1695690280,
"tokens": 0,
"indexing_status": "waiting",
"error": null,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"archived": false,
"display_status": "queuing",
"word_count": 0,
"hit_count": 0,
"doc_form": "text_model"
},
"batch": ""
}
```
この API は既存のナレッジに基づいており、このナレッジを基にファイルを使用して新しいドキュメントを作成します。
### パラメータ
ナレッジ ID
### リクエストボディ
- original_document_id
元のドキュメント ID (オプション)
- ドキュメントを再アップロードまたはクリーニングとセグメンテーション構成を変更するために使用されます。欠落している情報は元のドキュメントからコピーされます。
- 元のドキュメントはアーカイブされたドキュメントであってはなりません。
- original_document_id が渡された場合、更新操作が実行されます。process_rule は入力可能な項目です。入力されない場合、元のドキュメントのセグメンテーション方法がデフォルトで使用されます。
- original_document_id が渡されない場合、新しい操作が実行され、process_rule が必要です。
- indexing_technique
インデックスモード
- high_quality
高品質: 埋め込みモデルを使用してベクトルデータベースインデックスを構築
- economy
経済: キーワードテーブルインデックスの反転インデックスを構築
- doc_form
インデックス化された内容の形式
- text_model
テキストドキュメントは直接埋め込まれます; `economy` モードではこの形式がデフォルト
- hierarchical_model
親子モード
- qa_model
Q&A モード: 分割されたドキュメントの質問と回答ペアを生成し、質問を埋め込みます
- doc_language
Q&A モードでは、ドキュメントの言語を指定します。例: English
, Chinese
- process_rule
処理ルール
- mode
(string) クリーニング、セグメンテーションモード、自動 / カスタム
- rules
(object) カスタムルール (自動モードでは、このフィールドは空)
- pre_processing_rules
(array[object]) 前処理ルール
- id
(string) 前処理ルールの一意識別子
- 列挙
- remove_extra_spaces
連続するスペース、改行、タブを置換
- remove_urls_emails
URL、メールアドレスを削除
- enabled
(bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
- segmentation
(object) セグメンテーションルール
- separator
カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
- max_tokens
最大長 (トークン) デフォルトは 1000
- parent_mode
親チャンクの検索モード: full-doc
全文検索 / paragraph
段落検索
- subchunk_segmentation
(object) 子チャンクルール
- separator
セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは ***
- max_tokens
最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
- chunk_overlap
隣接するチャンク間の重複を定義 (オプション)
アップロードする必要があるファイル。
ナレッジベースにパラメータが設定されていない場合、最初のアップロードには以下のパラメータを提供する必要があります。提供されない場合、デフォルトパラメータが使用されます。
検索モデル
- search_method
(string) 検索方法
- hybrid_search
ハイブリッド検索
- semantic_search
セマンティック検索
- full_text_search
全文検索
- reranking_enable
(bool) 再ランキングを有効にするかどうか
- reranking_mode
(object) 再ランキングモデル構成
- reranking_provider_name
(string) 再ランキングモデルプロバイダー
- reranking_model_name
(string) 再ランキングモデル名
- top_k
(int) 返される結果の数
- score_threshold_enabled
(bool) スコア閾値を有効にするかどうか
- score_threshold
(float) スコア閾値
埋め込みモデル名
埋め込みモデルプロバイダー
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/document/create-by-file' \
--header 'Authorization: Bearer {api_key}' \
--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' \
--form 'file=@"/path/to/file"'
```
```json {{ title: 'Response' }}
{
"document": {
"id": "",
"position": 1,
"data_source_type": "upload_file",
"data_source_info": {
"upload_file_id": ""
},
"dataset_process_rule_id": "",
"name": "Dify.txt",
"created_from": "api",
"created_by": "",
"created_at": 1695308667,
"tokens": 0,
"indexing_status": "waiting",
"error": null,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"archived": false,
"display_status": "queuing",
"word_count": 0,
"hit_count": 0,
"doc_form": "text_model"
},
"batch": ""
}
```
### リクエストボディ
ナレッジ名
ナレッジの説明 (オプション)
インデックス技術 (オプション)
- high_quality
高品質
- economy
経済
権限
- only_me
自分のみ
- all_team_members
すべてのチームメンバー
- partial_members
一部のメンバー
プロバイダー (オプション、デフォルト: vendor)
- vendor
ベンダー
- external
外部ナレッジ
外部ナレッジ API ID (オプション)
外部ナレッジ ID (オプション)
```bash {{ title: 'cURL' }}
curl --location --request POST '${apiBaseUrl}/v1/datasets' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "name",
"permission": "only_me"
}'
```
```json {{ title: 'Response' }}
{
"id": "",
"name": "name",
"description": null,
"provider": "vendor",
"permission": "only_me",
"data_source_type": null,
"indexing_technique": null,
"app_count": 0,
"document_count": 0,
"word_count": 0,
"created_by": "",
"created_at": 1695636173,
"updated_by": "",
"updated_at": 1695636173,
"embedding_model": null,
"embedding_model_provider": null,
"embedding_available": null
}
```
### クエリ
ページ番号
返されるアイテム数、デフォルトは 20、範囲は 1-100
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets?page=1&limit=20' \
--header 'Authorization: Bearer {api_key}'
```
```json {{ title: 'Response' }}
{
"data": [
{
"id": "",
"name": "name",
"description": "desc",
"permission": "only_me",
"data_source_type": "upload_file",
"indexing_technique": "",
"app_count": 2,
"document_count": 10,
"word_count": 1200,
"created_by": "",
"created_at": "",
"updated_by": "",
"updated_at": ""
},
...
],
"has_more": true,
"limit": 20,
"total": 50,
"page": 1
}
```
### パラメータ
ナレッジ ID
```bash {{ title: 'cURL' }}
curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}' \
--header 'Authorization: Bearer {api_key}'
```
```text {{ title: 'Response' }}
204 No Content
```
この API は既存のナレッジに基づいており、このナレッジを基にテキストを使用してドキュメントを更新します。
### パラメータ
ナレッジ ID
ドキュメント ID
### リクエストボディ
ドキュメント名 (オプション)
ドキュメント内容 (オプション)
処理ルール
- mode
(string) クリーニング、セグメンテーションモード、自動 / カスタム
- rules
(object) カスタムルール (自動モードでは、このフィールドは空)
- pre_processing_rules
(array[object]) 前処理ルール
- id
(string) 前処理ルールの一意識別子
- 列挙
- remove_extra_spaces
連続するスペース、改行、タブを置換
- remove_urls_emails
URL、メールアドレスを削除
- enabled
(bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
- segmentation
(object) セグメンテーションルール
- separator
カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
- max_tokens
最大長 (トークン) デフォルトは 1000
- parent_mode
親チャンクの検索モード: full-doc
全文検索 / paragraph
段落検索
- subchunk_segmentation
(object) 子チャンクルール
- separator
セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは ***
- max_tokens
最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
- chunk_overlap
隣接するチャンク間の重複を定義 (オプション)
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-text' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "name",
"text": "text"
}'
```
```json {{ title: 'Response' }}
{
"document": {
"id": "",
"position": 1,
"data_source_type": "upload_file",
"data_source_info": {
"upload_file_id": ""
},
"dataset_process_rule_id": "",
"name": "name.txt",
"created_from": "api",
"created_by": "",
"created_at": 1695308667,
"tokens": 0,
"indexing_status": "waiting",
"error": null,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"archived": false,
"display_status": "queuing",
"word_count": 0,
"hit_count": 0,
"doc_form": "text_model"
},
"batch": ""
}
```
この API は既存のナレッジに基づいており、このナレッジを基にファイルを使用してドキュメントを更新します。
### パラメータ
ナレッジ ID
ドキュメント ID
### リクエストボディ
ドキュメント名 (オプション)
アップロードするファイル
処理ルール
- mode
(string) クリーニング、セグメンテーションモード、自動 / カスタム
- rules
(object) カスタムルール (自動モードでは、このフィールドは空)
- pre_processing_rules
(array[object]) 前処理ルール
- id
(string) 前処理ルールの一意識別子
- 列挙
- remove_extra_spaces
連続するスペース、改行、タブを置換
- remove_urls_emails
URL、メールアドレスを削除
- enabled
(bool) このルールを選択するかどうか。ドキュメント ID が渡されない場合、デフォルト値を表します。
- segmentation
(object) セグメンテーションルール
- separator
カスタムセグメント識別子。現在は 1 つの区切り文字のみ設定可能。デフォルトは \n
- max_tokens
最大長 (トークン) デフォルトは 1000
- parent_mode
親チャンクの検索モード: full-doc
全文検索 / paragraph
段落検索
- subchunk_segmentation
(object) 子チャンクルール
- separator
セグメンテーション識別子。現在は 1 つの区切り文字のみ許可。デフォルトは ***
- max_tokens
最大長 (トークン) は親チャンクの長さより短いことを検証する必要があります
- chunk_overlap
隣接するチャンク間の重複を定義 (オプション)
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/update-by-file' \
--header 'Authorization: Bearer {api_key}' \
--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' \
--form 'file=@"/path/to/file"'
```
```json {{ title: 'Response' }}
{
"document": {
"id": "",
"position": 1,
"data_source_type": "upload_file",
"data_source_info": {
"upload_file_id": ""
},
"dataset_process_rule_id": "",
"name": "Dify.txt",
"created_from": "api",
"created_by": "",
"created_at": 1695308667,
"tokens": 0,
"indexing_status": "waiting",
"error": null,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"archived": false,
"display_status": "queuing",
"word_count": 0,
"hit_count": 0,
"doc_form": "text_model"
},
"batch": "20230921150427533684"
}
```
### パラメータ
ナレッジ ID
アップロードされたドキュメントのバッチ番号
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{batch}/indexing-status' \
--header 'Authorization: Bearer {api_key}' \
```
```json {{ title: 'Response' }}
{
"data":[{
"id": "",
"indexing_status": "indexing",
"processing_started_at": 1681623462.0,
"parsing_completed_at": 1681623462.0,
"cleaning_completed_at": 1681623462.0,
"splitting_completed_at": 1681623462.0,
"completed_at": null,
"paused_at": null,
"error": null,
"stopped_at": null,
"completed_segments": 24,
"total_segments": 100
}]
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
```bash {{ title: 'cURL' }}
curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}' \
--header 'Authorization: Bearer {api_key}' \
```
```json {{ title: 'Response' }}
{
"result": "success"
}
```
### パラメータ
ナレッジ ID
### クエリ
検索キーワード、現在はドキュメント名のみ検索 (オプション)
ページ番号 (オプション)
返されるアイテム数、デフォルトは 20、範囲は 1-100 (オプション)
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents' \
--header 'Authorization: Bearer {api_key}' \
```
```json {{ title: 'Response' }}
{
"data": [
{
"id": "",
"position": 1,
"data_source_type": "file_upload",
"data_source_info": null,
"dataset_process_rule_id": null,
"name": "dify",
"created_from": "",
"created_by": "",
"created_at": 1681623639,
"tokens": 0,
"indexing_status": "waiting",
"error": null,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"archived": false
},
],
"has_more": false,
"limit": 20,
"total": 9,
"page": 1
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
### リクエストボディ
- content
(text) テキスト内容 / 質問内容、必須
- answer
(text) 回答内容、ナレッジのモードが Q&A モードの場合に値を渡します (オプション)
- keywords
(list) キーワード (オプション)
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"segments": [
{
"content": "1",
"answer": "1",
"keywords": ["a"]
}
]
}'
```
```json {{ title: 'Response' }}
{
"data": [{
"id": "",
"position": 1,
"document_id": "",
"content": "1",
"answer": "1",
"word_count": 25,
"tokens": 0,
"keywords": [
"a"
],
"index_node_id": "",
"index_node_hash": "",
"hit_count": 0,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
}],
"doc_form": "text_model"
}
```
### パス
ナレッジ ID
ドキュメント ID
### クエリ
キーワード (オプション)
検索ステータス、completed
ページ番号 (オプション)
返されるアイテム数、デフォルトは 20、範囲は 1-100 (オプション)
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json'
```
```json {{ title: 'Response' }}
{
"data": [{
"id": "",
"position": 1,
"document_id": "",
"content": "1",
"answer": "1",
"word_count": 25,
"tokens": 0,
"keywords": [
"a"
],
"index_node_id": "",
"index_node_hash": "",
"hit_count": 0,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
}],
"doc_form": "text_model",
"has_more": false,
"limit": 20,
"total": 9,
"page": 1
}
```
### パス
ナレッジ ID
ドキュメント ID
ドキュメントセグメント ID
```bash {{ title: 'cURL' }}
curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json'
```
```json {{ title: 'Response' }}
{
"result": "success"
}
```
### POST
ナレッジ ID
ドキュメント ID
ドキュメントセグメント ID
### リクエストボディ
- content
(text) テキスト内容 / 質問内容、必須
- answer
(text) 回答内容、ナレッジが Q&A モードの場合に値を渡します (オプション)
- keywords
(list) キーワード (オプション)
- enabled
(bool) False / true (オプション)
- regenerate_child_chunks
(bool) 子チャンクを再生成するかどうか (オプション)
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
--header 'Content-Type: application/json' \
--data-raw '{
"segment": {
"content": "1",
"answer": "1",
"keywords": ["a"],
"enabled": false
}
}'
```
```json {{ title: 'Response' }}
{
"data": {
"id": "",
"position": 1,
"document_id": "",
"content": "1",
"answer": "1",
"word_count": 25,
"tokens": 0,
"keywords": [
"a"
],
"index_node_id": "",
"index_node_hash": "",
"hit_count": 0,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
},
"doc_form": "text_model"
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
セグメント ID
### リクエストボディ
子チャンクの内容
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": "Child chunk content"
}'
```
```json {{ title: 'Response' }}
{
"data": {
"id": "",
"segment_id": "",
"content": "Child chunk content",
"word_count": 25,
"tokens": 0,
"index_node_id": "",
"index_node_hash": "",
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
}
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
セグメント ID
### クエリ
検索キーワード (オプション)
ページ番号 (オプション、デフォルト: 1)
ページあたりのアイテム数 (オプション、デフォルト: 20、最大: 100)
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks?page=1&limit=20' \
--header 'Authorization: Bearer {api_key}'
```
```json {{ title: 'Response' }}
{
"data": [{
"id": "",
"segment_id": "",
"content": "Child chunk content",
"word_count": 25,
"tokens": 0,
"index_node_id": "",
"index_node_hash": "",
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
}],
"total": 1,
"total_pages": 1,
"page": 1,
"limit": 20
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
セグメント ID
子チャンク ID
```bash {{ title: 'cURL' }}
curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
--header 'Authorization: Bearer {api_key}'
```
```json {{ title: 'Response' }}
{
"result": "success"
}
```
### パラメータ
ナレッジ ID
ドキュメント ID
セグメント ID
子チャンク ID
### リクエストボディ
子チャンクの内容
```bash {{ title: 'cURL' }}
curl --location --request PATCH '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunks/{child_chunk_id}' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": "Updated child chunk content"
}'
```
```json {{ title: 'Response' }}
{
"data": {
"id": "",
"segment_id": "",
"content": "Updated child chunk content",
"word_count": 25,
"tokens": 0,
"index_node_id": "",
"index_node_hash": "",
"status": "completed",
"created_by": "",
"created_at": 1695312007,
"indexing_at": 1695312007,
"completed_at": 1695312007,
"error": null,
"stopped_at": null
}
}
```
### パス
ナレッジ ID
ドキュメント ID
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/upload-file' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json'
```
```json {{ title: 'Response' }}
{
"id": "file_id",
"name": "file_name",
"size": 1024,
"extension": "txt",
"url": "preview_url",
"download_url": "download_url",
"mime_type": "text/plain",
"created_by": "user_id",
"created_at": 1728734540,
}
```
### パス
ナレッジ ID
### リクエストボディ
クエリキーワード
検索モデル (オプション、入力されない場合はデフォルトの方法でリコールされます)
- search_method
(text) 検索方法: 以下の 4 つのキーワードのいずれかが必要です
- keyword_search
キーワード検索
- semantic_search
セマンティック検索
- full_text_search
全文検索
- hybrid_search
ハイブリッド検索
- reranking_enable
(bool) 再ランキングを有効にするかどうか、検索モードが semantic_search または hybrid_search の場合に必須 (オプション)
- reranking_mode
(object) 再ランキングモデル構成、再ランキングが有効な場合に必須
- reranking_provider_name
(string) 再ランキングモデルプロバイダー
- reranking_model_name
(string) 再ランキングモデル名
- weights
(float) ハイブリッド検索モードでのセマンティック検索の重み設定
- top_k
(integer) 返される結果の数 (オプション)
- score_threshold_enabled
(bool) スコア閾値を有効にするかどうか
- score_threshold
(float) スコア閾値
未使用フィールド
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/retrieve' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": "test",
"retrieval_model": {
"search_method": "keyword_search",
"reranking_enable": false,
"reranking_mode": null,
"reranking_model": {
"reranking_provider_name": "",
"reranking_model_name": ""
},
"weights": null,
"top_k": 2,
"score_threshold_enabled": false,
"score_threshold": null
}
}'
```
```json {{ title: 'Response' }}
{
"query": {
"content": "test"
},
"records": [
{
"segment": {
"id": "7fa6f24f-8679-48b3-bc9d-bdf28d73f218",
"position": 1,
"document_id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
"content": "Operation guide",
"answer": null,
"word_count": 847,
"tokens": 280,
"keywords": [
"install",
"java",
"base",
"scripts",
"jdk",
"manual",
"internal",
"opens",
"add",
"vmoptions"
],
"index_node_id": "39dd8443-d960-45a8-bb46-7275ad7fbc8e",
"index_node_hash": "0189157697b3c6a418ccf8264a09699f25858975578f3467c76d6bfc94df1d73",
"hit_count": 0,
"enabled": true,
"disabled_at": null,
"disabled_by": null,
"status": "completed",
"created_by": "dbcb1ab5-90c8-41a7-8b78-73b235eb6f6f",
"created_at": 1728734540,
"indexing_at": 1728734552,
"completed_at": 1728734584,
"error": null,
"stopped_at": null,
"document": {
"id": "a8c6c36f-9f5d-4d7a-8472-f5d7b75d71d2",
"data_source_type": "upload_file",
"name": "readme.txt",
}
},
"score": 3.730463140527718e-05,
"tsne_position": null
}
]
}
```
### パラメータ
ナレッジ ID
### リクエストボディ
- type
(string) メタデータの種類、必須
- name
(string) メタデータの名前、必須
```bash {{ title: 'cURL' }}
```
```json {{ title: 'Response' }}
{
"id": "abc",
"type": "string",
"name": "test",
}
```
### パラメータ
ナレッジ ID
メタデータ ID
### リクエストボディ
- name
(string) メタデータの名前、必須
```bash {{ title: 'cURL' }}
```
```json {{ title: 'Response' }}
{
"id": "abc",
"type": "string",
"name": "test",
}
```
### パラメータ
ナレッジ ID
メタデータ ID
```bash {{ title: 'cURL' }}
```
### パラメータ
ナレッジ ID
disable/enable
```bash {{ title: 'cURL' }}
```
### パラメータ
ナレッジ ID
### リクエストボディ
- document_id
(string) ドキュメント ID
- metadata_list
(list) メタデータリスト
- id
(string) メタデータ ID
- value
(string) メタデータの値
- name
(string) メタデータの名前
```bash {{ title: 'cURL' }}
```
### パラメータ
ナレッジ ID
```bash {{ title: 'cURL' }}
```
```json {{ title: 'Response' }}
{
"doc_metadata": [
{
"id": "",
"name": "name",
"type": "string",
"use_count": 0,
},
...
],
"built_in_field_enabled": true
}
```
### エラーメッセージ
エラーコード
エラーステータス
エラーメッセージ
```json {{ title: 'Response' }}
{
"code": "no_file_uploaded",
"message": "Please upload your file.",
"status": 400
}
```
code |
status |
message |
no_file_uploaded |
400 |
Please upload your file. |
too_many_files |
400 |
Only one file is allowed. |
file_too_large |
413 |
File size exceeded. |
unsupported_file_type |
415 |
File type not allowed. |
high_quality_dataset_only |
400 |
Current operation only supports 'high-quality' datasets. |
dataset_not_initialized |
400 |
The dataset is still being initialized or indexing. Please wait a moment. |
archived_document_immutable |
403 |
The archived document is not editable. |
dataset_name_duplicate |
409 |
The dataset name already exists. Please modify your dataset name. |
invalid_action |
400 |
Invalid action. |
document_already_finished |
400 |
The document has been processed. Please refresh the page or go to the document details. |
document_indexing |
400 |
The document is being processed and cannot be edited. |
invalid_metadata |
400 |
The metadata content is incorrect. Please check and verify. |