@gaiot/apis
Version:
aiot apis
432 lines (431 loc) • 11.7 kB
JavaScript
var s = (l, e, t) => new Promise((n, i) => {
var r = (o) => {
try {
p(t.next(o));
} catch (a) {
i(a);
}
}, c = (o) => {
try {
p(t.throw(o));
} catch (a) {
i(a);
}
}, p = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(r, c);
p((t = t.apply(l, e)).next());
});
import g from "axios";
import { BaseApi as h } from "../base/index.mjs";
import { m as d } from "../node_modules/@gaiot/minio/dist/minio-zj.mjs";
class m extends h {
constructor(e, t) {
super(e != null ? e : g.create(), t);
}
getKnowledge(e, t) {
return s(this, null, function* () {
return this.get("/knowledge", {
docId: e,
name: t
});
});
}
postKnowledge(e) {
return s(this, null, function* () {
return this.post("/knowledge", e);
});
}
getKnowledgeId(e) {
return s(this, null, function* () {
return this.get(`/knowledge/${e}`);
});
}
patchKnowledgeId(e, t) {
return s(this, null, function* () {
return this.patch(`/knowledge/${e}`, t);
});
}
delKnowledgeId(e) {
return s(this, null, function* () {
return this.delete(`/knowledge/${e}`);
});
}
getKnowledgeIdFile(e) {
return s(this, null, function* () {
return this.get(`/knowledge/${e}/file`);
});
}
getKnowledgeIdFileList(e, t) {
return s(this, null, function* () {
return this.listPaged(`/knowledge/${e}/file`, t);
});
}
postKnowledgeIdFile(e, t) {
return s(this, null, function* () {
return this.post(`/knowledge/${e}/file`, t);
});
}
getUploadTicket(e) {
return s(this, null, function* () {
return this.get("/upload/ticket", e);
});
}
delKnowledgeIdFileFid(e, t) {
return s(this, null, function* () {
return this.delete(`/knowledge/${e}/file/${t}`);
});
}
patchKnowledgeIdFileFid(e, t, n) {
return s(this, null, function* () {
return this.patch(`/knowledge/${e}/file/${t}`, n);
});
}
listSessions(e, t) {
return s(this, null, function* () {
return this.get(`/application/${e}/sessionsa`, t);
});
}
postSession(e, t) {
return s(this, null, function* () {
return this.post(`/application/${e}/sessions`, t);
});
}
getSession(e, t) {
return s(this, null, function* () {
return this.get(`/application/${e}/sessions/${t}`);
});
}
patchSessionsId(e, t, n) {
return s(this, null, function* () {
return this.patch(`/application/${e}/sessions/${t}`, n);
});
}
delSessionsId(e, t) {
return s(this, null, function* () {
return this.delete(`/application/${e}/sessions/${t}`);
});
}
getSessionKnowledgeFile(e, t, n) {
return s(this, null, function* () {
return this.get(`/application/${e}session/${t}/file/${n}`);
});
}
postSessionKnowledgeFile(e, t, n) {
return s(this, null, function* () {
return this.post(`/application/${e}session/${t}/file`, n);
});
}
postComments(e) {
return s(this, null, function* () {
return this.post("/comments", e);
});
}
/**
* 查询会话记录
* 规则:
* 1. startTime + pageSize:向后查询
* 2. startTime + pageSize:向前查询
* 3. startTIme + endTime :查询区间(忽略pageSize)
* 4. pageSize 必须是偶数,问答必须一同查询。不严谨,但前端没有办法😭
* 5. 这里的time对应的是对话记录里的messageTime字段,该字段只精确到秒,并不严谨,导致规则4的出现
**/
getChatHistorySessionId(e, t, n) {
return s(this, null, function* () {
return this.get(`application/${e}/chatHistory/${t}`, n);
});
}
postChatHistorySessionId(e, t) {
return s(this, null, function* () {
return this.post(`/chatHistory/${e}`, t);
});
}
getApplications(e) {
return s(this, null, function* () {
return this.get("/applications", e);
});
}
postApplication(e) {
return s(this, null, function* () {
return this.post("/applications", e);
});
}
getApplicationId(e) {
return s(this, null, function* () {
return this.get(`/applications/${e}`);
});
}
patchApplicationId(e, t) {
return s(this, null, function* () {
return this.patch(`/applications/${e}`, t);
});
}
delApplicationId(e) {
return s(this, null, function* () {
return this.delete(`/applications/${e}`);
});
}
getApplicationIdSessions(e) {
return s(this, null, function* () {
return this.get(`/applications/${e}/session`);
});
}
patchFileId(e, t) {
return s(this, null, function* () {
return this.patch(`/file/${e}`, t);
});
}
getCvforceResource(e) {
return s(this, null, function* () {
return this.get("/cvforce/resource", e);
});
}
postKnowledgeIdComposedFiles(e, t) {
return s(this, null, function* () {
return this.post(`/knowledge/${e}/composedFiles`, t);
});
}
getTokensApplicationId(e, t) {
return s(this, null, function* () {
return this.get(`/tokens/${e}`, t);
});
}
getTokens(e) {
return s(this, null, function* () {
return this.get("/tokens", e);
});
}
uploadMinioFile(e, t) {
return s(this, null, function* () {
return new Promise((n, i) => {
const r = new FileReader();
r.readAsArrayBuffer(t), r.onload = (c) => {
d.initMinio({
endPoint: e.endpoints[0],
useSSL: e.useSSL,
accessKey: e.accessKey,
secretKey: e.secretKey
});
const p = Buffer.from(c.target.result), o = {
"Content-Type": "application/octet-stream"
};
d.putObjectBuffer(e.bucket, e.fileKeys[0], p, o, (a) => {
if (a)
throw console.error(a), Error(a);
n(e.fileKeys[0]);
});
};
});
});
}
uploadFile(e, t) {
return s(this, null, function* () {
const n = {
files: [t.name],
isv: "minio",
knowledgeId: e
};
return this.getUploadTicket(n).then((i) => this.uploadMinioFile(i.minio, t)).catch((i) => {
throw Error(i);
});
});
}
uploadFiles(e, t) {
return s(this, null, function* () {
const n = {
files: t.map((i) => i.name),
isv: "minio",
knowledgeId: e
};
return this.getUploadTicket(n).then((i) => Promise.all(t.map((r) => this.uploadMinioFile(i.minio, r)))).catch((i) => {
throw Error(i);
});
});
}
getAecModels() {
return s(this, null, function* () {
return this.get("/aecModels");
});
}
postTextFilter(e) {
return s(this, null, function* () {
return this.post("/textFilter", e);
});
}
getTenantModel() {
return s(this, null, function* () {
return this.get("/tenantModel");
});
}
// 获取prompt变量列表
getPrompts(e, t) {
return s(this, null, function* () {
return this.get(`application/${e}/promptVariables`, t);
});
}
// 新增prompt
postPrompt(e, t) {
return s(this, null, function* () {
return this.post(`application/${e}/promptVariables`, t);
});
}
// 修改单个prompt
patchPromptId(e, t, n) {
return s(this, null, function* () {
return this.patch(`application/${e}/promptVariables/${t}`, n);
});
}
// 删除单个prompt
delPromptId(e, t) {
return s(this, null, function* () {
return this.delete(`application/${e}/promptVariables/${t}`);
});
}
// 获取session下的prompt变量列表
getSessionPrompts(e) {
return s(this, null, function* () {
return this.get(`session/${e}/promptVariables`);
});
}
// 修改session单个prompt
patchSessionPromptId(e, t, n) {
return s(this, null, function* () {
return this.patch(`session/${t}/promptVariables/${e}`, n);
});
}
getApplicationIdSessionIdPromptVariables(e, t) {
return s(this, null, function* () {
return this.get(`/application/${e}/session/${t}/promptVariables`);
});
}
patchApplicationIdSessionpromptVariablesId(e, t, n, i) {
return s(this, null, function* () {
return this.patch(`/application/${e}/session/${t}/promptVariables/${n}`, i);
});
}
// 查询预置应用
getPresetApplication(e) {
return s(this, null, function* () {
return this.get("presetApplication", e);
});
}
// 新建知识库配置
postKnowledgeConfig(e) {
return s(this, null, function* () {
return this.post("/knowledgeConfig", e);
});
}
// 获取知识库配置
getKnowledgeConfig(e) {
return s(this, null, function* () {
return this.get(`/knowledgeConfig/${e}`);
});
}
// 编辑知识库配置
patchKnowledgeConfig(e, t) {
return s(this, null, function* () {
return this.patch(`/knowledgeConfig/${e}`, t);
});
}
getKnowledgeIdFileId(e, t) {
return s(this, null, function* () {
return this.get(`/knowledge/${e}/file/${t}`);
});
}
getKnowledgeIdFileIdData(e, t, n) {
return s(this, null, function* () {
return this.listPaged(`/knowledge/${e}/file/${t}/data`, n);
});
}
postKnowledgeIdFileIdData(e, t, n) {
return s(this, null, function* () {
return this.post(`/knowledge/${e}/file/${t}/data`, {
data: n
});
});
}
patchKnowledgeIdFileIdData(e, t, n, i) {
return s(this, null, function* () {
return this.patch(`/knowledge/${e}/file/${t}/data/${n}`, {
data: i
});
});
}
delKnowledgeIdFileIdDataDid(e, t, n) {
return s(this, null, function* () {
return this.delete(`/knowledge/${e}/file/${t}/data/${n}`);
});
}
// 获取预置知识库
getPresetKnowledge(e) {
return s(this, null, function* () {
return this.get("/presetKnowledge", e);
});
}
patchSessionsIdContext(e) {
return s(this, null, function* () {
return this.patch(`/sessions/${e}/context`, {});
});
}
postResourceToken(e) {
return s(this, null, function* () {
return this.post("/resourceToken", e);
});
}
// 应用嵌入接口
getApplicationIdSession(e) {
return s(this, null, function* () {
return this.get(`/application/${e}/session`);
});
}
patchApplicationIdSessionsIdContext(e, t) {
return s(this, null, function* () {
return this.patch(`/application/${e}/sessions/${t}/context`, {});
});
}
postApplicationIdSessions(e, t) {
return s(this, null, function* () {
return this.post(`/application/${e}/sessions`, t);
});
}
getApplicationIdChatHistorySessionId(e, t) {
return s(this, null, function* () {
return this.get(`/application/${e}/chatHistory/${t}`);
});
}
postApplicationIdChatHistorySessionIdComments(e, t, n) {
return s(this, null, function* () {
return this.post(`/application/${e}/sessions/${t}/comments`, n);
});
}
getApplicationIdPrompts(e, t) {
return s(this, null, function* () {
return this.get(`/application/${e}/promptVariables`, t);
});
}
// 上传知识库内文件的知识引用源文件
postKnowledgeSourceFile(e, t, n) {
return s(this, null, function* () {
return this.post(`/knowledge/${e}/sourceFile/${t}`, n);
});
}
//元数据接口
getMetadata(e) {
return s(this, null, function* () {
return this.get("/metadata", e);
});
}
postGeneques(e) {
return s(this, null, function* () {
return this.post("/geneques", e);
});
}
getBaseModel(e) {
return s(this, null, function* () {
return this.get("/baseModelInfo", {
serviceId: e
});
});
}
}
export {
m as CVForceApi
};