知识库问答
列出知识库(暂未实现)
上传知识库
POST http://{ip:port}/uran/lm/documents
请求参数
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
documents | ObjectArray | Y | 文档数组 |
+name | String | Y | 文档名 |
+type | String | Y | 文档类型,支持pdf, doc, txt, docx |
+url | String | Y | 文档url地址 |
+md5 | String | Y | 文档md5值,用于标识文档唯一性 |
repository | String | Y | 指定要插入的知识库 |
notifyUrl | String | Y | 通知文档处理状态地址 |
响应参数
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
status | Int | Y | 状态码200为成功,其余为出错 |
message | String | Y | 当status=200为”success”, 其余为错误信息 |
data | Object | N | 返回有用的数据 |
请求示例
{
"documents":[{ "name": "码极客算法白皮书", "type": "pdf",
"url": "http://xxxxxxxxxxxxxxx", "md5": "sfh8i3ss"}....]
"repository": "OsmagicAlgorithmSpec",
"notifyUrl": "http://xxxxxxxxxxxxxxx"
}
响应示例
{
"status": 200,
"message": "success"
}
删除知识库
DELETE http://{ip:port}/uran/lm/documents
请求参数
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
documents | StringArray | Y | 待删除的文档名数组 |
repository | String | Y | 指定所属的知识库 |
响应参数
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
status | Int | Y | 状态码200为成功,其余为出错 |
message | String | Y | 当status=200为”success”, 其余为错误信息 |
data | Object | N | 返回有用的数据 |
请求示例
{
"documents": ["码极客算法白皮书", "码极客算法报价单"...]
"repository": "OsmagicAlgorithmSpec",
}
响应示例
{
"staus": 200,
"message": "success"
}
知识库问答
POST http://{ip:port}/uran/lm/question
请求参数
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
messages | ObjectArrary | Y | 待搜索的问题集合 |
+role | String | Y | 角色user, assistant |
+content | String | Y | 搜索问题 |
maxTokens | Int | Y | 限制最大token数 |
temperature | Float | Y | 想象力 |
model | String | Y | 模型名 |
repository | Object | N | 指定要搜索的知识库/如果没有则属于对话模式 |
+name | String | Y | 知识库名 |
+threshold | Float | Y | 搜索阈值 |
+topK | Int | Y | 指定搜索结果的topK |
background | String | N | 背景信息描述 |
响应参数 ( 流式text/event-stream )
名称 | 类型 | 是否必须 | 说明 |
---|---|---|---|
data | Object | Y | 返回产生的结果[DONE]表示完成 |
+choices | ObjectArray | Y | |
++delta | Object | Y | |
+++role/step/content | String | Y | role=assistant,step=当前正在发生进行的步骤, content=模型回复的消息 |
请求示例
{
"maxTokens": 128,
"temperature": 0.7,
"messages": [
{
"role": "user",
"content": "铁路异物是什么意思",
}
],
"model": "koala-mm",
"repository": {
"repository": "铁塔高空监控",
"threshold": 0.5,
"topK": 2
},
"background" : "repository"
}
响应示例
data: { "choices": [{"delta": {"step": "正在检索知识库"}}]}
data: { "choices": [{"delta": {"step": "正在组织解决方案"}}]}
data: { "choices": [{"delta": {"role": "assistant"}}]}
data: { "choices": [{"delta": {"content": "火灾"}}]}
data: { "choices": ["delta": {"content": "发生"}}]}