Retrieve Knowledge
curl --request POST \
--url https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"entity_names": [
"<string>"
],
"enable_toc_enhance": false,
"knowledge_ids": [
"<string>"
],
"pre_filter_document_ids": [
"<string>"
],
"return_metadata": true
}
'import requests
url = "https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge"
payload = {
"query": "<string>",
"entity_names": ["<string>"],
"enable_toc_enhance": False,
"knowledge_ids": ["<string>"],
"pre_filter_document_ids": ["<string>"],
"return_metadata": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
entity_names: ['<string>'],
enable_toc_enhance: false,
knowledge_ids: ['<string>'],
pre_filter_document_ids: ['<string>'],
return_metadata: true
})
};
fetch('https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge', 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-spectra.duplik.cn/v1/tools/retrieval_knowledge",
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([
'query' => '<string>',
'entity_names' => [
'<string>'
],
'enable_toc_enhance' => false,
'knowledge_ids' => [
'<string>'
],
'pre_filter_document_ids' => [
'<string>'
],
'return_metadata' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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-spectra.duplik.cn/v1/tools/retrieval_knowledge"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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-spectra.duplik.cn/v1/tools/retrieval_knowledge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{
"document_id": "<string>",
"metadata": {}
}
],
"document_contents": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Tools
Retrieve Knowledge
Semantic retrieval over knowledge bases, with entity_names metadata pre-filtering
POST
/
v1
/
tools
/
retrieval_knowledge
Retrieve Knowledge
curl --request POST \
--url https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"entity_names": [
"<string>"
],
"enable_toc_enhance": false,
"knowledge_ids": [
"<string>"
],
"pre_filter_document_ids": [
"<string>"
],
"return_metadata": true
}
'import requests
url = "https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge"
payload = {
"query": "<string>",
"entity_names": ["<string>"],
"enable_toc_enhance": False,
"knowledge_ids": ["<string>"],
"pre_filter_document_ids": ["<string>"],
"return_metadata": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
entity_names: ['<string>'],
enable_toc_enhance: false,
knowledge_ids: ['<string>'],
pre_filter_document_ids: ['<string>'],
return_metadata: true
})
};
fetch('https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge', 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-spectra.duplik.cn/v1/tools/retrieval_knowledge",
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([
'query' => '<string>',
'entity_names' => [
'<string>'
],
'enable_toc_enhance' => false,
'knowledge_ids' => [
'<string>'
],
'pre_filter_document_ids' => [
'<string>'
],
'return_metadata' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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-spectra.duplik.cn/v1/tools/retrieval_knowledge"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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-spectra.duplik.cn/v1/tools/retrieval_knowledge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-spectra.duplik.cn/v1/tools/retrieval_knowledge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"entity_names\": [\n \"<string>\"\n ],\n \"enable_toc_enhance\": false,\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"pre_filter_document_ids\": [\n \"<string>\"\n ],\n \"return_metadata\": true\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{
"document_id": "<string>",
"metadata": {}
}
],
"document_contents": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The question to search the knowledge bases with
Metadata tags to pre-filter on, written as "key:value" (for example ["model:SY500"]). Prefix matched and ANDed
Enable table-of-contents enhanced retrieval
Knowledge bases to search, resolved within the API key's organization
Restrict the search to these documents; intersected with the entity_names filter when both are used
Include each document's entity_names in the response
