doomiaichat 1.4.0 → 1.4.1

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.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare class AIChat extends EventEmitter {
16
16
  * 向OpenAI发送一个聊天请求
17
17
  * @param {*} chatText
18
18
  */
19
- chatRequest(chatText: string | Array<any>, callChatOption: CallChatApiOption, axiosOption: AxiosRequestConfig): Promise<ChatReponse>;
19
+ chatRequest(chatText: string | Array<any>, callChatOption: CallChatApiOption, axiosOption?: AxiosRequestConfig): Promise<ChatReponse>;
20
20
  /**
21
21
  * 判断一句话的表达情绪
22
22
  * @param {*} s1
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ class AIChat extends events_1.EventEmitter {
39
39
  * 向OpenAI发送一个聊天请求
40
40
  * @param {*} chatText
41
41
  */
42
- chatRequest(chatText, callChatOption, axiosOption) {
42
+ chatRequest(chatText, callChatOption, axiosOption = {}) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
44
  if (!chatText)
45
45
  return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
@@ -47,6 +47,7 @@ class AIChat extends events_1.EventEmitter {
47
47
  return { successed: false, error: { errcode: 1, errmsg: '聊天机器人无效' } };
48
48
  let message = typeof (chatText) == 'string' ?
49
49
  [{ role: 'system', content: chatText + '' }] : chatText;
50
+ console.log('message', message);
50
51
  try {
51
52
  const response = yield this.chatRobot.createChatCompletion({
52
53
  model: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.model) || this.chatModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doomiaichat",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Doomisoft OpenAI",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -34,12 +34,13 @@ export class AIChat extends EventEmitter {
34
34
  * 向OpenAI发送一个聊天请求
35
35
  * @param {*} chatText
36
36
  */
37
- public async chatRequest(chatText: string | Array<any>, callChatOption: CallChatApiOption, axiosOption: AxiosRequestConfig): Promise<ChatReponse> {
37
+ public async chatRequest(chatText: string | Array<any>, callChatOption: CallChatApiOption, axiosOption: AxiosRequestConfig={}): Promise<ChatReponse> {
38
38
  if (!chatText) return {successed:false, error:{ errcode: 2, errmsg: '缺失聊天的内容' }};
39
39
  if(!this.chatRobot) return {successed: false, error: { errcode: 1, errmsg: '聊天机器人无效' }};
40
40
 
41
41
  let message: Array<ChatCompletionRequestMessage> = typeof(chatText)=='string'?
42
42
  [{ role: 'system', content: chatText + '' }] : chatText;
43
+ console.log('message', message)
43
44
  try {
44
45
  const response: AxiosResponse<CreateChatCompletionResponse, any>
45
46
  = await this.chatRobot.createChatCompletion({