doomiaichat 7.1.18 → 7.1.19
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/corzauthorization.d.ts +1 -1
- package/dist/corzbot.d.ts +1 -1
- package/dist/corzbot.js +19 -7
- package/package.json +1 -1
- package/src/corzauthorization.ts +1 -1
- package/src/corzbot.ts +18 -7
package/dist/corzbot.d.ts
CHANGED
package/dist/corzbot.js
CHANGED
|
@@ -99,11 +99,17 @@ class CorzBot extends gptbase_1.default {
|
|
|
99
99
|
* @param params
|
|
100
100
|
* @returns
|
|
101
101
|
*/
|
|
102
|
-
setVariables(params) {
|
|
102
|
+
setVariables(params = {}) {
|
|
103
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
104
|
const client = yield this.createClient();
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
!params.type && (params.type = 'app');
|
|
106
|
+
const cozeParams = { data: params.data };
|
|
107
|
+
params.type === 'app' && (cozeParams.app_id = this.authorizationProvider.appid);
|
|
108
|
+
params.type === 'bot' && this.botid && (cozeParams.bot_id = this.botid);
|
|
109
|
+
params.user_id && (cozeParams.connector_uid = params.user_id);
|
|
110
|
+
//Object.assign({ connector_uid: params?.user_id||'123456' }, params.type==='app'?{app_id:this.authorizationProvider.appid}:(params.type==='bot' ? { bot_id: this.botid } : {}), params);
|
|
111
|
+
const result = yield client.variables.update(cozeParams, { debug: true });
|
|
112
|
+
console.log('setVariables result', result);
|
|
107
113
|
return { successed: true };
|
|
108
114
|
});
|
|
109
115
|
}
|
|
@@ -207,9 +213,15 @@ class CorzBot extends gptbase_1.default {
|
|
|
207
213
|
////否则用智能体的对话来输出结果
|
|
208
214
|
const params = yield this.getRequestStream(client, message, callChatOption);
|
|
209
215
|
const response = this.botid ? yield client.chat.create(params) : yield client.workflows.runs.create(params);
|
|
210
|
-
if (this.workflowid
|
|
211
|
-
const
|
|
212
|
-
|
|
216
|
+
if (this.workflowid) {
|
|
217
|
+
const workflowResp = response;
|
|
218
|
+
if (workflowResp.msg === 'Success') {
|
|
219
|
+
const resp = workflowResp.data;
|
|
220
|
+
return { successed: true, message: [{ role: 'assistant', type: 'answer', content: resp }] };
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
console.error('workflow run failed', workflowResp.msg, workflowResp);
|
|
224
|
+
}
|
|
213
225
|
// try {
|
|
214
226
|
// return { successed: true, message: [{ role: 'assistant', type: 'answer', content: JSON.parse(resp).data }] };
|
|
215
227
|
// } catch (error) {
|
|
@@ -400,7 +412,7 @@ class CorzBot extends gptbase_1.default {
|
|
|
400
412
|
if (part.event === api_1.ChatEventType.CONVERSATION_CHAT_COMPLETED ||
|
|
401
413
|
part.event === api_1.WorkflowEventType.DONE) {
|
|
402
414
|
const { conversation_id, content } = (_f = (part.data)) !== null && _f !== void 0 ? _f : {};
|
|
403
|
-
let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup, followup, type: 'answer', content_type: 'text', role: api_1.RoleType.Assistant, requestid, segment: null, text: content !== null && content !== void 0 ? content : fullanswer.join(''), index: index++, session_id: conversation_id };
|
|
415
|
+
let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup: cardfollowup.filter(x => typeof x === 'string' && x.length > 0), followup, type: 'answer', content_type: 'text', role: api_1.RoleType.Assistant, requestid, segment: null, text: content !== null && content !== void 0 ? content : fullanswer.join(''), index: index++, session_id: conversation_id };
|
|
404
416
|
if (attach)
|
|
405
417
|
output = Object.assign({}, output, attach);
|
|
406
418
|
this.emit('chatdone', output);
|
package/package.json
CHANGED
package/src/corzauthorization.ts
CHANGED
|
@@ -7,7 +7,7 @@ export class CorzAuthorization {
|
|
|
7
7
|
private pemfile: string;
|
|
8
8
|
private secret: string;
|
|
9
9
|
private sessionName: string;
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(public appid: string,setting:Record<string,any>) {
|
|
11
11
|
this.secret = setting["keyid"];
|
|
12
12
|
this.pemfile = setting["pemfile"] || "private.pem"
|
|
13
13
|
this.sessionName = setting["sessionName"] || "default";
|
package/src/corzbot.ts
CHANGED
|
@@ -94,10 +94,16 @@ export default class CorzBot extends GptBase {
|
|
|
94
94
|
* @param params
|
|
95
95
|
* @returns
|
|
96
96
|
*/
|
|
97
|
-
override async setVariables(params: any): Promise<ApiResult> {
|
|
97
|
+
override async setVariables(params: any = {}): Promise<ApiResult> {
|
|
98
98
|
const client = await this.createClient();
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
!params.type && (params.type='app');
|
|
100
|
+
const cozeParams: VariableUpdateReq = { data: params.data };
|
|
101
|
+
params.type === 'app' && (cozeParams.app_id = this.authorizationProvider.appid);
|
|
102
|
+
params.type === 'bot' && this.botid && (cozeParams.bot_id = this.botid);
|
|
103
|
+
params.user_id && (cozeParams.connector_uid = params.user_id);
|
|
104
|
+
//Object.assign({ connector_uid: params?.user_id||'123456' }, params.type==='app'?{app_id:this.authorizationProvider.appid}:(params.type==='bot' ? { bot_id: this.botid } : {}), params);
|
|
105
|
+
const result = await client.variables.update(cozeParams, { debug : true })
|
|
106
|
+
console.log('setVariables result', result);
|
|
101
107
|
return { successed: true };
|
|
102
108
|
}
|
|
103
109
|
/**
|
|
@@ -189,9 +195,14 @@ export default class CorzBot extends GptBase {
|
|
|
189
195
|
////否则用智能体的对话来输出结果
|
|
190
196
|
const params = await this.getRequestStream(client, message, callChatOption);
|
|
191
197
|
const response = this.botid ? await client.chat.create(params as CreateChatReq) : await client.workflows.runs.create(params as RunWorkflowReq);
|
|
192
|
-
if (this.workflowid
|
|
193
|
-
const
|
|
194
|
-
|
|
198
|
+
if (this.workflowid) {
|
|
199
|
+
const workflowResp = response as RunWorkflowData;
|
|
200
|
+
if (workflowResp.msg === 'Success'){
|
|
201
|
+
const resp = workflowResp.data;
|
|
202
|
+
return { successed: true, message: [{ role: 'assistant', type: 'answer', content: resp }] };
|
|
203
|
+
}else{
|
|
204
|
+
console.error('workflow run failed', workflowResp.msg, workflowResp)
|
|
205
|
+
}
|
|
195
206
|
// try {
|
|
196
207
|
// return { successed: true, message: [{ role: 'assistant', type: 'answer', content: JSON.parse(resp).data }] };
|
|
197
208
|
// } catch (error) {
|
|
@@ -365,7 +376,7 @@ export default class CorzBot extends GptBase {
|
|
|
365
376
|
part.event === WorkflowEventType.DONE
|
|
366
377
|
) {
|
|
367
378
|
const { conversation_id, content } = (part.data) ?? {} as any;
|
|
368
|
-
let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup, followup, type: 'answer', content_type: 'text', role: RoleType.Assistant, requestid, segment: null, text: content ?? fullanswer.join(''), index: index++, session_id: conversation_id };
|
|
379
|
+
let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup: cardfollowup.filter(x=>typeof x === 'string' && x.length > 0), followup, type: 'answer', content_type: 'text', role: RoleType.Assistant, requestid, segment: null, text: content ?? fullanswer.join(''), index: index++, session_id: conversation_id };
|
|
369
380
|
if (attach) output = Object.assign({}, output, attach);
|
|
370
381
|
this.emit('chatdone', output)
|
|
371
382
|
}
|