doomiaichat 7.1.6 → 7.1.7
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/corzbot.d.ts +1 -1
- package/dist/corzbot.js +9 -4
- package/dist/gptbase.d.ts +5 -0
- package/dist/gptbase.js +18 -0
- package/package.json +1 -1
- package/src/corzbot.ts +11 -7
- package/src/gptbase.ts +10 -1
package/dist/corzbot.d.ts
CHANGED
package/dist/corzbot.js
CHANGED
|
@@ -73,10 +73,15 @@ class CorzBot extends gptbase_1.default {
|
|
|
73
73
|
*/
|
|
74
74
|
createCoversation(client) {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
try {
|
|
77
|
+
const czApi = client !== null && client !== void 0 ? client : yield this.createClient();
|
|
78
|
+
const result = yield czApi.conversations.create({ bot_id: this.botid });
|
|
79
|
+
return result.id;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('createCoversation error in coze api');
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
87
|
/**
|
package/dist/gptbase.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export default abstract class GptBase extends EventEmitter {
|
|
|
18
18
|
* @param axiosOption
|
|
19
19
|
*/
|
|
20
20
|
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption?: any): Promise<ApiResult>;
|
|
21
|
+
/**
|
|
22
|
+
* 创建一个会话主题id
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
createCoversation(_client?: any): Promise<string | null>;
|
|
21
26
|
/**
|
|
22
27
|
* 流式的聊天模式
|
|
23
28
|
* @param chatText
|
package/dist/gptbase.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const events_1 = require("events");
|
|
4
13
|
class GptBase extends events_1.EventEmitter {
|
|
@@ -13,6 +22,15 @@ class GptBase extends events_1.EventEmitter {
|
|
|
13
22
|
* @param text
|
|
14
23
|
*/
|
|
15
24
|
getTextEmbedding(_text, _axiosOption) { return null; }
|
|
25
|
+
/**
|
|
26
|
+
* 创建一个会话主题id
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
createCoversation(_client) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return null;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
16
34
|
/**
|
|
17
35
|
* 流式的聊天模式
|
|
18
36
|
* @param chatText
|
package/package.json
CHANGED
package/src/corzbot.ts
CHANGED
|
@@ -57,11 +57,15 @@ export default class CorzBot extends GptBase {
|
|
|
57
57
|
/**
|
|
58
58
|
* 发起一次会话
|
|
59
59
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
override async createCoversation(client?: CozeAPI):Promise<string|null>{
|
|
61
|
+
try{
|
|
62
|
+
const czApi = client?? await this.createClient();
|
|
63
|
+
const result = await czApi.conversations.create({ bot_id: this.botid})
|
|
64
|
+
return result.id;
|
|
65
|
+
}catch(error){
|
|
66
|
+
console.error('createCoversation error in coze api');
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* 组装请求参数
|
|
@@ -111,7 +115,7 @@ export default class CorzBot extends GptBase {
|
|
|
111
115
|
const client = await this.createClient();
|
|
112
116
|
////如果参数中用的是Workflow,则调用对话流来输出结果
|
|
113
117
|
////否则用智能体的对话来输出结果
|
|
114
|
-
const params =await this.getRequestStream(client,
|
|
118
|
+
const params = await this.getRequestStream(client,message, callChatOption);
|
|
115
119
|
const response = await client.chat.createAndPoll(params as CreateChatReq);
|
|
116
120
|
if (response.chat.status === ChatStatus.COMPLETED && response.messages) {
|
|
117
121
|
const message = response.messages.filter(x=>x.type==='answer').map(item => ({
|
|
@@ -219,7 +223,7 @@ export default class CorzBot extends GptBase {
|
|
|
219
223
|
////如果参数中用的是Workflow,则调用对话流来输出结果
|
|
220
224
|
////否则用智能体的对话来输出结果
|
|
221
225
|
let requestid = Math.ceil(Math.random() * (new Date().getTime() * Math.random()) / 1000), index=0;
|
|
222
|
-
const params =await this.getRequestStream(client,
|
|
226
|
+
const params = await this.getRequestStream(client,message, callChatOption);
|
|
223
227
|
const stream = !callChatOption.workflowid? client.chat.stream(params as StreamChatReq) : client.workflows.chat.stream(params as ChatWorkflowReq);
|
|
224
228
|
let deltaindex = 0, fullanswer: string[] = [], followup: string[] = [];
|
|
225
229
|
let deepThinking = '', thinkingStatus = DeepThinkingStatus.None,cardResource=''; // 是否在深度思考中
|
package/src/gptbase.ts
CHANGED
|
@@ -20,6 +20,14 @@ export default abstract class GptBase extends EventEmitter {
|
|
|
20
20
|
* @param axiosOption
|
|
21
21
|
*/
|
|
22
22
|
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption?: any): Promise<ApiResult>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 创建一个会话主题id
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
async createCoversation(_client?:any):Promise<string|null> {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
23
31
|
/**
|
|
24
32
|
* 流式的聊天模式
|
|
25
33
|
* @param chatText
|
|
@@ -27,4 +35,5 @@ export default abstract class GptBase extends EventEmitter {
|
|
|
27
35
|
* @param axiosOption
|
|
28
36
|
*/
|
|
29
37
|
chatRequestInStream(_chatText: string | Array<any>, _paramOption: any, _attach?: any, _axiosOption?: any): any { return null; }
|
|
30
|
-
}
|
|
38
|
+
}
|
|
39
|
+
|