【RAGFlow】如何通过API查询知识库内容
·
import requests
import json
data = \
{
"dataset_ids": ["617892ce3d2111f1835f373a6cab5d12"],
"question": "快乐8游戏中,总共有多少个号码?",
"top_k": 3
}
# 发送http请求
header = {
"Content-Type": "application/json",
"Authorization": "Bearer xxx"
}
url = "http://localhost:8080/api/v1/retrieval"
response = requests.post(url, data=json.dumps(data), headers=header)
# 关键步骤:强制设置响应编码
response.encoding = 'utf-8'
try:
# 优先尝试 JSON 解析
data = response.json()
print(json.dumps(data, ensure_ascii=False, indent=2))
except Exception as e:
# 若 JSON 解析失败,尝试手动解码内容
print(response.content.decode('utf-8', 'ignore'))
更多推荐




所有评论(0)