知識庫(新版)

建立知識庫

POST /api/knowledge-bases/

請求內容

請求參數

欄位
類型
必填
說明

embeddingModel

string (uuid)

rerankerModel

string (uuid)

name

string

description

string

numberOfRetrievedChunks

integer

提取的參考資料數量,預設為 12,最小值為 1

sentenceWindowSize

integer

RAG 擴增句子視窗大小,預設為 2,最小值為 0

enableHyde

boolean

啟用 HyDE,預設為 False

similarityCutoff

number (double)

相似度門檻,預設為 0.0,範圍為 0.0-1.0

enableRerank

boolean

是否啟用重新排序,預設為 True

elasticsearchUrl

string (uri)

Custom Elasticsearch endpoint URL. If not provided, the default system Elasticsearch will be used.

elasticsearchApiKey

string

API Key for custom Elasticsearch endpoint. Will be stored securely.

chatbots

array[IdName]

groups

array[IdName]

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


列出所有知識庫

GET /api/knowledge-bases/

參數

參數名稱
必填
類型
說明

embeddingModel

string

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

rerankerModel

string

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定知識庫詳情

GET /api/knowledge-bases/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base.

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


更新知識庫

PUT /api/knowledge-bases/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base.

請求內容

請求參數

欄位
類型
必填
說明

user

string (uuid)

organization

string (uuid)

embeddingModel

string (uuid)

rerankerModel

string (uuid)

name

string

description

string

numberOfRetrievedChunks

integer

提取的參考資料數量,預設為 12,最小值為 1

sentenceWindowSize

integer

RAG 擴增句子視窗大小,預設為 2,最小值為 0

enableHyde

boolean

啟用 HyDE,預設為 False

similarityCutoff

number (double)

相似度門檻,預設為 0.0,範圍為 0.0-1.0

enableRerank

boolean

是否啟用重新排序,預設為 True

elasticsearchUrl

string (uri)

Custom Elasticsearch endpoint URL. If not provided, the default system Elasticsearch will be used.

elasticsearchApiKey

string

API Key for custom Elasticsearch endpoint. Will be stored securely.

chatbots

array[IdName]

groups

array[IdName]

知識庫可存取的群組列表

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


部分更新知識庫

PATCH /api/knowledge-bases/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base.

請求內容

請求參數

欄位
類型
必填
說明

user

string (uuid)

organization

string (uuid)

embeddingModel

string (uuid)

rerankerModel

string (uuid)

name

string

description

string

numberOfRetrievedChunks

integer

提取的參考資料數量,預設為 12,最小值為 1

sentenceWindowSize

integer

RAG 擴增句子視窗大小,預設為 2,最小值為 0

enableHyde

boolean

啟用 HyDE,預設為 False

similarityCutoff

number (double)

相似度門檻,預設為 0.0,範圍為 0.0-1.0

enableRerank

boolean

是否啟用重新排序,預設為 True

elasticsearchUrl

string (uri)

Custom Elasticsearch endpoint URL. If not provided, the default system Elasticsearch will be used.

elasticsearchApiKey

string

API Key for custom Elasticsearch endpoint. Will be stored securely.

chatbots

array[IdName]

groups

array[IdName]

知識庫可存取的群組列表

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


刪除知識庫

DELETE /api/knowledge-bases/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base.

程式碼範例

回應內容

狀態碼
說明

204

No response body


創建新標籤

POST /api/knowledge-bases/{knowledgeBasePk}/labels/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

name

string

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


列出知識庫中的標籤

GET /api/knowledge-bases/{knowledgeBasePk}/labels/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定標籤詳情

GET /api/knowledge-bases/{knowledgeBasePk}/labels/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this knowledge base label.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


更新標籤

PUT /api/knowledge-bases/{knowledgeBasePk}/labels/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this knowledge base label.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

name

string

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


部分更新標籤

PATCH /api/knowledge-bases/{knowledgeBasePk}/labels/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this knowledge base label.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

name

string

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


刪除標籤

DELETE /api/knowledge-bases/{knowledgeBasePk}/labels/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this knowledge base label.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼
說明

204

No response body


上傳檔案到知識庫

POST /api/knowledge-bases/{knowledgeBasePk}/files/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

fileType

string

檔案類型過濾,例如:pdf、docx、txt、xlsx 等

knowledgeBase

string

知識庫 ID

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

搜尋關鍵字,可以搜尋檔案名稱或檔案 ID

status

string

