Skip to main content
POST
/
v1
/
projects
/
{projectId}
/
knowledgebases
/
{knowledgebaseId}
/
datasets
建立資料集
curl --request POST \
  --url https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '{}'
import requests

url = "https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets"

payload = {}
headers = {
    "Authorization": "<authorization>",
    "Content-Type": "<content-type>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
  body: JSON.stringify({})
};

fetch('https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: <authorization>",
    "Content-Type: <content-type>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<authorization>")
	req.Header.Add("Content-Type", "<content-type>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets")
  .header("Authorization", "<authorization>")
  .header("Content-Type", "<content-type>")
  .body("{}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{}"

response = http.request(request)
puts response.read_body
上傳檔案作為新的資料集。上傳後檔案會以非同步方式切割成區塊並嵌入 — 請輪詢 列出資料集 並觀察 isParsed,以得知何時可供查詢。

請求

POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets

路徑參數

projectId
string
required
專案 ID
knowledgebaseId
string
required
要上傳至的知識庫

標頭

Authorization
string
required
使用您的 Developer Key 進行 Bearer 令牌認證
Content-Type
string
required
必須為 multipart/form-data

請求主體

dataset
file
required
要上傳的檔案。支援格式:PDF、TXT、DOCX 及其他以文字為基礎的格式。

回應

{
  "message": "Dataset Uploaded successfully, currently embedding in the background",
  "success": true
}

範例

curl -X POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases/kb_abc123/datasets \
  -H "Authorization: Bearer dk_your_key" \
  -F "dataset=@/path/to/your/file.pdf"