doomiaichat 1.1.0 → 1.2.0
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/index.js +8 -4
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,8 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AIChat = void 0;
|
|
13
|
+
const openai_1 = require("openai");
|
|
14
|
+
const events_1 = require("events");
|
|
12
15
|
const SECTION_LENGTH = 256; ///每256个字符分成一组
|
|
13
16
|
const MESSAGE_LENGTH = 8; ///每次送8句话给openai 进行解析,送多了,会报错
|
|
14
17
|
//请将答案放在最后,标记为答案:()
|
|
@@ -19,7 +22,7 @@ const QUESTION_TEXT_MAPPING = {
|
|
|
19
22
|
completion: ',根据以上内容,请生成1道填空题,每道题目1个填空,请按照{"question":"","answer":[]}的JSON结构输出,answer数组中包含填空答案' //请将答案放在最后,标记为答案:()
|
|
20
23
|
};
|
|
21
24
|
const QUESTION_TYPE = ['singlechoice', 'multiplechoice', 'trueorfalse', 'completion'];
|
|
22
|
-
|
|
25
|
+
class AIChat extends events_1.EventEmitter {
|
|
23
26
|
/**
|
|
24
27
|
*
|
|
25
28
|
* @param apiKey 调用OpenAI 的key
|
|
@@ -27,7 +30,7 @@ export class AIChat extends EventEmitter {
|
|
|
27
30
|
*/
|
|
28
31
|
constructor(apiKey, apiOption = {}) {
|
|
29
32
|
super();
|
|
30
|
-
this.chatRobot = new OpenAIApi(new Configuration({ apiKey }));
|
|
33
|
+
this.chatRobot = new openai_1.OpenAIApi(new openai_1.Configuration({ apiKey }));
|
|
31
34
|
this.chatModel = apiOption.model || 'gpt-3.5-turbo';
|
|
32
35
|
this.maxtoken = apiOption.maxtoken || 1024;
|
|
33
36
|
this.temperature = apiOption.temperature || 0.9;
|
|
@@ -311,3 +314,4 @@ export class AIChat extends EventEmitter {
|
|
|
311
314
|
return message;
|
|
312
315
|
}
|
|
313
316
|
}
|
|
317
|
+
exports.AIChat = AIChat;
|
package/package.json
CHANGED