Search Knowledge Base
curl --request POST \
--url https://api.reportify.cn/v1/tools/kb/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"folder_ids": [
"<string>"
],
"doc_ids": [
"<string>"
],
"start_date": "<string>",
"end_date": "<string>",
"num": 10
}
'import requests
url = "https://api.reportify.cn/v1/tools/kb/search"
payload = {
"query": "<string>",
"folder_ids": ["<string>"],
"doc_ids": ["<string>"],
"start_date": "<string>",
"end_date": "<string>",
"num": 10
}
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>',
folder_ids: ['<string>'],
doc_ids: ['<string>'],
start_date: '<string>',
end_date: '<string>',
num: 10
})
};
fetch('https://api.reportify.cn/v1/tools/kb/search', 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.reportify.cn/v1/tools/kb/search",
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>',
'folder_ids' => [
'<string>'
],
'doc_ids' => [
'<string>'
],
'start_date' => '<string>',
'end_date' => '<string>',
'num' => 10
]),
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.reportify.cn/v1/tools/kb/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\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.reportify.cn/v1/tools/kb/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reportify.cn/v1/tools/kb/search")
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 \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\n}"
response = http.request(request)
puts response.read_body{
"chunks": []
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}知识库和文件管理
Search Knowledge Base
User knowledge base search, supporting all types of user uploaded files and allows searching within specified directories
POST
/
v1
/
tools
/
kb
/
search
Search Knowledge Base
curl --request POST \
--url https://api.reportify.cn/v1/tools/kb/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"folder_ids": [
"<string>"
],
"doc_ids": [
"<string>"
],
"start_date": "<string>",
"end_date": "<string>",
"num": 10
}
'import requests
url = "https://api.reportify.cn/v1/tools/kb/search"
payload = {
"query": "<string>",
"folder_ids": ["<string>"],
"doc_ids": ["<string>"],
"start_date": "<string>",
"end_date": "<string>",
"num": 10
}
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>',
folder_ids: ['<string>'],
doc_ids: ['<string>'],
start_date: '<string>',
end_date: '<string>',
num: 10
})
};
fetch('https://api.reportify.cn/v1/tools/kb/search', 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.reportify.cn/v1/tools/kb/search",
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>',
'folder_ids' => [
'<string>'
],
'doc_ids' => [
'<string>'
],
'start_date' => '<string>',
'end_date' => '<string>',
'num' => 10
]),
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.reportify.cn/v1/tools/kb/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\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.reportify.cn/v1/tools/kb/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.reportify.cn/v1/tools/kb/search")
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 \"folder_ids\": [\n \"<string>\"\n ],\n \"doc_ids\": [\n \"<string>\"\n ],\n \"start_date\": \"<string>\",\n \"end_date\": \"<string>\",\n \"num\": 10\n}"
response = http.request(request)
puts response.read_body{
"chunks": []
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}搜索知识库
URL:/v1/tools/kb/search方法:
POST描述: 搜索用户的私有知识库,包括上传的文档和文件夹。
请求参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| query | string | 是 | 搜索关键词 |
| folder_ids | string[] | 否 | 文件夹 ID 列表,筛选特定文件夹 |
| doc_ids | string[] | 否 | 文档 ID 列表,筛选特定文档 |
| start_date | string | 否 | 开始日期(YYYY-MM-DD) |
| end_date | string | 否 | 结束日期(YYYY-MM-DD) |
| num | integer | 否 | 返回结果数量,默认 10 |
响应参数
| 参数名 | 类型 | 描述 |
|---|---|---|
| chunks | array | 搜索结果块列表 |
| chunk_id | string | 内容块 ID |
| content | string | 匹配的内容 |
| score | number | 相关性得分 |
| doc_id | string | 所属文档 ID |
| doc_title | string | 文档标题 |
| folder_id | string | 文件夹 ID |
| folder_name | string | 文件夹名称 |
请求示例
cURLcurl -X POST "https://api.reportify.cn/v1/tools/kb/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "投资策略",
"num": 10
}'
import requests
url = "https://api.reportify.cn/v1/tools/kb/search"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"query": "投资策略",
"folder_ids": ["folder_abc123"],
"num": 10
}
response = requests.post(url, headers=headers, json=data)
results = response.json()
for chunk in results["chunks"]:
print(f"[{chunk['doc_title']}] {chunk['content'][:100]}...")
const response = await fetch('https://api.reportify.cn/v1/tools/kb/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: '投资策略',
num: 10
})
});
const data = await response.json();
console.log(`Found ${data.chunks.length} results`);
响应示例
{
"chunks": [
{
"chunk_id": "chunk_abc123",
"content": "本报告提出的投资策略主要关注价值投资和成长投资的结合...",
"score": 0.95,
"doc_id": "doc_xyz789",
"doc_title": "2024年投资策略报告.pdf",
"folder_id": "folder_abc123",
"folder_name": "投资研究"
}
]
}
错误响应
| 状态码 | 描述 |
|---|---|
| 422 | 请求参数验证失败 |
使用场景
-
搜索私有文档
- 在上传的研究报告中搜索特定内容
- 快速定位相关分析和数据
-
按时间范围筛选
- 搜索特定时间段内的文档内容
- 追踪历史分析记录
-
分文件夹搜索
- 在特定项目文件夹中搜索
- 隔离不同研究领域的内容
Authorizations
Enter your Bearer token
Body
application/json
Response
Successful Response
Output model for knowledge base search
Search result chunks with document information
Show child attributes
Show child attributes
⌘I
