vectocore4 0.0.11 → 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 +104 -60
- package/dist/index.d.ts +165 -55
- package/dist/mjs/index.js +104 -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,7 @@ class Vectocore {
|
|
|
132
178
|
}
|
|
133
179
|
/**
|
|
134
180
|
* 특정 인덱스에 저장된 모든 지식 데이터를 조회합니다.
|
|
135
|
-
*
|
|
181
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListAllExtremeDataParams})
|
|
136
182
|
* - **indexName**: string (필수)
|
|
137
183
|
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
138
184
|
* @returns 인덱스 목록
|
|
@@ -150,6 +196,13 @@ class Vectocore {
|
|
|
150
196
|
return response;
|
|
151
197
|
});
|
|
152
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* 특정 문서를 삭제합니다.
|
|
201
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
202
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
203
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
204
|
+
* @returns 삭제 결과
|
|
205
|
+
*/
|
|
153
206
|
deleteExtremeData(_a) {
|
|
154
207
|
return __awaiter(this, arguments, void 0, function* ({ indexName, documentId }) {
|
|
155
208
|
const requestParam = {
|
|
@@ -163,6 +216,19 @@ class Vectocore {
|
|
|
163
216
|
return response;
|
|
164
217
|
});
|
|
165
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
|
+
*/
|
|
166
232
|
extremeSearch(_a) {
|
|
167
233
|
return __awaiter(this, arguments, void 0, function* ({ mode, indexNames, question, top, rerank }) {
|
|
168
234
|
const requestParam = {
|
|
@@ -179,6 +245,12 @@ class Vectocore {
|
|
|
179
245
|
return response;
|
|
180
246
|
});
|
|
181
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* 웹검색
|
|
250
|
+
* @param params ({@link WebSearchParams})
|
|
251
|
+
* - **question**: string (필수) 사용자 질문
|
|
252
|
+
* @returns 웹 검색 결과
|
|
253
|
+
*/
|
|
182
254
|
webSearch(_a) {
|
|
183
255
|
return __awaiter(this, arguments, void 0, function* ({ question }) {
|
|
184
256
|
const requestParam = {
|
|
@@ -197,9 +269,9 @@ class Lens {
|
|
|
197
269
|
/**
|
|
198
270
|
* API Client for interfacing with the Lens API.
|
|
199
271
|
*
|
|
200
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
272
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
201
273
|
*/
|
|
202
|
-
constructor({ tenantKey, baseURL
|
|
274
|
+
constructor({ tenantKey, baseURL }) {
|
|
203
275
|
if (tenantKey === undefined) {
|
|
204
276
|
throw new Error("error tenantKey is undefined");
|
|
205
277
|
}
|
|
@@ -210,17 +282,6 @@ class Lens {
|
|
|
210
282
|
else {
|
|
211
283
|
this.baseURL = baseURL;
|
|
212
284
|
}
|
|
213
|
-
this.role = role;
|
|
214
|
-
this.rule = rule;
|
|
215
|
-
this.outputFormat = outputFormat;
|
|
216
|
-
this.mode = mode;
|
|
217
|
-
this.maxHisCount = maxHisCount;
|
|
218
|
-
this.sessionKey = sessionKey;
|
|
219
|
-
this.numOfRef = numOfRef;
|
|
220
|
-
this.customSystemPrompt = customSystemPrompt || undefined;
|
|
221
|
-
this.staticInfo = staticInfo || undefined;
|
|
222
|
-
this.webSearch = webSearch;
|
|
223
|
-
this.agentic = agentic;
|
|
224
285
|
}
|
|
225
286
|
requestStream(requestBody) {
|
|
226
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -253,59 +314,42 @@ class Lens {
|
|
|
253
314
|
});
|
|
254
315
|
}
|
|
255
316
|
chat(_a) {
|
|
256
|
-
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, }) {
|
|
257
318
|
const requestParam = {
|
|
258
|
-
command: "
|
|
259
|
-
|
|
319
|
+
command: "lens_chat",
|
|
320
|
+
params: {
|
|
321
|
+
question: question,
|
|
322
|
+
stream: stream !== null && stream !== void 0 ? stream : true,
|
|
323
|
+
},
|
|
260
324
|
};
|
|
261
|
-
if (
|
|
262
|
-
requestParam.
|
|
263
|
-
if (
|
|
264
|
-
requestParam.
|
|
265
|
-
if (
|
|
266
|
-
requestParam.
|
|
267
|
-
if (
|
|
268
|
-
requestParam.
|
|
269
|
-
if (this.maxHisCount)
|
|
270
|
-
requestParam.maxHisCount = this.maxHisCount;
|
|
271
|
-
if (this.sessionKey)
|
|
272
|
-
requestParam.sessionKey = this.sessionKey;
|
|
273
|
-
if (this.numOfRef)
|
|
274
|
-
requestParam.numOfRef = this.numOfRef;
|
|
275
|
-
if (this.customSystemPrompt)
|
|
276
|
-
requestParam.customSystemPrompt = this.customSystemPrompt;
|
|
277
|
-
if (this.staticInfo)
|
|
278
|
-
requestParam.staticInfo = this.staticInfo;
|
|
279
|
-
if (this.webSearch)
|
|
280
|
-
requestParam.webSearch = this.webSearch;
|
|
281
|
-
if (this.agentic)
|
|
282
|
-
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;
|
|
283
333
|
if (imageUrls)
|
|
284
|
-
requestParam.imageUrls = imageUrls;
|
|
334
|
+
requestParam.params.imageUrls = imageUrls;
|
|
285
335
|
if (fileUrls)
|
|
286
|
-
requestParam.
|
|
287
|
-
if (
|
|
288
|
-
requestParam.
|
|
289
|
-
if (
|
|
290
|
-
requestParam.
|
|
291
|
-
if (
|
|
292
|
-
requestParam.
|
|
293
|
-
if (
|
|
294
|
-
requestParam.
|
|
295
|
-
if (
|
|
296
|
-
requestParam.
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
requestParam.isFirstMsg = true;
|
|
300
|
-
}
|
|
301
|
-
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;
|
|
302
347
|
let response = yield this.requestStream(requestParam);
|
|
303
348
|
if (stream) {
|
|
304
|
-
return response;
|
|
349
|
+
return response.body.getReader();
|
|
305
350
|
}
|
|
306
351
|
else {
|
|
307
|
-
|
|
308
|
-
return res;
|
|
352
|
+
return response.json();
|
|
309
353
|
}
|
|
310
354
|
});
|
|
311
355
|
}
|
|
@@ -370,7 +414,7 @@ class AIMS {
|
|
|
370
414
|
/**
|
|
371
415
|
* API Client for interfacing with the Vectocore API.
|
|
372
416
|
*
|
|
373
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
417
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
374
418
|
*/
|
|
375
419
|
constructor({ baseURL, tenantKey } = {}) {
|
|
376
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,47 +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})
|
|
179
274
|
* - **indexName**: string (필수)
|
|
180
275
|
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
181
276
|
* @returns 인덱스 목록
|
|
182
277
|
*/
|
|
183
278
|
listAllExtremeData({ indexName, withVectorValue }: ListAllExtremeDataParams): Promise<any>;
|
|
279
|
+
/**
|
|
280
|
+
* 특정 문서를 삭제합니다.
|
|
281
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
282
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
283
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
284
|
+
* @returns 삭제 결과
|
|
285
|
+
*/
|
|
184
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
|
+
*/
|
|
185
300
|
extremeSearch({ mode, indexNames, question, top, rerank }: ExtremeSearchParams): Promise<any>;
|
|
301
|
+
/**
|
|
302
|
+
* 웹검색
|
|
303
|
+
* @param params ({@link WebSearchParams})
|
|
304
|
+
* - **question**: string (필수) 사용자 질문
|
|
305
|
+
* @returns 웹 검색 결과
|
|
306
|
+
*/
|
|
186
307
|
webSearch({ question }: WebSearchParams): Promise<any>;
|
|
187
308
|
}
|
|
188
309
|
export declare class Lens {
|
|
189
310
|
tenantKey: string | undefined;
|
|
190
311
|
baseURL: string;
|
|
191
|
-
role: string | undefined;
|
|
192
|
-
rule: string | undefined;
|
|
193
|
-
outputFormat: any;
|
|
194
|
-
mode: "VECTOR" | "BOTH" | "WEB" | "CUSTOM" | undefined;
|
|
195
|
-
webSearch: WebSearchOption | undefined;
|
|
196
|
-
agentic: AgenticOption | undefined;
|
|
197
|
-
maxHisCount: number | undefined;
|
|
198
|
-
sessionKey: string | undefined;
|
|
199
|
-
numOfRef: number | undefined;
|
|
200
|
-
customSystemPrompt: string | undefined;
|
|
201
|
-
staticInfo: any;
|
|
202
312
|
/**
|
|
203
313
|
* API Client for interfacing with the Lens API.
|
|
204
314
|
*
|
|
205
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
315
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
206
316
|
*/
|
|
207
|
-
constructor({ tenantKey, baseURL
|
|
317
|
+
constructor({ tenantKey, baseURL }: ClientOptions);
|
|
208
318
|
protected requestStream(requestBody: any): Promise<ReadableStream<Uint8Array> | null>;
|
|
209
319
|
protected genStreamResponse(streamRes: ReadableStream): Promise<any>;
|
|
210
|
-
chat({ question,
|
|
320
|
+
chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, }: LensChatParams): Promise<any>;
|
|
211
321
|
history({ sessionKey, limit }: ChatHistoryParams): Promise<any>;
|
|
212
322
|
jsonAutoComplete(jsonString: string): string | null;
|
|
213
323
|
}
|
|
@@ -217,7 +327,7 @@ export declare class AIMS {
|
|
|
217
327
|
/**
|
|
218
328
|
* API Client for interfacing with the Vectocore API.
|
|
219
329
|
*
|
|
220
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
330
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
221
331
|
*/
|
|
222
332
|
constructor({ baseURL, tenantKey }?: ClientOptions);
|
|
223
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,7 @@ export class Vectocore {
|
|
|
104
150
|
}
|
|
105
151
|
/**
|
|
106
152
|
* 특정 인덱스에 저장된 모든 지식 데이터를 조회합니다.
|
|
107
|
-
*
|
|
153
|
+
* @param params - 조회에 필요한 매개변수 객체 ({@link ListAllExtremeDataParams})
|
|
108
154
|
* - **indexName**: string (필수)
|
|
109
155
|
* - withVectorValye: bool (선택) 결과에 벡터값 포함 여부. 기본값 : 'false'
|
|
110
156
|
* @returns 인덱스 목록
|
|
@@ -120,6 +166,13 @@ export class Vectocore {
|
|
|
120
166
|
const response = await this.requestPost(requestParam);
|
|
121
167
|
return response;
|
|
122
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* 특정 문서를 삭제합니다.
|
|
171
|
+
* @param params ({@link DeleteExtremeDataParams})
|
|
172
|
+
* - **indexName**: string (필수) 문서가 저장되어 있는 인덱스의 이름
|
|
173
|
+
* - **documentId**: string (필수) 문서의 ID
|
|
174
|
+
* @returns 삭제 결과
|
|
175
|
+
*/
|
|
123
176
|
async deleteExtremeData({ indexName, documentId }) {
|
|
124
177
|
const requestParam = {
|
|
125
178
|
command: "delete_extreme_data",
|
|
@@ -131,6 +184,19 @@ export class Vectocore {
|
|
|
131
184
|
const response = await this.requestPost(requestParam);
|
|
132
185
|
return response;
|
|
133
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
|
+
*/
|
|
134
200
|
async extremeSearch({ mode, indexNames, question, top, rerank }) {
|
|
135
201
|
const requestParam = {
|
|
136
202
|
command: "extreme_search",
|
|
@@ -145,6 +211,12 @@ export class Vectocore {
|
|
|
145
211
|
const response = await this.requestPost(requestParam);
|
|
146
212
|
return response;
|
|
147
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* 웹검색
|
|
216
|
+
* @param params ({@link WebSearchParams})
|
|
217
|
+
* - **question**: string (필수) 사용자 질문
|
|
218
|
+
* @returns 웹 검색 결과
|
|
219
|
+
*/
|
|
148
220
|
async webSearch({ question }) {
|
|
149
221
|
const requestParam = {
|
|
150
222
|
command: "web_search",
|
|
@@ -159,23 +231,12 @@ export class Vectocore {
|
|
|
159
231
|
export class Lens {
|
|
160
232
|
tenantKey;
|
|
161
233
|
baseURL;
|
|
162
|
-
role;
|
|
163
|
-
rule;
|
|
164
|
-
outputFormat;
|
|
165
|
-
mode;
|
|
166
|
-
webSearch;
|
|
167
|
-
agentic;
|
|
168
|
-
maxHisCount;
|
|
169
|
-
sessionKey;
|
|
170
|
-
numOfRef;
|
|
171
|
-
customSystemPrompt;
|
|
172
|
-
staticInfo;
|
|
173
234
|
/**
|
|
174
235
|
* API Client for interfacing with the Lens API.
|
|
175
236
|
*
|
|
176
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
237
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
177
238
|
*/
|
|
178
|
-
constructor({ tenantKey, baseURL
|
|
239
|
+
constructor({ tenantKey, baseURL }) {
|
|
179
240
|
if (tenantKey === undefined) {
|
|
180
241
|
throw new Error("error tenantKey is undefined");
|
|
181
242
|
}
|
|
@@ -186,17 +247,6 @@ export class Lens {
|
|
|
186
247
|
else {
|
|
187
248
|
this.baseURL = baseURL;
|
|
188
249
|
}
|
|
189
|
-
this.role = role;
|
|
190
|
-
this.rule = rule;
|
|
191
|
-
this.outputFormat = outputFormat;
|
|
192
|
-
this.mode = mode;
|
|
193
|
-
this.maxHisCount = maxHisCount;
|
|
194
|
-
this.sessionKey = sessionKey;
|
|
195
|
-
this.numOfRef = numOfRef;
|
|
196
|
-
this.customSystemPrompt = customSystemPrompt || undefined;
|
|
197
|
-
this.staticInfo = staticInfo || undefined;
|
|
198
|
-
this.webSearch = webSearch;
|
|
199
|
-
this.agentic = agentic;
|
|
200
250
|
}
|
|
201
251
|
async requestStream(requestBody) {
|
|
202
252
|
let header = {
|
|
@@ -224,59 +274,42 @@ export class Lens {
|
|
|
224
274
|
const payload = JSON.parse(content);
|
|
225
275
|
return payload;
|
|
226
276
|
}
|
|
227
|
-
async chat({ question,
|
|
277
|
+
async chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, }) {
|
|
228
278
|
const requestParam = {
|
|
229
|
-
command: "
|
|
230
|
-
|
|
279
|
+
command: "lens_chat",
|
|
280
|
+
params: {
|
|
281
|
+
question: question,
|
|
282
|
+
stream: stream ?? true,
|
|
283
|
+
},
|
|
231
284
|
};
|
|
232
|
-
if (
|
|
233
|
-
requestParam.
|
|
234
|
-
if (
|
|
235
|
-
requestParam.
|
|
236
|
-
if (
|
|
237
|
-
requestParam.
|
|
238
|
-
if (
|
|
239
|
-
requestParam.
|
|
240
|
-
if (this.maxHisCount)
|
|
241
|
-
requestParam.maxHisCount = this.maxHisCount;
|
|
242
|
-
if (this.sessionKey)
|
|
243
|
-
requestParam.sessionKey = this.sessionKey;
|
|
244
|
-
if (this.numOfRef)
|
|
245
|
-
requestParam.numOfRef = this.numOfRef;
|
|
246
|
-
if (this.customSystemPrompt)
|
|
247
|
-
requestParam.customSystemPrompt = this.customSystemPrompt;
|
|
248
|
-
if (this.staticInfo)
|
|
249
|
-
requestParam.staticInfo = this.staticInfo;
|
|
250
|
-
if (this.webSearch)
|
|
251
|
-
requestParam.webSearch = this.webSearch;
|
|
252
|
-
if (this.agentic)
|
|
253
|
-
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;
|
|
254
293
|
if (imageUrls)
|
|
255
|
-
requestParam.imageUrls = imageUrls;
|
|
294
|
+
requestParam.params.imageUrls = imageUrls;
|
|
256
295
|
if (fileUrls)
|
|
257
|
-
requestParam.
|
|
258
|
-
if (
|
|
259
|
-
requestParam.
|
|
260
|
-
if (
|
|
261
|
-
requestParam.
|
|
262
|
-
if (
|
|
263
|
-
requestParam.
|
|
264
|
-
if (
|
|
265
|
-
requestParam.
|
|
266
|
-
if (
|
|
267
|
-
requestParam.
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
requestParam.isFirstMsg = true;
|
|
271
|
-
}
|
|
272
|
-
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;
|
|
273
307
|
let response = await this.requestStream(requestParam);
|
|
274
308
|
if (stream) {
|
|
275
|
-
return response;
|
|
309
|
+
return response.body.getReader();
|
|
276
310
|
}
|
|
277
311
|
else {
|
|
278
|
-
|
|
279
|
-
return res;
|
|
312
|
+
return response.json();
|
|
280
313
|
}
|
|
281
314
|
}
|
|
282
315
|
async history({ sessionKey, limit }) {
|
|
@@ -339,7 +372,7 @@ export class AIMS {
|
|
|
339
372
|
/**
|
|
340
373
|
* API Client for interfacing with the Vectocore API.
|
|
341
374
|
*
|
|
342
|
-
* @param {string | undefined} [opts.tenantKey=process.env['
|
|
375
|
+
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
343
376
|
*/
|
|
344
377
|
constructor({ baseURL, tenantKey } = {}) {
|
|
345
378
|
if (tenantKey === undefined) {
|