vectocore4 0.0.27 → 0.0.28
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 +4 -34
- package/dist/index.d.ts +1 -3
- package/dist/mjs/index.js +4 -30
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -283,7 +283,7 @@ class Lens {
|
|
|
283
283
|
this.baseURL = baseURL;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
|
|
286
|
+
request(requestBody) {
|
|
287
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
288
|
let header = {
|
|
289
289
|
"x-tenant-key": this.tenantKey ? this.tenantKey : "",
|
|
@@ -294,23 +294,7 @@ class Lens {
|
|
|
294
294
|
body: JSON.stringify(requestBody),
|
|
295
295
|
};
|
|
296
296
|
const response = yield fetch(this.baseURL, request);
|
|
297
|
-
return response
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
genStreamResponse(streamRes) {
|
|
301
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
-
const reader = streamRes === null || streamRes === void 0 ? void 0 : streamRes.getReader();
|
|
303
|
-
const decoder = new TextDecoder();
|
|
304
|
-
let done = false;
|
|
305
|
-
let content = "";
|
|
306
|
-
while (!done) {
|
|
307
|
-
const { value, done: doneReading } = yield reader.read();
|
|
308
|
-
done = doneReading; // 스트림 완료시 true
|
|
309
|
-
const chunkValue = decoder.decode(value);
|
|
310
|
-
content = content + chunkValue;
|
|
311
|
-
}
|
|
312
|
-
const payload = JSON.parse(content);
|
|
313
|
-
return payload;
|
|
297
|
+
return response;
|
|
314
298
|
});
|
|
315
299
|
}
|
|
316
300
|
chat(_a) {
|
|
@@ -346,29 +330,15 @@ class Lens {
|
|
|
346
330
|
requestParam.params.static_info = staticInfo;
|
|
347
331
|
if (customSystemPrompt)
|
|
348
332
|
requestParam.params.custom_system_prompt = customSystemPrompt;
|
|
349
|
-
let response = yield this.
|
|
333
|
+
let response = yield this.request(requestParam);
|
|
350
334
|
if (stream) {
|
|
351
335
|
return response;
|
|
352
336
|
}
|
|
353
337
|
else {
|
|
354
|
-
|
|
355
|
-
return res;
|
|
338
|
+
return response.json();
|
|
356
339
|
}
|
|
357
340
|
});
|
|
358
341
|
}
|
|
359
|
-
history(_a) {
|
|
360
|
-
return __awaiter(this, arguments, void 0, function* ({ sessionKey, limit }) {
|
|
361
|
-
const requestParam = {
|
|
362
|
-
command: "lensChatHistory",
|
|
363
|
-
sessionKey: sessionKey,
|
|
364
|
-
};
|
|
365
|
-
if (limit)
|
|
366
|
-
requestParam.limit = limit;
|
|
367
|
-
let response = yield this.requestStream(requestParam);
|
|
368
|
-
const res = yield this.genStreamResponse(response);
|
|
369
|
-
return res;
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
342
|
jsonAutoComplete(jsonString) {
|
|
373
343
|
const dataCloseChar = {
|
|
374
344
|
"{": "}",
|
package/dist/index.d.ts
CHANGED
|
@@ -324,10 +324,8 @@ export declare class Lens {
|
|
|
324
324
|
* @param {string | undefined} [opts.tenantKey=process.env['VECTOCORE4_TENANT_KEY'] ?? undefined]
|
|
325
325
|
*/
|
|
326
326
|
constructor({ tenantKey, baseURL }: ClientOptions);
|
|
327
|
-
protected
|
|
328
|
-
protected genStreamResponse(streamRes: ReadableStream): Promise<any>;
|
|
327
|
+
protected request(requestBody: any): Promise<Response>;
|
|
329
328
|
chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, customSystemPrompt, }: LensChatParams): Promise<any>;
|
|
330
|
-
history({ sessionKey, limit }: ChatHistoryParams): Promise<any>;
|
|
331
329
|
jsonAutoComplete(jsonString: string): string | null;
|
|
332
330
|
}
|
|
333
331
|
export declare class AIMS {
|
package/dist/mjs/index.js
CHANGED
|
@@ -248,7 +248,7 @@ export class Lens {
|
|
|
248
248
|
this.baseURL = baseURL;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
async
|
|
251
|
+
async request(requestBody) {
|
|
252
252
|
let header = {
|
|
253
253
|
"x-tenant-key": this.tenantKey ? this.tenantKey : "",
|
|
254
254
|
};
|
|
@@ -258,21 +258,7 @@ export class Lens {
|
|
|
258
258
|
body: JSON.stringify(requestBody),
|
|
259
259
|
};
|
|
260
260
|
const response = await fetch(this.baseURL, request);
|
|
261
|
-
return response
|
|
262
|
-
}
|
|
263
|
-
async genStreamResponse(streamRes) {
|
|
264
|
-
const reader = streamRes?.getReader();
|
|
265
|
-
const decoder = new TextDecoder();
|
|
266
|
-
let done = false;
|
|
267
|
-
let content = "";
|
|
268
|
-
while (!done) {
|
|
269
|
-
const { value, done: doneReading } = await reader.read();
|
|
270
|
-
done = doneReading; // 스트림 완료시 true
|
|
271
|
-
const chunkValue = decoder.decode(value);
|
|
272
|
-
content = content + chunkValue;
|
|
273
|
-
}
|
|
274
|
-
const payload = JSON.parse(content);
|
|
275
|
-
return payload;
|
|
261
|
+
return response;
|
|
276
262
|
}
|
|
277
263
|
async chat({ question, stream, model, xfinder, webSearch, agentic, imageUrls, fileUrls, customContext, sessionKey, maxHisCount, withStatus, staticInfo, customSystemPrompt, }) {
|
|
278
264
|
const requestParam = {
|
|
@@ -306,26 +292,14 @@ export class Lens {
|
|
|
306
292
|
requestParam.params.static_info = staticInfo;
|
|
307
293
|
if (customSystemPrompt)
|
|
308
294
|
requestParam.params.custom_system_prompt = customSystemPrompt;
|
|
309
|
-
let response = await this.
|
|
295
|
+
let response = await this.request(requestParam);
|
|
310
296
|
if (stream) {
|
|
311
297
|
return response;
|
|
312
298
|
}
|
|
313
299
|
else {
|
|
314
|
-
|
|
315
|
-
return res;
|
|
300
|
+
return response.json();
|
|
316
301
|
}
|
|
317
302
|
}
|
|
318
|
-
async history({ sessionKey, limit }) {
|
|
319
|
-
const requestParam = {
|
|
320
|
-
command: "lensChatHistory",
|
|
321
|
-
sessionKey: sessionKey,
|
|
322
|
-
};
|
|
323
|
-
if (limit)
|
|
324
|
-
requestParam.limit = limit;
|
|
325
|
-
let response = await this.requestStream(requestParam);
|
|
326
|
-
const res = await this.genStreamResponse(response);
|
|
327
|
-
return res;
|
|
328
|
-
}
|
|
329
303
|
jsonAutoComplete(jsonString) {
|
|
330
304
|
const dataCloseChar = {
|
|
331
305
|
"{": "}",
|