doomiaichat 1.4.1 → 1.4.3
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 +5 -5
- package/package.json +1 -1
- package/src/index.ts +5 -5
package/dist/index.js
CHANGED
|
@@ -46,15 +46,15 @@ class AIChat extends events_1.EventEmitter {
|
|
|
46
46
|
if (!this.chatRobot)
|
|
47
47
|
return { successed: false, error: { errcode: 1, errmsg: '聊天机器人无效' } };
|
|
48
48
|
let message = typeof (chatText) == 'string' ?
|
|
49
|
-
[{ role: '
|
|
49
|
+
[{ role: 'user', content: chatText }] : chatText;
|
|
50
50
|
console.log('message', message);
|
|
51
51
|
try {
|
|
52
52
|
const response = yield this.chatRobot.createChatCompletion({
|
|
53
53
|
model: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.model) || this.chatModel,
|
|
54
54
|
messages: message,
|
|
55
|
-
temperature: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.temperature) || this.temperature,
|
|
56
|
-
max_tokens: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.maxtoken) || this.maxtoken,
|
|
57
|
-
n: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.replyCounts) || 1
|
|
55
|
+
temperature: Number((callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.temperature) || this.temperature),
|
|
56
|
+
max_tokens: Number((callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.maxtoken) || this.maxtoken),
|
|
57
|
+
n: Number((callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.replyCounts) || 1) || 1
|
|
58
58
|
}, axiosOption);
|
|
59
59
|
return { successed: true, message: response.data.choices };
|
|
60
60
|
}
|
|
@@ -128,7 +128,7 @@ class AIChat extends events_1.EventEmitter {
|
|
|
128
128
|
///如果源话是全中文,那么结果中不应该出来英文的相似说法,如果源话是全英文,则结果不能出现全中文的说法
|
|
129
129
|
let prefix = (!chnReg && engReg) ? '请用完整的英文表达,' : ((chnReg && !engReg) ? '请用完整的中文表达,' : '');
|
|
130
130
|
const text = `${prefix}生成与下面句子意思相同的内容"${content}"`;
|
|
131
|
-
let result = yield this.chatRequest(
|
|
131
|
+
let result = yield this.chatRequest(text, { replyCounts: count }, axiosOption);
|
|
132
132
|
if (!result.successed || !result.message)
|
|
133
133
|
return result;
|
|
134
134
|
let replys = result.message.map(item => { return item.message.content.trim(); });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -39,16 +39,16 @@ export class AIChat extends EventEmitter {
|
|
|
39
39
|
if(!this.chatRobot) return {successed: false, error: { errcode: 1, errmsg: '聊天机器人无效' }};
|
|
40
40
|
|
|
41
41
|
let message: Array<ChatCompletionRequestMessage> = typeof(chatText)=='string'?
|
|
42
|
-
[{ role: '
|
|
42
|
+
[{ role: 'user', content: chatText}] : chatText;
|
|
43
43
|
console.log('message', message)
|
|
44
44
|
try {
|
|
45
45
|
const response: AxiosResponse<CreateChatCompletionResponse, any>
|
|
46
46
|
= await this.chatRobot.createChatCompletion({
|
|
47
47
|
model: callChatOption?.model || this.chatModel,
|
|
48
48
|
messages: message,
|
|
49
|
-
temperature: callChatOption?.temperature || this.temperature,
|
|
50
|
-
max_tokens: callChatOption?.maxtoken || this.maxtoken,
|
|
51
|
-
n: callChatOption?.replyCounts || 1
|
|
49
|
+
temperature: Number(callChatOption?.temperature || this.temperature),
|
|
50
|
+
max_tokens: Number(callChatOption?.maxtoken || this.maxtoken),
|
|
51
|
+
n: Number(callChatOption?.replyCounts || 1) || 1
|
|
52
52
|
}, axiosOption);
|
|
53
53
|
return {successed:true,message: response.data.choices};
|
|
54
54
|
} catch (error) {
|
|
@@ -118,7 +118,7 @@ export class AIChat extends EventEmitter {
|
|
|
118
118
|
///如果源话是全中文,那么结果中不应该出来英文的相似说法,如果源话是全英文,则结果不能出现全中文的说法
|
|
119
119
|
let prefix = (!chnReg && engReg) ? '请用完整的英文表达,' : ((chnReg && !engReg) ? '请用完整的中文表达,':'')
|
|
120
120
|
const text = `${prefix}生成与下面句子意思相同的内容"${content}"`
|
|
121
|
-
let result = await this.chatRequest(
|
|
121
|
+
let result = await this.chatRequest(text, { replyCounts: count }, axiosOption);
|
|
122
122
|
if (!result.successed || !result.message) return result;
|
|
123
123
|
let replys = result.message.map(item => { return item.message.content.trim(); })
|
|
124
124
|
return { successed: true, message: replys }
|