vectocore4 0.0.10 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +106 -60
- package/dist/index.d.ts +167 -55
- package/dist/mjs/index.js +106 -71
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -41,6 +41,13 @@ class Vectocore {
|
|
|
41
41
|
return response.data;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* 인덱스를 생성/수정합니다.
|
|
46
|
+
* @param params ({@link PutIndexParams})
|
|
47
|
+
* - **indexName**: string (필수) 생성 및 수정할 인덱스 명
|
|
48
|
+
* - description: string (선택) 인덱스에 대한 설명
|
|
49
|
+
* @returns 식제 결과
|
|
50
|
+
*/
|
|
44
51
|
putIndex(_a) {
|
|
45
52
|
return __awaiter(this, arguments, void 0, function* ({ indexName, description }) {
|
|
46
53
|
const requestParam = {
|
|
@@ -54,6 +61,12 @@ class Vectocore {
|
|
|
54
61
|
return response;
|
|
55
62
|
});
|
|
56
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* 인덱스를 삭제합니다.
|
|
66
|
+
* @param params ({@link DeleteIndexParams})
|
|
67
|
+
* - **indexName**: string (필수) 삭제할 인덱스의 이름
|
|
68
|
+
* @returns 식제 결과
|
|
69
|
+
*/
|
|
57
70
|
deleteIndex(_a) {
|
|
58
71
|
return __awaiter(this, arguments, void 0, function* ({ indexName }) {
|
|
59
72
|
const requestParam = {
|
|
@@ -66,6 +79,10 @@ class Vectocore {
|
|
|
66
79
|
return response;
|
|
67
80
|
});
|
|
68
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* 인덱스 목록을 조회합니다.
|
|
84
|
+
* @returns 인덱스 목록
|
|
85
|
+
*/
|
|
69
86
|
listIndex() {
|
|
70
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
88
|
const requestParam = {
|
|
@@ -75,6 +92,20 @@ class Vectocore {
|
|
|
75
92
|
return response;
|
|
76
93
|
});
|
|
77
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* 인덱스에 문서 저장
|
|
97
|
+
* @param params ({@link PutExtremeDataParams})
|
|
98
|
+
* - **indexName**: string (필수) 문서를 저장할 인덱스의 이름
|
|
99
|
+
* - **docBody**: json (필수)
|
|
100
|
+
* - **id**: string (선택) 도큐먼트 ID (소문자, 영문, -), 값은 인덱스내에서 유일해야함, 신규 row일 경우 각 시스템에서 직접 채번하거나 ""빈값으로 보내면 자동으로 채번함
|
|
101
|
+
* - **keywords**: string (필수) 검색의 대상이 되는 필드. 사용자 질문의 의도를 파악하여 RAG내에서 유사도를 비교하여 높은 순서로 결과를 리턴 받는다.
|
|
102
|
+
* - **data**: string (필수) 키워드에 해당하는 문서의 실제 내용
|
|
103
|
+
* - docType: "text"|"image" (선택) Default : "text", 저장할 지식의 타입으로 Default는 "text". doc_type이 "image"일 경우 추가로 "image_url" 필드를 사용합니다.
|
|
104
|
+
* - imageUrl: string (선택) doc_type이 "image"일 경우 사용하는 필드로 웹에서 접근 가능한 이미지의 경로를 입력.
|
|
105
|
+
* - metadata: json (선택) 문서 저장시 추가로 남기고 싶은 정보를 json 형식으로 추가하면 향후 검색 결과시 리턴. 문서명이나, 페이지 번호 등을 입력하여 출처 확인용으로 사용할 수 있다
|
|
106
|
+
* - refOnlyText: bool (선택) ens 기능 사용시 사용하는 옵션으로 doc_type이 "image"인 경우 "image_url"의 경로를 자동으로 멀티모달로 전달하는데 ref_only_text : true로 설정한 경우 멀티모달을 전달하지 않고 "data" 필드의 정보만 context로 활용한다.
|
|
107
|
+
* @returns 문서 저장 결과
|
|
108
|
+
*/
|
|
78
109
|
putExtremeData(_a) {
|
|
79
110
|
return __awaiter(this, arguments, void 0, function* ({ indexName, docBody }) {
|
|
80
111
|
var _b, _c;
|
|
@@ -101,6 +132,13 @@ class Vectocore {
|
|
|
101
132
|
return response;
|
|
102
133
|
});
|
|
103
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* 특정 문서를 조회합니다.
|
|
137
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link GetExtremeDataParams})
|
|
138
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
139
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
140
|
+
* @returns 문서 정보
|
|
141
|
+
*/
|
|
104
142
|
getExtremeData(_a) {
|
|
105
143
|
return __awaiter(this, arguments, void 0, function* ({ indexName, documentId }) {
|
|
106
144
|
const requestParam = {
|
|
@@ -114,6 +152,14 @@ class Vectocore {
|
|
|
114
152
|
return response;
|
|
115
153
|
});
|
|
116
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* 특정 인덱스에 저장된 지식 데이터를 조회합니다.(페이징)
|
|
157
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListExtremeDataParams})
|
|
158
|
+
* - **indexName**: string (필수)
|
|
159
|
+
* - lastKey: string (선택) 최초 검색 결과에서 전달 받은 토큰값
|
|
160
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
161
|
+
* @returns 인덱스 목록
|
|
162
|
+
*/
|
|
117
163
|
listExtremeData(_a) {
|
|
118
164
|
return __awaiter(this, arguments, void 0, function* ({ indexName, lastKey, withVectorValue }) {
|
|
119
165
|
const requestParam = {
|
|
@@ -132,7 +178,9 @@ class Vectocore {
|
|
|
132
178
|
}
|
|
133
179
|
/**
|
|
134
180
|
* 특정 인덱스에 저장된 모든 지식 데이터를 조회합니다.
|
|
135
|
-
*
|
|
181
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListAllExtremeDataParams})
|
|
182
|
+
* - **indexName**: string (필수)
|
|
183
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
136
184
|
* @returns 인덱스 목록
|
|
137
185
|
*/
|
|
138
186
|
listAllExtremeData(_a) {
|
|
@@ -148,6 +196,13 @@ class Vectocore {
|
|
|
148
196
|
return response;
|
|
149
197
|
});
|
|
150
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* 특정 문서를 삭제합니다.
|
|
201
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
202
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
203
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
204
|
+
* @returns 삭제 결과
|
|
205
|
+
*/
|
|
151
206
|
deleteExtremeData(_a) {
|
|
152
207
|
return __awaiter(this, arguments, void 0, function* ({ indexName, documentId }) {
|
|
153
208
|
const requestParam = {
|
|
@@ -161,6 +216,19 @@ class Vectocore {
|
|
|
161
216
|
return response;
|
|
162
217
|
});
|
|
163
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* X-Finder의 문서를 AI 검색합니다.
|
|
221
|
+
* @param params ({@link ExtremeSearchParams})
|
|
222
|
+
* - **question**: string (필수) 사용자 질문 (시멘틱 검색을 사용하기때문에 서술형을 질문해도 의미를 파악하여 유사한 결과를 유사도 순위별로 리턴.)
|
|
223
|
+
* - **mode**: "vector" | "keyword" | "hybrid" (선택) Default : "vector"
|
|
224
|
+
* - vector 모드 : 시멘틱 유사도만 사용
|
|
225
|
+
* - keyword 모드 : 키워드 유사도만 사용, 키워드 모드인 경우 해당 "단어"가 문서에 없으면 빈 list를 리턴
|
|
226
|
+
* - hybrid 모드 : 시멘틱 검색 순위와 키워드 검색 순위를 모두 사용하여 순위 결정
|
|
227
|
+
* - indexNames: string[] (선택) 사용자의 질문을 검색하고자하는 인덱스 목록, 생략하거나 []를 전송시 전체 인덱스에서 검색 실행
|
|
228
|
+
* - top: number (선택) 결과로 보고싶은 목록의 최대 건수, 생략시 10건을 조회.
|
|
229
|
+
* - rerank: bool (선택) 검색 mode가 hybrid일 경우 벡터 검색과 키워드 검색 결과를 ai가 다시 score를 산정하는 방식으로 별도의 토큰이 소모 됨.
|
|
230
|
+
* @returns 순위가 있는 문서 목록
|
|
231
|
+
*/
|
|
164
232
|
extremeSearch(_a) {
|
|
165
233
|
return __awaiter(this, arguments, void 0, function* ({ mode, indexNames, question, top, rerank }) {
|
|
166
234
|
const requestParam = {
|
|
@@ -177,6 +245,12 @@ class Vectocore {
|
|
|
177
245
|
return response;
|
|
178
246
|
});
|
|
179
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* 웹검색
|
|
250
|
+
* @param params ({@link WebSearchParams})
|
|
251
|
+
* - **question**: string (필수) 사용자 질문
|
|
252
|
+
* @returns 웹 검색 결과
|
|
253
|
+
*/
|
|
180
254
|
webSearch(_a) {
|
|
181
255
|
return __awaiter(this, arguments, void 0, function* ({ question }) {
|
|
182
256
|
const requestParam = {
|
|
@@ -195,9 +269,9 @@ class Lens {
|
|
|
195
269
|
/**
|
|
196
270
|
* API Client for interfacing with the Lens API.
|
|
197
271
|
*
|
|
198
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
272
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
199
273
|
*/
|
|
200
|
-
constructor({ tenantKey, baseURL
|
|
274
|
+
constructor({ tenantKey, baseURL }) {
|
|
201
275
|
if (tenantKey === undefined) {
|
|
202
276
|
throw new Error("error tenantKey is undefined");
|
|
203
277
|
}
|
|
@@ -208,17 +282,6 @@ class Lens {
|
|
|
208
282
|
else {
|
|
209
283
|
this.baseURL = baseURL;
|
|
210
284
|
}
|
|
211
|
-
this.role = role;
|
|
212
|
-
this.rule = rule;
|
|
213
|
-
this.outputFormat = outputFormat;
|
|
214
|
-
this.mode = mode;
|
|
215
|
-
this.maxHisCount = maxHisCount;
|
|
216
|
-
this.sessionKey = sessionKey;
|
|
217
|
-
this.numOfRef = numOfRef;
|
|
218
|
-
this.customSystemPrompt = customSystemPrompt || undefined;
|
|
219
|
-
this.staticInfo = staticInfo || undefined;
|
|
220
|
-
this.webSearch = webSearch;
|
|
221
|
-
this.agentic = agentic;
|
|
222
285
|
}
|
|
223
286
|
requestStream(requestBody) {
|
|
224
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -251,59 +314,42 @@ class Lens {
|
|
|
251
314
|
});
|
|
252
315
|
}
|
|
253
316
|
chat(_a) {
|
|
254
|
-
return __awaiter(this, arguments, void 0, function* ({ question,
|
|
317
|
+
return __awaiter(this, arguments, void 0, function* ({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, }) {
|
|
255
318
|
const requestParam = {
|
|
256
|
-
command: "
|
|
257
|
-
|
|
319
|
+
command: "lens_chat",
|
|
320
|
+
params: {
|
|
321
|
+
question: question,
|
|
322
|
+
stream: stream !== null && stream !== void 0 ? stream : true,
|
|
323
|
+
},
|
|
258
324
|
};
|
|
259
|
-
if (
|
|
260
|
-
requestParam.
|
|
261
|
-
if (
|
|
262
|
-
requestParam.
|
|
263
|
-
if (
|
|
264
|
-
requestParam.
|
|
265
|
-
if (
|
|
266
|
-
requestParam.
|
|
267
|
-
if (this.maxHisCount)
|
|
268
|
-
requestParam.maxHisCount = this.maxHisCount;
|
|
269
|
-
if (this.sessionKey)
|
|
270
|
-
requestParam.sessionKey = this.sessionKey;
|
|
271
|
-
if (this.numOfRef)
|
|
272
|
-
requestParam.numOfRef = this.numOfRef;
|
|
273
|
-
if (this.customSystemPrompt)
|
|
274
|
-
requestParam.customSystemPrompt = this.customSystemPrompt;
|
|
275
|
-
if (this.staticInfo)
|
|
276
|
-
requestParam.staticInfo = this.staticInfo;
|
|
277
|
-
if (this.webSearch)
|
|
278
|
-
requestParam.webSearch = this.webSearch;
|
|
279
|
-
if (this.agentic)
|
|
280
|
-
requestParam.agentic = this.agentic;
|
|
325
|
+
if (model)
|
|
326
|
+
requestParam.params.model = model;
|
|
327
|
+
if (xfinder)
|
|
328
|
+
requestParam.params.xfinder = xfinder;
|
|
329
|
+
if (webSearch)
|
|
330
|
+
requestParam.params.web_search = webSearch;
|
|
331
|
+
if (agentic)
|
|
332
|
+
requestParam.params.agentic = agentic;
|
|
281
333
|
if (imageUrls)
|
|
282
|
-
requestParam.imageUrls = imageUrls;
|
|
334
|
+
requestParam.params.imageUrls = imageUrls;
|
|
283
335
|
if (fileUrls)
|
|
284
|
-
requestParam.
|
|
285
|
-
if (
|
|
286
|
-
requestParam.
|
|
287
|
-
if (
|
|
288
|
-
requestParam.
|
|
289
|
-
if (
|
|
290
|
-
requestParam.
|
|
291
|
-
if (
|
|
292
|
-
requestParam.
|
|
293
|
-
if (
|
|
294
|
-
requestParam.
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
requestParam.isFirstMsg = true;
|
|
298
|
-
}
|
|
299
|
-
requestParam.withStatus = withStatus ? withStatus : false;
|
|
336
|
+
requestParam.params.file_urls = fileUrls;
|
|
337
|
+
if (customContext)
|
|
338
|
+
requestParam.params.custom_context = customContext;
|
|
339
|
+
if (sessionKey)
|
|
340
|
+
requestParam.params.session_key = sessionKey;
|
|
341
|
+
if (maxHisCount)
|
|
342
|
+
requestParam.params.max_his_count = maxHisCount;
|
|
343
|
+
if (withStatus)
|
|
344
|
+
requestParam.params.with_status = withStatus;
|
|
345
|
+
if (staticInfo)
|
|
346
|
+
requestParam.params.static_info = staticInfo;
|
|
300
347
|
let response = yield this.requestStream(requestParam);
|
|
301
348
|
if (stream) {
|
|
302
|
-
return response;
|
|
349
|
+
return response.body.getReader();
|
|
303
350
|
}
|
|
304
351
|
else {
|
|
305
|
-
|
|
306
|
-
return res;
|
|
352
|
+
return response.json();
|
|
307
353
|
}
|
|
308
354
|
});
|
|
309
355
|
}
|
|
@@ -368,7 +414,7 @@ class AIMS {
|
|
|
368
414
|
/**
|
|
369
415
|
* API Client for interfacing with the Vectocore API.
|
|
370
416
|
*
|
|
371
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
417
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
372
418
|
*/
|
|
373
419
|
constructor({ baseURL, tenantKey } = {}) {
|
|
374
420
|
if (tenantKey === undefined) {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,27 +10,6 @@ export interface ClientOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
baseURL?: string;
|
|
12
12
|
}
|
|
13
|
-
export interface CustomDataParams {
|
|
14
|
-
type: "text" | "image";
|
|
15
|
-
text?: string;
|
|
16
|
-
image_url?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface LensClientOptions {
|
|
19
|
-
tenantKey?: string;
|
|
20
|
-
baseURL?: string;
|
|
21
|
-
role?: string;
|
|
22
|
-
rule?: string;
|
|
23
|
-
outputFormat?: any;
|
|
24
|
-
mode?: "VECTOR" | "BOTH" | "WEB" | "CUSTOM";
|
|
25
|
-
webSearch?: WebSearchOption;
|
|
26
|
-
agentic?: AgenticOption;
|
|
27
|
-
maxHisCount?: number;
|
|
28
|
-
sessionKey?: string;
|
|
29
|
-
customData?: CustomDataParams;
|
|
30
|
-
customSystemPrompt?: string;
|
|
31
|
-
numOfRef?: number;
|
|
32
|
-
staticInfo?: any;
|
|
33
|
-
}
|
|
34
13
|
export interface PutIndexParams {
|
|
35
14
|
/**
|
|
36
15
|
* 생성할 인덱스의 이름입니다.
|
|
@@ -127,17 +106,96 @@ export type FileType = {
|
|
|
127
106
|
url: string;
|
|
128
107
|
extImgUrls?: string[];
|
|
129
108
|
};
|
|
130
|
-
|
|
109
|
+
type XFinderOptions = {
|
|
110
|
+
/**
|
|
111
|
+
* vector | keyword | hybrid (Default : hybrid)
|
|
112
|
+
*/
|
|
113
|
+
mode?: "vector" | "keyword" | "hybrid";
|
|
114
|
+
/**
|
|
115
|
+
* 검색에 사용할 index명 목록, 생략 또는 []시 전체 인덱스 스캔
|
|
116
|
+
*/
|
|
117
|
+
indexNames?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* 검색 max count, 숫자가 많을 수록 많은 토큰을 소모함.
|
|
120
|
+
*/
|
|
121
|
+
top?: number;
|
|
122
|
+
/**
|
|
123
|
+
* AI rerank 사용 여부(Default : false), 사용시 토큰 소모
|
|
124
|
+
*/
|
|
125
|
+
rerank?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* 벡터 Context에 image_url등 멀티모달 이미지가 존재해도 무시하고자 할 경우 사용
|
|
128
|
+
*/
|
|
129
|
+
textOnly?: boolean;
|
|
130
|
+
};
|
|
131
|
+
type WebSearchOptions = {
|
|
132
|
+
/** 이미지 검색 결과도 보여주고 싶을 때 사용 (Default : false) */
|
|
133
|
+
with_image?: boolean;
|
|
134
|
+
/** 비디오 검색 결과도 보여주고 싶을 때 사용 (Default : false) */
|
|
135
|
+
with_video?: boolean;
|
|
136
|
+
};
|
|
137
|
+
type AgenticOptions = {
|
|
138
|
+
/** 추론모드 사용 여부 (추론 모드는 ai agent를 우선순위대로 하나씩 호출하면서 추론 과정을 거침. 정확도는 높으나 속도가 매우 느림) */
|
|
139
|
+
reasoning?: boolean;
|
|
140
|
+
};
|
|
141
|
+
type CustomContextOptions = {
|
|
142
|
+
/** ext 타입의 사용자 정의 Context */
|
|
143
|
+
text?: string;
|
|
144
|
+
/** 멀티모달 Context로 전송할 이미지 경로 URL */
|
|
145
|
+
imageUrls?: string;
|
|
146
|
+
};
|
|
147
|
+
export interface LensChatParams {
|
|
148
|
+
/** 사용자 질문 (필수) */
|
|
131
149
|
question: string;
|
|
150
|
+
/** 스트림 응답 모드 (선택) 기본값 : true */
|
|
151
|
+
stream?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* 모델 선택 (선택) 기본값 : 5.1chat
|
|
154
|
+
* - 5.1chat, 5chat, 4o, mini, Default : 5.1chat
|
|
155
|
+
* - ‼️ 단, chat 모델의 경우 만료될 수 있음.
|
|
156
|
+
* - ‼️ mini 모델은 멀티모달을 사용할 수 없음.
|
|
157
|
+
* */
|
|
158
|
+
model?: "5.1chat" | "5chat" | "4o" | "mini";
|
|
159
|
+
/** 사전에 등록한 내부지식(X-Finder)를 사용하고자 할 경우 아래 파라미터 추가 ({@link XFinderOptions}) */
|
|
160
|
+
xfinder?: XFinderOptions;
|
|
161
|
+
/** 웹 검색 결과를 Context로 제공하고자 할 때 사용(별도 권한 필요) ({@link WebSearchOptions}) */
|
|
162
|
+
webSearch?: WebSearchOptions;
|
|
163
|
+
/** AI 추론 과정에서 ai agent들을 호출하고 싶을때 사용. Vectocore가 ai agent를 자동으로 호출 ({@link AgenticOptions}) */
|
|
164
|
+
agentic?: AgenticOptions;
|
|
165
|
+
/** 사용자 멀티모달 이미지 입력 시 자동으로 호출 */
|
|
132
166
|
imageUrls?: string[];
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
167
|
+
/** 사용자 멀티모달 파일(페이지별 이미지) 입력 시, 순수 파일을 올릴 수는 없고 별도의 pdf to images 와 같은 전처리 과정을 거쳐 문서의 각 페이지별 이미지 캡쳐본을 올릴 수 있음. 자동으로 호출 */
|
|
168
|
+
fileUrls?: string[];
|
|
169
|
+
/**
|
|
170
|
+
* 사용자가 직접 정의한 Context 내에서 답변하고자 할 경우 ({@link CustomContextOptions})
|
|
171
|
+
* 해당 파라미터가 있는 경우 Rag를 무시하고 사용자가 입력한 Context 내에서만 답변합니다.
|
|
172
|
+
*/
|
|
173
|
+
customContext?: CustomContextOptions;
|
|
174
|
+
/**
|
|
175
|
+
* 사용자의 이전 대화를 참고하여 연속성있는 챗봇을 구성할때 사용하는 값. 세션키가 없는 경우 챗봇이 이전대화를 활용하지 않아 소모되는 토큰을 절약할 수 있지만 연속성 있는 대화를 할 수 없습니다. 세션키를 입력하면 이전대화를 참고하여 프롬프트를 생성하기 때문에 토큰의 비용이 올라가지만 연속성있는 대화를 통해 사용자의 경험을 개선할 수 있습니다.
|
|
176
|
+
* ※ 세션키는 각 챗봇 시스템에서 사용자 1인을 구분할 수 있는 유일한 값으로 전달하는게 좋습니다.(예 : 고객ID)
|
|
177
|
+
*/
|
|
178
|
+
sessionKey?: string;
|
|
179
|
+
/**
|
|
180
|
+
* 세션키가 있는 경우 불러올 이전대화의 목록 건수 입니다. Default : 2. 대화 목록을 지나치게 불러오면 토큰의 비용이 비약적으로 증가할 수 있으며 AI 챗봇의 프롬프트 해석 능력도 떨어질 수 있습니다. 적절한 건수를 설정하세요.
|
|
181
|
+
*/
|
|
182
|
+
maxHisCount?: number;
|
|
183
|
+
/**
|
|
184
|
+
* AI 백엔드에서 진행되는 상태를 구간별로 전송받는 데이터입니다.
|
|
185
|
+
* * @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* {
|
|
188
|
+
* status_0000: ["20260120101650200000", "채팅을 시작합니다."],
|
|
189
|
+
* status_1000: ["20260120101650208399", "채팅 이력을 확인합니다."],
|
|
190
|
+
* status_2000: ["20260120101651151011", "지식 검색을 시작합니다."],
|
|
191
|
+
* // ... 중략
|
|
192
|
+
* status_3019: ["20260120101713662980", "AI 답변이 완료되었습니다."]
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
withStatus?: boolean;
|
|
197
|
+
/** 사용자의 질문으로 보낼 수 없는 고유한 정보들이 있는 경우 static_info에 보내면 해당 데이터를 AI가 참고함. */
|
|
198
|
+
staticInfo?: any;
|
|
141
199
|
}
|
|
142
200
|
export interface ChatHistoryParams {
|
|
143
201
|
sessionKey: string;
|
|
@@ -148,15 +206,6 @@ export interface TranslateParams {
|
|
|
148
206
|
text: string;
|
|
149
207
|
stream?: boolean | undefined;
|
|
150
208
|
}
|
|
151
|
-
type WebSearchOption = {
|
|
152
|
-
model?: "google" | "bing";
|
|
153
|
-
withImage?: boolean;
|
|
154
|
-
withVideo?: boolean;
|
|
155
|
-
};
|
|
156
|
-
type AgenticOption = {
|
|
157
|
-
enable?: boolean;
|
|
158
|
-
reasoning?: boolean;
|
|
159
|
-
};
|
|
160
209
|
export declare class Vectocore {
|
|
161
210
|
tenantKey: string | undefined;
|
|
162
211
|
baseURL: string;
|
|
@@ -167,45 +216,108 @@ export declare class Vectocore {
|
|
|
167
216
|
*/
|
|
168
217
|
constructor({ baseURL, tenantKey }?: ClientOptions);
|
|
169
218
|
protected requestPost(requestBody: any): Promise<any>;
|
|
219
|
+
/**
|
|
220
|
+
* 인덱스를 생성/수정합니다.
|
|
221
|
+
* @param params ({@link PutIndexParams})
|
|
222
|
+
* - **indexName**: string (필수) 생성 및 수정할 인덱스 명
|
|
223
|
+
* - description: string (선택) 인덱스에 대한 설명
|
|
224
|
+
* @returns 식제 결과
|
|
225
|
+
*/
|
|
170
226
|
putIndex({ indexName, description }: PutIndexParams): Promise<any>;
|
|
227
|
+
/**
|
|
228
|
+
* 인덱스를 삭제합니다.
|
|
229
|
+
* @param params ({@link DeleteIndexParams})
|
|
230
|
+
* - **indexName**: string (필수) 삭제할 인덱스의 이름
|
|
231
|
+
* @returns 식제 결과
|
|
232
|
+
*/
|
|
171
233
|
deleteIndex({ indexName }: DeleteIndexParams): Promise<any>;
|
|
234
|
+
/**
|
|
235
|
+
* 인덱스 목록을 조회합니다.
|
|
236
|
+
* @returns 인덱스 목록
|
|
237
|
+
*/
|
|
172
238
|
listIndex(): Promise<any>;
|
|
239
|
+
/**
|
|
240
|
+
* 인덱스에 문서 저장
|
|
241
|
+
* @param params ({@link PutExtremeDataParams})
|
|
242
|
+
* - **indexName**: string (필수) 문서를 저장할 인덱스의 이름
|
|
243
|
+
* - **docBody**: json (필수)
|
|
244
|
+
* - **id**: string (선택) 도큐먼트 ID (소문자, 영문, -), 값은 인덱스내에서 유일해야함, 신규 row일 경우 각 시스템에서 직접 채번하거나 ""빈값으로 보내면 자동으로 채번함
|
|
245
|
+
* - **keywords**: string (필수) 검색의 대상이 되는 필드. 사용자 질문의 의도를 파악하여 RAG내에서 유사도를 비교하여 높은 순서로 결과를 리턴 받는다.
|
|
246
|
+
* - **data**: string (필수) 키워드에 해당하는 문서의 실제 내용
|
|
247
|
+
* - docType: "text"|"image" (선택) Default : "text", 저장할 지식의 타입으로 Default는 "text". doc_type이 "image"일 경우 추가로 "image_url" 필드를 사용합니다.
|
|
248
|
+
* - imageUrl: string (선택) doc_type이 "image"일 경우 사용하는 필드로 웹에서 접근 가능한 이미지의 경로를 입력.
|
|
249
|
+
* - metadata: json (선택) 문서 저장시 추가로 남기고 싶은 정보를 json 형식으로 추가하면 향후 검색 결과시 리턴. 문서명이나, 페이지 번호 등을 입력하여 출처 확인용으로 사용할 수 있다
|
|
250
|
+
* - refOnlyText: bool (선택) ens 기능 사용시 사용하는 옵션으로 doc_type이 "image"인 경우 "image_url"의 경로를 자동으로 멀티모달로 전달하는데 ref_only_text : true로 설정한 경우 멀티모달을 전달하지 않고 "data" 필드의 정보만 context로 활용한다.
|
|
251
|
+
* @returns 문서 저장 결과
|
|
252
|
+
*/
|
|
173
253
|
putExtremeData({ indexName, docBody }: PutExtremeDataParams): Promise<any>;
|
|
254
|
+
/**
|
|
255
|
+
* 특정 문서를 조회합니다.
|
|
256
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link GetExtremeDataParams})
|
|
257
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
258
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
259
|
+
* @returns 문서 정보
|
|
260
|
+
*/
|
|
174
261
|
getExtremeData({ indexName, documentId }: GetExtremeDataParams): Promise<any>;
|
|
262
|
+
/**
|
|
263
|
+
* 특정 인덱스에 저장된 지식 데이터를 조회합니다.(페이징)
|
|
264
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListExtremeDataParams})
|
|
265
|
+
* - **indexName**: string (필수)
|
|
266
|
+
* - lastKey: string (선택) 최초 검색 결과에서 전달 받은 토큰값
|
|
267
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
268
|
+
* @returns 인덱스 목록
|
|
269
|
+
*/
|
|
175
270
|
listExtremeData({ indexName, lastKey, withVectorValue }: ListExtremeDataParams): Promise<any>;
|
|
176
271
|
/**
|
|
177
272
|
* 특정 인덱스에 저장된 모든 지식 데이터를 조회합니다.
|
|
178
|
-
*
|
|
273
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListAllExtremeDataParams})
|
|
274
|
+
* - **indexName**: string (필수)
|
|
275
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
179
276
|
* @returns 인덱스 목록
|
|
180
277
|
*/
|
|
181
278
|
listAllExtremeData({ indexName, withVectorValue }: ListAllExtremeDataParams): Promise<any>;
|
|
279
|
+
/**
|
|
280
|
+
* 특정 문서를 삭제합니다.
|
|
281
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
282
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
283
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
284
|
+
* @returns 삭제 결과
|
|
285
|
+
*/
|
|
182
286
|
deleteExtremeData({ indexName, documentId }: DeleteExtremeDataParams): Promise<any>;
|
|
287
|
+
/**
|
|
288
|
+
* X-Finder의 문서를 AI 검색합니다.
|
|
289
|
+
* @param params ({@link ExtremeSearchParams})
|
|
290
|
+
* - **question**: string (필수) 사용자 질문 (시멘틱 검색을 사용하기때문에 서술형을 질문해도 의미를 파악하여 유사한 결과를 유사도 순위별로 리턴.)
|
|
291
|
+
* - **mode**: "vector" | "keyword" | "hybrid" (선택) Default : "vector"
|
|
292
|
+
* - vector 모드 : 시멘틱 유사도만 사용
|
|
293
|
+
* - keyword 모드 : 키워드 유사도만 사용, 키워드 모드인 경우 해당 "단어"가 문서에 없으면 빈 list를 리턴
|
|
294
|
+
* - hybrid 모드 : 시멘틱 검색 순위와 키워드 검색 순위를 모두 사용하여 순위 결정
|
|
295
|
+
* - indexNames: string[] (선택) 사용자의 질문을 검색하고자하는 인덱스 목록, 생략하거나 []를 전송시 전체 인덱스에서 검색 실행
|
|
296
|
+
* - top: number (선택) 결과로 보고싶은 목록의 최대 건수, 생략시 10건을 조회.
|
|
297
|
+
* - rerank: bool (선택) 검색 mode가 hybrid일 경우 벡터 검색과 키워드 검색 결과를 ai가 다시 score를 산정하는 방식으로 별도의 토큰이 소모 됨.
|
|
298
|
+
* @returns 순위가 있는 문서 목록
|
|
299
|
+
*/
|
|
183
300
|
extremeSearch({ mode, indexNames, question, top, rerank }: ExtremeSearchParams): Promise<any>;
|
|
301
|
+
/**
|
|
302
|
+
* 웹검색
|
|
303
|
+
* @param params ({@link WebSearchParams})
|
|
304
|
+
* - **question**: string (필수) 사용자 질문
|
|
305
|
+
* @returns 웹 검색 결과
|
|
306
|
+
*/
|
|
184
307
|
webSearch({ question }: WebSearchParams): Promise<any>;
|
|
185
308
|
}
|
|
186
309
|
export declare class Lens {
|
|
187
310
|
tenantKey: string | undefined;
|
|
188
311
|
baseURL: string;
|
|
189
|
-
role: string | undefined;
|
|
190
|
-
rule: string | undefined;
|
|
191
|
-
outputFormat: any;
|
|
192
|
-
mode: "VECTOR" | "BOTH" | "WEB" | "CUSTOM" | undefined;
|
|
193
|
-
webSearch: WebSearchOption | undefined;
|
|
194
|
-
agentic: AgenticOption | undefined;
|
|
195
|
-
maxHisCount: number | undefined;
|
|
196
|
-
sessionKey: string | undefined;
|
|
197
|
-
numOfRef: number | undefined;
|
|
198
|
-
customSystemPrompt: string | undefined;
|
|
199
|
-
staticInfo: any;
|
|
200
312
|
/**
|
|
201
313
|
* API Client for interfacing with the Lens API.
|
|
202
314
|
*
|
|
203
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
315
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
204
316
|
*/
|
|
205
|
-
constructor({ tenantKey, baseURL
|
|
317
|
+
constructor({ tenantKey, baseURL }: ClientOptions);
|
|
206
318
|
protected requestStream(requestBody: any): Promise<ReadableStream<Uint8Array> | null>;
|
|
207
319
|
protected genStreamResponse(streamRes: ReadableStream): Promise<any>;
|
|
208
|
-
chat({ question,
|
|
320
|
+
chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, }: LensChatParams): Promise<any>;
|
|
209
321
|
history({ sessionKey, limit }: ChatHistoryParams): Promise<any>;
|
|
210
322
|
jsonAutoComplete(jsonString: string): string | null;
|
|
211
323
|
}
|
|
@@ -215,7 +327,7 @@ export declare class AIMS {
|
|
|
215
327
|
/**
|
|
216
328
|
* API Client for interfacing with the Vectocore API.
|
|
217
329
|
*
|
|
218
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
330
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
219
331
|
*/
|
|
220
332
|
constructor({ baseURL, tenantKey }?: ClientOptions);
|
|
221
333
|
protected requestStream(requestBody: any): Promise<ReadableStream<Uint8Array> | null>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -26,6 +26,13 @@ export class Vectocore {
|
|
|
26
26
|
const response = await axios.post(this.baseURL, requestBody, config);
|
|
27
27
|
return response.data;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 인덱스를 생성/수정합니다.
|
|
31
|
+
* @param params ({@link PutIndexParams})
|
|
32
|
+
* - **indexName**: string (필수) 생성 및 수정할 인덱스 명
|
|
33
|
+
* - description: string (선택) 인덱스에 대한 설명
|
|
34
|
+
* @returns 식제 결과
|
|
35
|
+
*/
|
|
29
36
|
async putIndex({ indexName, description }) {
|
|
30
37
|
const requestParam = {
|
|
31
38
|
command: "put_index",
|
|
@@ -37,6 +44,12 @@ export class Vectocore {
|
|
|
37
44
|
const response = await this.requestPost(requestParam);
|
|
38
45
|
return response;
|
|
39
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 인덱스를 삭제합니다.
|
|
49
|
+
* @param params ({@link DeleteIndexParams})
|
|
50
|
+
* - **indexName**: string (필수) 삭제할 인덱스의 이름
|
|
51
|
+
* @returns 식제 결과
|
|
52
|
+
*/
|
|
40
53
|
async deleteIndex({ indexName }) {
|
|
41
54
|
const requestParam = {
|
|
42
55
|
command: "delete_index",
|
|
@@ -47,6 +60,10 @@ export class Vectocore {
|
|
|
47
60
|
const response = await this.requestPost(requestParam);
|
|
48
61
|
return response;
|
|
49
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 인덱스 목록을 조회합니다.
|
|
65
|
+
* @returns 인덱스 목록
|
|
66
|
+
*/
|
|
50
67
|
async listIndex() {
|
|
51
68
|
const requestParam = {
|
|
52
69
|
command: "list_index",
|
|
@@ -54,6 +71,20 @@ export class Vectocore {
|
|
|
54
71
|
const response = await this.requestPost(requestParam);
|
|
55
72
|
return response;
|
|
56
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* 인덱스에 문서 저장
|
|
76
|
+
* @param params ({@link PutExtremeDataParams})
|
|
77
|
+
* - **indexName**: string (필수) 문서를 저장할 인덱스의 이름
|
|
78
|
+
* - **docBody**: json (필수)
|
|
79
|
+
* - **id**: string (선택) 도큐먼트 ID (소문자, 영문, -), 값은 인덱스내에서 유일해야함, 신규 row일 경우 각 시스템에서 직접 채번하거나 ""빈값으로 보내면 자동으로 채번함
|
|
80
|
+
* - **keywords**: string (필수) 검색의 대상이 되는 필드. 사용자 질문의 의도를 파악하여 RAG내에서 유사도를 비교하여 높은 순서로 결과를 리턴 받는다.
|
|
81
|
+
* - **data**: string (필수) 키워드에 해당하는 문서의 실제 내용
|
|
82
|
+
* - docType: "text"|"image" (선택) Default : "text", 저장할 지식의 타입으로 Default는 "text". doc_type이 "image"일 경우 추가로 "image_url" 필드를 사용합니다.
|
|
83
|
+
* - imageUrl: string (선택) doc_type이 "image"일 경우 사용하는 필드로 웹에서 접근 가능한 이미지의 경로를 입력.
|
|
84
|
+
* - metadata: json (선택) 문서 저장시 추가로 남기고 싶은 정보를 json 형식으로 추가하면 향후 검색 결과시 리턴. 문서명이나, 페이지 번호 등을 입력하여 출처 확인용으로 사용할 수 있다
|
|
85
|
+
* - refOnlyText: bool (선택) ens 기능 사용시 사용하는 옵션으로 doc_type이 "image"인 경우 "image_url"의 경로를 자동으로 멀티모달로 전달하는데 ref_only_text : true로 설정한 경우 멀티모달을 전달하지 않고 "data" 필드의 정보만 context로 활용한다.
|
|
86
|
+
* @returns 문서 저장 결과
|
|
87
|
+
*/
|
|
57
88
|
async putExtremeData({ indexName, docBody }) {
|
|
58
89
|
const requestParam = {
|
|
59
90
|
command: "put_extreme_data",
|
|
@@ -77,6 +108,13 @@ export class Vectocore {
|
|
|
77
108
|
const response = await this.requestPost(requestParam);
|
|
78
109
|
return response;
|
|
79
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* 특정 문서를 조회합니다.
|
|
113
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link GetExtremeDataParams})
|
|
114
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
115
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
116
|
+
* @returns 문서 정보
|
|
117
|
+
*/
|
|
80
118
|
async getExtremeData({ indexName, documentId }) {
|
|
81
119
|
const requestParam = {
|
|
82
120
|
command: "get_extreme_data",
|
|
@@ -88,6 +126,14 @@ export class Vectocore {
|
|
|
88
126
|
const response = await this.requestPost(requestParam);
|
|
89
127
|
return response;
|
|
90
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* 특정 인덱스에 저장된 지식 데이터를 조회합니다.(페이징)
|
|
131
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListExtremeDataParams})
|
|
132
|
+
* - **indexName**: string (필수)
|
|
133
|
+
* - lastKey: string (선택) 최초 검색 결과에서 전달 받은 토큰값
|
|
134
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
135
|
+
* @returns 인덱스 목록
|
|
136
|
+
*/
|
|
91
137
|
async listExtremeData({ indexName, lastKey, withVectorValue }) {
|
|
92
138
|
const requestParam = {
|
|
93
139
|
command: "list_extreme_data",
|
|
@@ -104,7 +150,9 @@ export class Vectocore {
|
|
|
104
150
|
}
|
|
105
151
|
/**
|
|
106
152
|
* 특정 인덱스에 저장된 모든 지식 데이터를 조회합니다.
|
|
107
|
-
*
|
|
153
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListAllExtremeDataParams})
|
|
154
|
+
* - **indexName**: string (필수)
|
|
155
|
+
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
108
156
|
* @returns 인덱스 목록
|
|
109
157
|
*/
|
|
110
158
|
async listAllExtremeData({ indexName, withVectorValue }) {
|
|
@@ -118,6 +166,13 @@ export class Vectocore {
|
|
|
118
166
|
const response = await this.requestPost(requestParam);
|
|
119
167
|
return response;
|
|
120
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* 특정 문서를 삭제합니다.
|
|
171
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
172
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
173
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
174
|
+
* @returns 삭제 결과
|
|
175
|
+
*/
|
|
121
176
|
async deleteExtremeData({ indexName, documentId }) {
|
|
122
177
|
const requestParam = {
|
|
123
178
|
command: "delete_extreme_data",
|
|
@@ -129,6 +184,19 @@ export class Vectocore {
|
|
|
129
184
|
const response = await this.requestPost(requestParam);
|
|
130
185
|
return response;
|
|
131
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* X-Finder의 문서를 AI 검색합니다.
|
|
189
|
+
* @param params ({@link ExtremeSearchParams})
|
|
190
|
+
* - **question**: string (필수) 사용자 질문 (시멘틱 검색을 사용하기때문에 서술형을 질문해도 의미를 파악하여 유사한 결과를 유사도 순위별로 리턴.)
|
|
191
|
+
* - **mode**: "vector" | "keyword" | "hybrid" (선택) Default : "vector"
|
|
192
|
+
* - vector 모드 : 시멘틱 유사도만 사용
|
|
193
|
+
* - keyword 모드 : 키워드 유사도만 사용, 키워드 모드인 경우 해당 "단어"가 문서에 없으면 빈 list를 리턴
|
|
194
|
+
* - hybrid 모드 : 시멘틱 검색 순위와 키워드 검색 순위를 모두 사용하여 순위 결정
|
|
195
|
+
* - indexNames: string[] (선택) 사용자의 질문을 검색하고자하는 인덱스 목록, 생략하거나 []를 전송시 전체 인덱스에서 검색 실행
|
|
196
|
+
* - top: number (선택) 결과로 보고싶은 목록의 최대 건수, 생략시 10건을 조회.
|
|
197
|
+
* - rerank: bool (선택) 검색 mode가 hybrid일 경우 벡터 검색과 키워드 검색 결과를 ai가 다시 score를 산정하는 방식으로 별도의 토큰이 소모 됨.
|
|
198
|
+
* @returns 순위가 있는 문서 목록
|
|
199
|
+
*/
|
|
132
200
|
async extremeSearch({ mode, indexNames, question, top, rerank }) {
|
|
133
201
|
const requestParam = {
|
|
134
202
|
command: "extreme_search",
|
|
@@ -143,6 +211,12 @@ export class Vectocore {
|
|
|
143
211
|
const response = await this.requestPost(requestParam);
|
|
144
212
|
return response;
|
|
145
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* 웹검색
|
|
216
|
+
* @param params ({@link WebSearchParams})
|
|
217
|
+
* - **question**: string (필수) 사용자 질문
|
|
218
|
+
* @returns 웹 검색 결과
|
|
219
|
+
*/
|
|
146
220
|
async webSearch({ question }) {
|
|
147
221
|
const requestParam = {
|
|
148
222
|
command: "web_search",
|
|
@@ -157,23 +231,12 @@ export class Vectocore {
|
|
|
157
231
|
export class Lens {
|
|
158
232
|
tenantKey;
|
|
159
233
|
baseURL;
|
|
160
|
-
role;
|
|
161
|
-
rule;
|
|
162
|
-
outputFormat;
|
|
163
|
-
mode;
|
|
164
|
-
webSearch;
|
|
165
|
-
agentic;
|
|
166
|
-
maxHisCount;
|
|
167
|
-
sessionKey;
|
|
168
|
-
numOfRef;
|
|
169
|
-
customSystemPrompt;
|
|
170
|
-
staticInfo;
|
|
171
234
|
/**
|
|
172
235
|
* API Client for interfacing with the Lens API.
|
|
173
236
|
*
|
|
174
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
237
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
175
238
|
*/
|
|
176
|
-
constructor({ tenantKey, baseURL
|
|
239
|
+
constructor({ tenantKey, baseURL }) {
|
|
177
240
|
if (tenantKey === undefined) {
|
|
178
241
|
throw new Error("error tenantKey is undefined");
|
|
179
242
|
}
|
|
@@ -184,17 +247,6 @@ export class Lens {
|
|
|
184
247
|
else {
|
|
185
248
|
this.baseURL = baseURL;
|
|
186
249
|
}
|
|
187
|
-
this.role = role;
|
|
188
|
-
this.rule = rule;
|
|
189
|
-
this.outputFormat = outputFormat;
|
|
190
|
-
this.mode = mode;
|
|
191
|
-
this.maxHisCount = maxHisCount;
|
|
192
|
-
this.sessionKey = sessionKey;
|
|
193
|
-
this.numOfRef = numOfRef;
|
|
194
|
-
this.customSystemPrompt = customSystemPrompt || undefined;
|
|
195
|
-
this.staticInfo = staticInfo || undefined;
|
|
196
|
-
this.webSearch = webSearch;
|
|
197
|
-
this.agentic = agentic;
|
|
198
250
|
}
|
|
199
251
|
async requestStream(requestBody) {
|
|
200
252
|
let header = {
|
|
@@ -222,59 +274,42 @@ export class Lens {
|
|
|
222
274
|
const payload = JSON.parse(content);
|
|
223
275
|
return payload;
|
|
224
276
|
}
|
|
225
|
-
async chat({ question,
|
|
277
|
+
async chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, }) {
|
|
226
278
|
const requestParam = {
|
|
227
|
-
command: "
|
|
228
|
-
|
|
279
|
+
command: "lens_chat",
|
|
280
|
+
params: {
|
|
281
|
+
question: question,
|
|
282
|
+
stream: stream ?? true,
|
|
283
|
+
},
|
|
229
284
|
};
|
|
230
|
-
if (
|
|
231
|
-
requestParam.
|
|
232
|
-
if (
|
|
233
|
-
requestParam.
|
|
234
|
-
if (
|
|
235
|
-
requestParam.
|
|
236
|
-
if (
|
|
237
|
-
requestParam.
|
|
238
|
-
if (this.maxHisCount)
|
|
239
|
-
requestParam.maxHisCount = this.maxHisCount;
|
|
240
|
-
if (this.sessionKey)
|
|
241
|
-
requestParam.sessionKey = this.sessionKey;
|
|
242
|
-
if (this.numOfRef)
|
|
243
|
-
requestParam.numOfRef = this.numOfRef;
|
|
244
|
-
if (this.customSystemPrompt)
|
|
245
|
-
requestParam.customSystemPrompt = this.customSystemPrompt;
|
|
246
|
-
if (this.staticInfo)
|
|
247
|
-
requestParam.staticInfo = this.staticInfo;
|
|
248
|
-
if (this.webSearch)
|
|
249
|
-
requestParam.webSearch = this.webSearch;
|
|
250
|
-
if (this.agentic)
|
|
251
|
-
requestParam.agentic = this.agentic;
|
|
285
|
+
if (model)
|
|
286
|
+
requestParam.params.model = model;
|
|
287
|
+
if (xfinder)
|
|
288
|
+
requestParam.params.xfinder = xfinder;
|
|
289
|
+
if (webSearch)
|
|
290
|
+
requestParam.params.web_search = webSearch;
|
|
291
|
+
if (agentic)
|
|
292
|
+
requestParam.params.agentic = agentic;
|
|
252
293
|
if (imageUrls)
|
|
253
|
-
requestParam.imageUrls = imageUrls;
|
|
294
|
+
requestParam.params.imageUrls = imageUrls;
|
|
254
295
|
if (fileUrls)
|
|
255
|
-
requestParam.
|
|
256
|
-
if (
|
|
257
|
-
requestParam.
|
|
258
|
-
if (
|
|
259
|
-
requestParam.
|
|
260
|
-
if (
|
|
261
|
-
requestParam.
|
|
262
|
-
if (
|
|
263
|
-
requestParam.
|
|
264
|
-
if (
|
|
265
|
-
requestParam.
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
requestParam.isFirstMsg = true;
|
|
269
|
-
}
|
|
270
|
-
requestParam.withStatus = withStatus ? withStatus : false;
|
|
296
|
+
requestParam.params.file_urls = fileUrls;
|
|
297
|
+
if (customContext)
|
|
298
|
+
requestParam.params.custom_context = customContext;
|
|
299
|
+
if (sessionKey)
|
|
300
|
+
requestParam.params.session_key = sessionKey;
|
|
301
|
+
if (maxHisCount)
|
|
302
|
+
requestParam.params.max_his_count = maxHisCount;
|
|
303
|
+
if (withStatus)
|
|
304
|
+
requestParam.params.with_status = withStatus;
|
|
305
|
+
if (staticInfo)
|
|
306
|
+
requestParam.params.static_info = staticInfo;
|
|
271
307
|
let response = await this.requestStream(requestParam);
|
|
272
308
|
if (stream) {
|
|
273
|
-
return response;
|
|
309
|
+
return response.body.getReader();
|
|
274
310
|
}
|
|
275
311
|
else {
|
|
276
|
-
|
|
277
|
-
return res;
|
|
312
|
+
return response.json();
|
|
278
313
|
}
|
|
279
314
|
}
|
|
280
315
|
async history({ sessionKey, limit }) {
|
|
@@ -337,7 +372,7 @@ export class AIMS {
|
|
|
337
372
|
/**
|
|
338
373
|
* API Client for interfacing with the Vectocore API.
|
|
339
374
|
*
|
|
340
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
375
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
341
376
|
*/
|
|
342
377
|
constructor({ baseURL, tenantKey } = {}) {
|
|
343
378
|
if (tenantKey === undefined) {
|