檔案狀態過濾,可選值:initial(初始化)、processing(處理中)、done(完成)、deleting(刪除中)、deleted(已刪除)、failed(失敗) `initial`: Initial ; `processing`: Processing ; `done`: Done ; `deleting`: Deleting ; `deleted`: Deleted ; `faile...

請求內容

請求參數

欄位
類型
必填
說明

files

array[KnowledgeBaseFileCreate]

支援多檔案批次上傳功能,上限為單次 50 個檔案

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


批量刪除檔案

POST /api/knowledge-bases/{knowledgeBasePk}/files/batch-delete/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

ids

array[string]

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼
說明

204

No response body


列出知識庫中的檔案

GET /api/knowledge-bases/{knowledgeBasePk}/files/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

fileType

string

檔案類型過濾,例如:pdf、docx、txt、xlsx 等

knowledgeBase

string

知識庫 ID

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

搜尋關鍵字,可以搜尋檔案名稱或檔案 ID

status

string

檔案狀態過濾,可選值:initial(初始化)、processing(處理中)、done(完成)、deleting(刪除中)、deleted(已刪除)、failed(失敗) `initial`: Initial ; `processing`: Processing ; `done`: Done ; `deleting`: Deleting ; `deleted`: Deleted ; `faile...

程式碼範例

{% tabs %} {% tab title="Shell/Bash" %} `

``bash

呼叫 API 示例 (Shell)

curl -X GET "https://api.maiagent.ai/api/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=deleted" -H "Authorization: Api-Key YOUR_API_KEY"

請確認在執行前替換 YOUR_API_KEY 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定檔案詳情

GET /api/knowledge-bases/{knowledgeBasePk}/files/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base File.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


更新檔案資訊

PUT /api/knowledge-bases/{knowledgeBasePk}/files/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base File.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

filename

string

檔案名稱

file

string (uri)

要上傳的檔案

parser

string (uuid)

labels

array[IdName]

rawUserDefineMetadata

object

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


部分更新檔案

PATCH /api/knowledge-bases/{knowledgeBasePk}/files/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base File.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

filename

string

檔案名稱

file

string (uri)

要上傳的檔案

parser

string (uuid)

labels

array[IdName]

rawUserDefineMetadata

object

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


部分更新檔案

PATCH /api/knowledge-bases/{knowledgeBasePk}/files/batch-reparse/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

fileType

string

檔案類型過濾,例如:pdf、docx、txt、xlsx 等

knowledgeBase

string

知識庫 ID

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

搜尋關鍵字,可以搜尋檔案名稱或檔案 ID

status

string

檔案狀態過濾,可選值:initial(初始化)、processing(處理中)、done(完成)、deleting(刪除中)、deleted(已刪除)、failed(失敗) `initial`: Initial ; `processing`: Processing ; `done`: Done ; `deleting`: Deleting ; `deleted`: Deleted ; `faile...

程式碼範例

{% tabs %} {% tab title="Shell/Bash" %} `

``bash

呼叫 API 示例 (Shell)

curl -X PATCH "https://api.maiagent.ai/api/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-reparse/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=deleted" -H "Authorization: Api-Key YOUR_API_KEY" -H "Content-Type: application/json" -d '[]'

請確認在執行前替換 YOUR_API_KEY 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

回應範例值


刪除檔案

DELETE /api/knowledge-bases/{knowledgeBasePk}/files/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this Knowledge Base File.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼
說明

204

No response body


創建新的 FAQ

POST /api/knowledge-bases/{knowledgeBasePk}/faqs/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

question

string

answer

string

answerMediaUrls

object

存放答案中的圖片、影片等媒體檔案的 URLs

labels

array[IdName]

rawUserDefineMetadata

object

knowledgeBase

object (含 2 個屬性: id, name)

knowledgeBase.id

string (uuid)

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


批量刪除 FAQ

POST /api/knowledge-bases/{knowledgeBasePk}/faqs/batch-delete/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

ids

array[string]

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼
說明

204

No response body


列出特定知識庫的所有 FAQ

GET /api/knowledge-bases/{knowledgeBasePk}/faqs/

參數

參數名稱
必填
類型
說明

knowledgeBasePk

string

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定 FAQ 詳情

GET /api/knowledge-bases/{knowledgeBasePk}/faqs/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this FAQ.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


更新 FAQ

PUT /api/knowledge-bases/{knowledgeBasePk}/faqs/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this FAQ.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

question

string

answer

string

answerMediaUrls

object

存放答案中的圖片、影片等媒體檔案的 URLs

labels

array[IdName]

rawUserDefineMetadata

object

knowledgeBase

object (含 2 個屬性: id, name)

knowledgeBase.id

string (uuid)

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


部分更新 FAQ

PATCH /api/knowledge-bases/{knowledgeBasePk}/faqs/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this FAQ.

knowledgeBasePk

string

請求內容

請求參數

欄位
類型
必填
說明

question

string

answer

string

answerMediaUrls

object

存放答案中的圖片、影片等媒體檔案的 URLs

labels

array[IdName]

rawUserDefineMetadata

object

knowledgeBase

object (含 2 個屬性: id, name)

knowledgeBase.id

string (uuid)

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


刪除 FAQ

DELETE /api/knowledge-bases/{knowledgeBasePk}/faqs/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this FAQ.

knowledgeBasePk

string

程式碼範例

回應內容

狀態碼
說明

204

No response body


Last updated

Was this helpful?