一、下载AnythingLLM
在这里插入图片描述

二、创建知识库,并进行各种设置
在这里插入图片描述
在这里插入图片描述

三、上传知识库
在这里插入图片描述

四、比Cherry studio和Chat box厉害的是,提供了接口

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

五、根据上述,获取了密钥、工作空间向量编码。

import request as r
import json

ques = '你怎么看联系时长两年半这件事'

workspace = '上述的向量数据库标识符'
url = f"http://127.0.0.1:3001/api/v1/workspace/{workspace}/chat"
headers = {
	"Authorization":"Bearer 上述API密钥", # 权限验证
	"Content-Type":"application/json",#发送消息的格式
	"accept":"application/json"#接收消息的格式
}

data = {
	"message":ques, #要提问的内容
	"mode":"chat",#chat模式:聊天;query模式:查询或知识库
	"max_token":512
}

resp = r.post(uel.headers=headers,json=data)
resp.json()
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