pcm-agents 0.3.0 → 0.3.2

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.
Files changed (146) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/index-BFPEnLbS.js +195 -0
  3. package/dist/cjs/index-BFPEnLbS.js.map +1 -0
  4. package/dist/cjs/index.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/my-component.cjs.entry.js +2 -2
  7. package/dist/cjs/my-component.cjs.entry.js.map +1 -1
  8. package/dist/cjs/my-component.entry.cjs.js.map +1 -1
  9. package/dist/cjs/pcm-agents.cjs.js +1 -1
  10. package/dist/cjs/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.cjs.js.map +1 -0
  11. package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js +6560 -0
  12. package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js.map +1 -0
  13. package/dist/cjs/pcm-chat-modal.cjs.entry.js +17 -32
  14. package/dist/cjs/pcm-chat-modal.cjs.entry.js.map +1 -1
  15. package/dist/cjs/pcm-chat-modal.entry.cjs.js.map +1 -1
  16. package/dist/collection/collection-manifest.json +2 -0
  17. package/dist/collection/components/my-component/my-component.css +3 -3
  18. package/dist/collection/components/my-component/my-component.js +1 -1
  19. package/dist/collection/components/my-component/my-component.js.map +1 -1
  20. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.css +2 -1
  21. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js +137 -159
  22. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js.map +1 -1
  23. package/dist/collection/components/pcm-chat-message/pcm-chat-message.css +66 -12
  24. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js +106 -13
  25. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js.map +1 -1
  26. package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js +39 -34
  27. package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js.map +1 -1
  28. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js +76 -105
  29. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js.map +1 -1
  30. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.css +162 -0
  31. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js +616 -0
  32. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js.map +1 -0
  33. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.css +0 -79
  34. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js +133 -81
  35. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js.map +1 -1
  36. package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js +77 -101
  37. package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js.map +1 -1
  38. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.css +273 -0
  39. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js +613 -0
  40. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js.map +1 -0
  41. package/dist/collection/global/global.css +324 -0
  42. package/dist/collection/index.js.map +1 -1
  43. package/dist/collection/interfaces/chat.js.map +1 -1
  44. package/dist/collection/utils/utils.js +54 -113
  45. package/dist/collection/utils/utils.js.map +1 -1
  46. package/dist/components/index.js +1298 -11280
  47. package/dist/components/index.js.map +1 -1
  48. package/dist/components/my-component.js +2 -3
  49. package/dist/components/my-component.js.map +1 -1
  50. package/dist/components/{p-C4l_DOnx.js → p-BctfuDvG.js} +106 -147
  51. package/dist/components/p-BctfuDvG.js.map +1 -0
  52. package/dist/components/{p-D0s1Q-3O.js → p-LkDC0SN2.js} +343 -16
  53. package/dist/components/p-LkDC0SN2.js.map +1 -0
  54. package/dist/components/pcm-app-chat-modal.js +1 -1
  55. package/dist/components/pcm-chat-message.js +1 -1
  56. package/dist/components/pcm-chat-modal.js +19 -34
  57. package/dist/components/pcm-chat-modal.js.map +1 -1
  58. package/dist/components/pcm-hr-chat-modal.js +70 -100
  59. package/dist/components/pcm-hr-chat-modal.js.map +1 -1
  60. package/dist/components/pcm-jlpx-modal.d.ts +11 -0
  61. package/dist/components/pcm-jlpx-modal.js +339 -0
  62. package/dist/components/pcm-jlpx-modal.js.map +1 -0
  63. package/dist/components/pcm-mnms-modal.js +109 -57
  64. package/dist/components/pcm-mnms-modal.js.map +1 -1
  65. package/dist/components/pcm-video-chat-modal.js +74 -99
  66. package/dist/components/pcm-video-chat-modal.js.map +1 -1
  67. package/dist/components/pcm-zygh-modal.d.ts +11 -0
  68. package/dist/components/pcm-zygh-modal.js +330 -0
  69. package/dist/components/pcm-zygh-modal.js.map +1 -0
  70. package/dist/esm/index-nVjZGfA8.js +189 -0
  71. package/dist/esm/index-nVjZGfA8.js.map +1 -0
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/loader.js +1 -1
  74. package/dist/esm/my-component.entry.js +2 -2
  75. package/dist/esm/my-component.entry.js.map +1 -1
  76. package/dist/esm/pcm-agents.js +1 -1
  77. package/dist/esm/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.js.map +1 -0
  78. package/dist/esm/pcm-app-chat-modal_7.entry.js +6552 -0
  79. package/dist/esm/pcm-app-chat-modal_7.entry.js.map +1 -0
  80. package/dist/esm/pcm-chat-modal.entry.js +17 -32
  81. package/dist/esm/pcm-chat-modal.entry.js.map +1 -1
  82. package/dist/pcm-agents/index.esm.js +1 -1
  83. package/dist/pcm-agents/my-component.entry.esm.js.map +1 -1
  84. package/dist/pcm-agents/p-55417392.entry.js +2 -0
  85. package/dist/pcm-agents/p-55417392.entry.js.map +1 -0
  86. package/dist/pcm-agents/p-a698b59f.entry.js +2 -0
  87. package/dist/pcm-agents/p-a698b59f.entry.js.map +1 -0
  88. package/dist/pcm-agents/p-f3ca99b4.entry.js +2 -0
  89. package/dist/pcm-agents/p-f3ca99b4.entry.js.map +1 -0
  90. package/dist/pcm-agents/p-nVjZGfA8.js +2 -0
  91. package/dist/pcm-agents/p-nVjZGfA8.js.map +1 -0
  92. package/dist/pcm-agents/pcm-agents.esm.js +1 -1
  93. package/dist/pcm-agents/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.esm.js.map +1 -0
  94. package/dist/pcm-agents/pcm-chat-modal.entry.esm.js.map +1 -1
  95. package/dist/types/components/pcm-app-chat-modal/pcm-app-chat-modal.d.ts +13 -8
  96. package/dist/types/components/pcm-chat-message/pcm-chat-message.d.ts +5 -0
  97. package/dist/types/components/pcm-chat-modal/pcm-chat-modal.d.ts +8 -8
  98. package/dist/types/components/pcm-hr-chat-modal/pcm-hr-chat-modal.d.ts +6 -12
  99. package/dist/types/components/pcm-jlpx-modal/pcm-jlpx-modal.d.ts +113 -0
  100. package/dist/types/components/pcm-mnms-modal/pcm-mnms-modal.d.ts +19 -20
  101. package/dist/types/components/pcm-video-chat-modal/pcm-video-chat-modal.d.ts +4 -4
  102. package/dist/types/components/pcm-zygh-modal/pcm-zygh-modal.d.ts +117 -0
  103. package/dist/types/components.d.ts +429 -80
  104. package/dist/types/interfaces/chat.d.ts +0 -4
  105. package/dist/types/utils/utils.d.ts +29 -83
  106. package/package.json +61 -60
  107. package/readme.md +307 -307
  108. package/dist/cjs/index-DfIUl99H.js +0 -11413
  109. package/dist/cjs/index-DfIUl99H.js.map +0 -1
  110. package/dist/cjs/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.cjs.js.map +0 -1
  111. package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js +0 -3734
  112. package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js.map +0 -1
  113. package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js +0 -1078
  114. package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js.map +0 -1
  115. package/dist/cjs/pcm-hr-chat-modal.entry.cjs.js.map +0 -1
  116. package/dist/cjs/pcm-video-chat-modal.cjs.entry.js +0 -927
  117. package/dist/cjs/pcm-video-chat-modal.cjs.entry.js.map +0 -1
  118. package/dist/cjs/pcm-video-chat-modal.entry.cjs.js.map +0 -1
  119. package/dist/components/p-C4l_DOnx.js.map +0 -1
  120. package/dist/components/p-CgDy4pJp.js +0 -1244
  121. package/dist/components/p-CgDy4pJp.js.map +0 -1
  122. package/dist/components/p-D0s1Q-3O.js.map +0 -1
  123. package/dist/esm/index-B2EtEi7v.js +0 -11409
  124. package/dist/esm/index-B2EtEi7v.js.map +0 -1
  125. package/dist/esm/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.js.map +0 -1
  126. package/dist/esm/pcm-app-chat-modal_3.entry.js +0 -3730
  127. package/dist/esm/pcm-app-chat-modal_3.entry.js.map +0 -1
  128. package/dist/esm/pcm-hr-chat-modal.entry.js +0 -1076
  129. package/dist/esm/pcm-hr-chat-modal.entry.js.map +0 -1
  130. package/dist/esm/pcm-video-chat-modal.entry.js +0 -925
  131. package/dist/esm/pcm-video-chat-modal.entry.js.map +0 -1
  132. package/dist/pcm-agents/p-0ddd5c47.entry.js +0 -2
  133. package/dist/pcm-agents/p-0ddd5c47.entry.js.map +0 -1
  134. package/dist/pcm-agents/p-5f624943.entry.js +0 -2
  135. package/dist/pcm-agents/p-5f624943.entry.js.map +0 -1
  136. package/dist/pcm-agents/p-6c07f155.entry.js +0 -2
  137. package/dist/pcm-agents/p-6c07f155.entry.js.map +0 -1
  138. package/dist/pcm-agents/p-9a1fb6ca.entry.js +0 -2
  139. package/dist/pcm-agents/p-9a1fb6ca.entry.js.map +0 -1
  140. package/dist/pcm-agents/p-B2EtEi7v.js +0 -146
  141. package/dist/pcm-agents/p-B2EtEi7v.js.map +0 -1
  142. package/dist/pcm-agents/p-e21bc169.entry.js +0 -2
  143. package/dist/pcm-agents/p-e21bc169.entry.js.map +0 -1
  144. package/dist/pcm-agents/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.esm.js.map +0 -1
  145. package/dist/pcm-agents/pcm-hr-chat-modal.entry.esm.js.map +0 -1
  146. package/dist/pcm-agents/pcm-video-chat-modal.entry.esm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"my-component.js","sourceRoot":"","sources":["../../../src/components/my-component/my-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAO3C,MAAM,OAAO,WAAW;IACtB;;OAEG;IACK,KAAK,CAAS;IAEtB;;OAEG;IACK,MAAM,CAAS;IAEvB;;OAEG;IACK,IAAI,CAAS;IAEb,OAAO;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,MAAM;QACJ,OAAO;;YAAwB,IAAI,CAAC,OAAO,EAAE,CAAO,CAAC;IACvD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport { format } from '../../utils/utils';\n\n@Component({\n tag: 'my-component',\n styleUrl: 'my-component.css',\n shadow: true,\n})\nexport class MyComponent {\n /**\n * The first name\n */\n @Prop() first: string;\n\n /**\n * The middle name\n */\n @Prop() middle: string;\n\n /**\n * The last name\n */\n @Prop() last: string;\n\n private getText(): string {\n return format(this.first, this.middle, this.last);\n }\n\n render() {\n return <div>Hello, World! I'm {this.getText()}</div>;\n }\n}\n"]}
1
+ {"version":3,"file":"my-component.js","sourceRoot":"","sources":["../../../src/components/my-component/my-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAO3C,MAAM,OAAO,WAAW;IACtB;;OAEG;IACK,KAAK,CAAS;IAEtB;;OAEG;IACK,MAAM,CAAS;IAEvB;;OAEG;IACK,IAAI,CAAS;IAEb,OAAO;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,MAAM;QACJ,OAAO;;YAAwB,IAAI,CAAC,OAAO,EAAE,CAAO,CAAC;IACvD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\r\nimport { format } from '../../utils/utils';\r\n\r\n@Component({\r\n tag: 'my-component',\r\n styleUrl: 'my-component.css',\r\n shadow: true,\r\n})\r\nexport class MyComponent {\r\n /**\r\n * The first name\r\n */\r\n @Prop() first: string;\r\n\r\n /**\r\n * The middle name\r\n */\r\n @Prop() middle: string;\r\n\r\n /**\r\n * The last name\r\n */\r\n @Prop() last: string;\r\n\r\n private getText(): string {\r\n return format(this.first, this.middle, this.last);\r\n }\r\n\r\n render() {\r\n return <div>Hello, World! I'm {this.getText()}</div>;\r\n }\r\n}\r\n"]}
@@ -184,7 +184,7 @@
184
184
  overflow-y: auto;
185
185
  padding: 20px;
186
186
  scroll-behavior: smooth;
187
- min-height: 400px;
187
+ height: 400px;
188
188
  background: url(https://pcm-resource-1312611446.cos.ap-guangzhou.myqcloud.com/web/sdk/chat_bg.png);
189
189
  background-size: 100%;
190
190
  }
@@ -768,6 +768,7 @@
768
768
 
769
769
  .chat-history {
770
770
  min-height: 200px;
771
+ max-height: 350px;
771
772
  }
772
773
  }
773
774
 
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
- import { convertWorkflowStreamNodeToMessageRound, sendSSERequest, sendHttpRequest } from "../../utils/utils";
2
+ import { convertWorkflowStreamNodeToMessageRound, sendSSERequest, sendHttpRequest, uploadFileToBackend, API_DOMAIN } from "../../utils/utils";
3
3
  export class ChatAPPModal {
4
4
  /**
5
5
  * 模态框标题
@@ -8,7 +8,7 @@ export class ChatAPPModal {
8
8
  /**
9
9
  * API鉴权密钥
10
10
  */
11
- apiKey = '';
11
+ token = '';
12
12
  /**
13
13
  * 是否显示聊天模态框
14
14
  */
@@ -38,7 +38,7 @@ export class ChatAPPModal {
38
38
  */
39
39
  isNeedClose = true;
40
40
  /**
41
- * 会话ID
41
+ * 会话ID,传入继续对话,否则创建新会话
42
42
  */
43
43
  conversationId;
44
44
  /**
@@ -114,7 +114,7 @@ export class ChatAPPModal {
114
114
  countdownWarningTime = 30;
115
115
  showCountdownWarning = false;
116
116
  /**
117
- * 是否以全屏模式打开
117
+ * 是否以全屏模式打开,移动端建议设置为true
118
118
  */
119
119
  fullscreen = false;
120
120
  // 添加新的状态来跟踪视频上传
@@ -131,20 +131,22 @@ export class ChatAPPModal {
131
131
  * 录制状态变化事件
132
132
  */
133
133
  recordingStatusChange;
134
+ /**
135
+ * 是否启用语音播报功能
136
+ * true: 启用语音合成
137
+ * false: 禁用语音合成
138
+ */
139
+ enableTTS = false;
134
140
  /**
135
141
  * 是否自动播放语音问题
136
142
  */
137
- enableVoice = true;
143
+ enableVoice = false;
138
144
  /**
139
145
  * 是否显示题干内容
140
146
  * 1: 显示题干内容
141
147
  * 0: 不显示题干内容
142
148
  */
143
149
  displayContentStatus = "1";
144
- /**
145
- * 用户ID
146
- */
147
- userId = '';
148
150
  /**
149
151
  * 面试模式
150
152
  * video: 视频面试模式
@@ -158,6 +160,10 @@ export class ChatAPPModal {
158
160
  * 自定义智能体inputs输入参数
159
161
  */
160
162
  customInputs = {};
163
+ /**
164
+ * 机器人ID
165
+ */
166
+ botId;
161
167
  handleClose = () => {
162
168
  this.stopRecording();
163
169
  this.modalClosed.emit();
@@ -180,7 +186,7 @@ export class ChatAPPModal {
180
186
  answer: '',
181
187
  isStreaming: true, // 是否正在流式输出
182
188
  conversation_id: this.conversationId, // 会话ID
183
- inputs: {}, // 输入参数
189
+ inputs: this.customInputs, // 输入参数
184
190
  status: "normal", // 消息状态
185
191
  error: null // 错误信息
186
192
  };
@@ -206,7 +212,7 @@ export class ChatAPPModal {
206
212
  response_mode: 'streaming',
207
213
  conversation_id: this.conversationId,
208
214
  query: queryText,
209
- user: this.userId // 使用传入的 userId
215
+ bot_id: this.botId // 添加 botId 到请求数据中
210
216
  };
211
217
  // 合并基本输入参数和自定义输入参数
212
218
  requestData.inputs = {
@@ -218,10 +224,10 @@ export class ChatAPPModal {
218
224
  requestData.inputs.video_url = videoUrl;
219
225
  }
220
226
  await sendSSERequest({
221
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/chat-messages`,
227
+ url: `/sdk/v1/chat/chat-messages`,
222
228
  method: 'POST',
223
229
  headers: {
224
- 'authorization': 'Bearer ' + this.apiKey
230
+ 'authorization': 'Bearer ' + this.token
225
231
  },
226
232
  data: requestData,
227
233
  onMessage: (data) => {
@@ -291,19 +297,26 @@ export class ChatAPPModal {
291
297
  if (latestAIMessage && latestAIMessage.answer) {
292
298
  // 优先使用 LLMText,如果没有则使用 answer
293
299
  const textForSynthesis = llmText || latestAIMessage.answer;
294
- if (textForSynthesis) {
300
+ if (textForSynthesis && this.enableTTS) {
295
301
  // 合成语音
296
302
  const audioUrl = await this.synthesizeAudio(textForSynthesis);
297
303
  if (this.enableVoice) {
298
304
  // 自动播放语音
299
305
  await this.playAudio(audioUrl);
300
- // 自动播放模式下,播放完成后立即开始等待录制
301
- this.startWaitingToRecord();
306
+ // 自动播放模式下,只在视频模式时开始等待录制
307
+ if (this.interviewMode === 'video') {
308
+ this.startWaitingToRecord();
309
+ }
302
310
  }
303
311
  else {
304
312
  // 只保存音频URL,不自动播放
305
313
  this.audioUrl = audioUrl;
306
- // 非自动播放模式下,不立即开始等待录制
314
+ }
315
+ }
316
+ else {
317
+ // 如果禁用了语音合成,只在视频模式时开始等待录制
318
+ if (this.interviewMode === 'video') {
319
+ this.startWaitingToRecord();
307
320
  }
308
321
  }
309
322
  }
@@ -345,57 +358,46 @@ export class ChatAPPModal {
345
358
  this.isLoadingHistory = true;
346
359
  console.log('加载历史消息...');
347
360
  try {
348
- await sendHttpRequest({
349
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/messages`,
361
+ const result = await sendHttpRequest({
362
+ url: '/sdk/v1/chat/messages',
350
363
  method: 'GET',
351
364
  headers: {
352
- 'authorization': 'Bearer ' + this.apiKey
365
+ 'authorization': 'Bearer ' + this.token
353
366
  },
354
367
  data: {
355
368
  conversation_id: this.conversationId,
369
+ bot_id: this.botId,
356
370
  limit: 20
357
- },
358
- onMessage: (data) => {
359
- if (data.data) {
360
- const historyData = data.data || [];
361
- const formattedMessages = historyData.map(msg => {
362
- const time = new Date(msg.created_at * 1000);
363
- const hours = time.getHours().toString().padStart(2, '0');
364
- const minutes = time.getMinutes().toString().padStart(2, '0');
365
- const timeStr = `${hours}:${minutes}`;
366
- // 创建新的消息对象,不包含 inputs 字段
367
- const { inputs, ...msgWithoutInputs } = msg;
368
- return {
369
- ...msgWithoutInputs,
370
- time: timeStr,
371
- isStreaming: false,
372
- status: msg.status === 'error' ? 'error' : 'normal'
373
- };
374
- });
375
- this.messages = formattedMessages;
376
- this.isLoadingHistory = false;
377
- requestAnimationFrame(() => {
378
- this.shouldAutoScroll = true;
379
- this.scrollToBottom();
380
- });
381
- }
382
- else {
383
- this.isLoadingHistory = false;
384
- }
385
- },
386
- onError: (error) => {
387
- console.error('加载历史消息失败:', error);
388
- alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
389
- this.isLoadingHistory = false;
390
- },
391
- onComplete: () => {
392
- this.isLoadingHistory = false;
393
371
  }
394
372
  });
373
+ if (result.success && result.data) {
374
+ const historyData = result.data.data || [];
375
+ const formattedMessages = historyData.map(msg => {
376
+ const time = new Date(msg.created_at * 1000);
377
+ const hours = time.getHours().toString().padStart(2, '0');
378
+ const minutes = time.getMinutes().toString().padStart(2, '0');
379
+ const timeStr = `${hours}:${minutes}`;
380
+ // 创建新的消息对象,不包含 inputs 字段
381
+ const { inputs, ...msgWithoutInputs } = msg;
382
+ return {
383
+ ...msgWithoutInputs,
384
+ time: timeStr,
385
+ isStreaming: false,
386
+ status: msg.status === 'error' ? 'error' : 'normal'
387
+ };
388
+ });
389
+ this.messages = formattedMessages;
390
+ requestAnimationFrame(() => {
391
+ this.shouldAutoScroll = true;
392
+ this.scrollToBottom();
393
+ });
394
+ }
395
395
  }
396
396
  catch (error) {
397
397
  console.error('加载历史消息失败:', error);
398
398
  alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
399
+ }
400
+ finally {
399
401
  this.isLoadingHistory = false;
400
402
  }
401
403
  }
@@ -423,6 +425,10 @@ export class ChatAPPModal {
423
425
  }
424
426
  // 开始等待录制
425
427
  startWaitingToRecord() {
428
+ // 如果不是视频模式,直接返回
429
+ if (this.interviewMode !== 'video') {
430
+ return;
431
+ }
426
432
  // 清除可能存在的计时器
427
433
  if (this.waitingTimer) {
428
434
  clearInterval(this.waitingTimer);
@@ -678,34 +684,23 @@ export class ChatAPPModal {
678
684
  // 修改音频转文字方法
679
685
  async convertAudioToText(cosKey) {
680
686
  try {
681
- // 创建一个Promise来处理响应
682
- return new Promise((resolve, reject) => {
683
- sendHttpRequest({
684
- url: `https://pcm_api.ylzhaopin.com/external/v1/tts/audio_to_text`,
685
- method: 'POST',
686
- headers: {
687
- 'Content-Type': 'application/json',
688
- 'authorization': 'Bearer ' + this.apiKey
689
- },
690
- data: {
691
- cos_key: cosKey
692
- },
693
- onMessage: (data) => {
694
- // 检查返回结果中是否包含转换后的文本
695
- if (data && data.text) {
696
- resolve(data.text);
697
- }
698
- else {
699
- console.warn('音频转文字返回结果格式不正确');
700
- resolve(null);
701
- }
702
- },
703
- onError: (error) => {
704
- console.error('音频转文字请求失败:', error);
705
- reject(error);
706
- }
707
- });
687
+ const result = await sendHttpRequest({
688
+ url: '/sdk/v1/tts/audio_to_text',
689
+ method: 'POST',
690
+ headers: {
691
+ 'authorization': 'Bearer ' + this.token
692
+ },
693
+ data: {
694
+ cos_key: cosKey
695
+ }
708
696
  });
697
+ if (result.success && result.data && result.data.text) {
698
+ return result.data.text;
699
+ }
700
+ else {
701
+ console.warn('音频转文字返回结果格式不正确');
702
+ return null;
703
+ }
709
704
  }
710
705
  catch (error) {
711
706
  console.error('音频转文字错误:', error);
@@ -722,27 +717,16 @@ export class ChatAPPModal {
722
717
  // 根据Blob类型确定文件扩展名
723
718
  const fileExtension = this.recordedBlob.type.includes('webm') ? 'webm' : 'mp4';
724
719
  const fileName = `answer.${fileExtension}`;
725
- const formData = new FormData();
726
- formData.append('file', this.recordedBlob, fileName);
727
- const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/files/upload', {
728
- method: 'POST',
729
- headers: {
730
- 'authorization': 'Bearer ' + this.apiKey
731
- },
732
- body: formData
720
+ // 创建File对象
721
+ const file = new File([this.recordedBlob], fileName, { type: this.recordedBlob.type });
722
+ // 使用uploadFileToBackend上传文件
723
+ const fileInfo = await uploadFileToBackend(file, {
724
+ 'authorization': 'Bearer ' + this.token
733
725
  });
734
- const result = await response.json();
735
- if (result && result.cos_key) {
736
- // 调用音频转文字API
737
- const transcriptionText = await this.convertAudioToText(result.cos_key);
738
- // 保存视频答案
739
- await this.saveVideoAnswer(result.cos_key);
740
- // 发送"下一题"请求,可以附带转录文本
741
- this.sendMessageToAPI(transcriptionText || "下一题");
742
- }
743
- else {
744
- throw new Error('视频上传失败');
745
- }
726
+ // 调用音频转文字API
727
+ const transcriptionText = await this.convertAudioToText(fileInfo.cos_key);
728
+ // 发送"下一题"请求,可以附带转录文本
729
+ this.sendMessageToAPI(transcriptionText || "下一题");
746
730
  }
747
731
  catch (error) {
748
732
  console.error('视频上传或处理错误:', error);
@@ -759,32 +743,6 @@ export class ChatAPPModal {
759
743
  this.recordedBlob = null;
760
744
  }
761
745
  }
762
- // 保存视频答案
763
- async saveVideoAnswer(cosKey) {
764
- if (!this.conversationId)
765
- return;
766
- try {
767
- const lastAIMessage = this.messages.length > 0 ? this.messages[this.messages.length - 1] : null;
768
- if (!lastAIMessage)
769
- return;
770
- await sendHttpRequest({
771
- url: 'https://pcm_api.ylzhaopin.com/agents/hr_competition/answer',
772
- method: 'POST',
773
- headers: {
774
- 'authorization': 'Bearer ' + this.apiKey
775
- },
776
- data: {
777
- conversation_id: this.conversationId,
778
- user: this.userId, // 使用传入的 userId
779
- question: lastAIMessage.answer,
780
- file_url: cosKey
781
- },
782
- });
783
- }
784
- catch (error) {
785
- console.error('保存视频答案失败:', error);
786
- }
787
- }
788
746
  /**
789
747
  * 发送面试完成请求
790
748
  */
@@ -796,20 +754,19 @@ export class ChatAPPModal {
796
754
  response_mode: 'streaming',
797
755
  conversation_id: this.conversationId,
798
756
  query: "面试完成",
799
- user: this.userId,
800
757
  inputs: {
801
758
  // 合并自定义输入参数
802
759
  ...this.customInputs
803
760
  }
804
761
  };
805
- // 不使用 await,直接发送请求
806
- sendSSERequest({
807
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/chat-messages`,
762
+ // 使用sendHttpRequest发送请求
763
+ sendHttpRequest({
764
+ url: '/sdk/v1/chat/chat-messages',
808
765
  method: 'POST',
809
766
  headers: {
810
- 'authorization': 'Bearer ' + this.apiKey
767
+ 'authorization': 'Bearer ' + this.token
811
768
  },
812
- data: requestData,
769
+ data: requestData
813
770
  }).catch(error => {
814
771
  console.error('发送面试完成请求失败:', error);
815
772
  });
@@ -821,11 +778,11 @@ export class ChatAPPModal {
821
778
  // 添加TTS合成音频的方法
822
779
  async synthesizeAudio(text) {
823
780
  try {
824
- const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/tts/synthesize_audio', {
781
+ const response = await fetch(`${API_DOMAIN}/sdk/v1/tts/synthesize_audio`, {
825
782
  method: 'POST',
826
783
  headers: {
827
784
  'Content-Type': 'application/json',
828
- 'authorization': 'Bearer ' + this.apiKey
785
+ 'authorization': 'Bearer ' + this.token
829
786
  },
830
787
  body: JSON.stringify({ text })
831
788
  });
@@ -904,8 +861,10 @@ export class ChatAPPModal {
904
861
  handlePlayAudio = async () => {
905
862
  if (this.audioUrl) {
906
863
  await this.playAudio(this.audioUrl);
907
- // 手动播放完成后开始等待录制
908
- this.startWaitingToRecord();
864
+ // 手动播放完成后只在视频模式时开始等待录制
865
+ if (this.interviewMode === 'video') {
866
+ this.startWaitingToRecord();
867
+ }
909
868
  }
910
869
  };
911
870
  // 处理文本输入变化
@@ -999,7 +958,7 @@ export class ChatAPPModal {
999
958
  return (h("div", { class: "placeholder-status default-status" }, h("p", null, "\u51C6\u5907\u4E2D...")));
1000
959
  };
1001
960
  // 修改文本输入区域渲染函数
1002
- const renderTextInputArea = () => (h("div", { class: "text-input-area" }, h("textarea", { class: "text-answer-input", placeholder: "\u8BF7\u8F93\u5165\u60A8\u7684\u56DE\u7B54...(\u6309\u56DE\u8F66\u53D1\u9001\uFF0CCtrl+\u56DE\u8F66\u6362\u884C)", value: this.textAnswer, onInput: this.handleTextInputChange, onKeyDown: this.handleKeyDown, disabled: this.isSubmittingText || this.isLoading || !!this.currentStreamingMessage || this.waitingToRecord || this.isPlayingAudio }), h("div", { class: "input-toolbar" }, h("div", { class: "toolbar-actions" }), h("button", { class: {
961
+ const renderTextInputArea = () => (h("div", { class: "text-input-area" }, h("textarea", { class: "text-answer-input", placeholder: "\u8BF7\u8F93\u5165...(\u6309\u56DE\u8F66\u53D1\u9001\uFF0CCtrl+\u56DE\u8F66\u6362\u884C)", value: this.textAnswer, onInput: this.handleTextInputChange, onKeyDown: this.handleKeyDown, disabled: this.isSubmittingText || this.isLoading || !!this.currentStreamingMessage || this.waitingToRecord || this.isPlayingAudio }), h("div", { class: "input-toolbar" }, h("div", { class: "toolbar-actions" }), h("button", { class: {
1003
962
  'submit-text-button': true,
1004
963
  'disabled': !this.textAnswer.trim() || this.isSubmittingText || this.isLoading || !!this.currentStreamingMessage || this.waitingToRecord || this.isPlayingAudio
1005
964
  }, disabled: !this.textAnswer.trim() || this.isSubmittingText || this.isLoading || !!this.currentStreamingMessage || this.waitingToRecord || this.isPlayingAudio, onClick: this.submitTextAnswer }, this.isSubmittingText ? '发送中...' : '发送'))));
@@ -1051,7 +1010,7 @@ export class ChatAPPModal {
1051
1010
  "reflect": false,
1052
1011
  "defaultValue": "'\u5728\u7EBF\u5BA2\u670D'"
1053
1012
  },
1054
- "apiKey": {
1013
+ "token": {
1055
1014
  "type": "string",
1056
1015
  "mutable": false,
1057
1016
  "complexType": {
@@ -1067,7 +1026,7 @@ export class ChatAPPModal {
1067
1026
  },
1068
1027
  "getter": false,
1069
1028
  "setter": false,
1070
- "attribute": "api-key",
1029
+ "attribute": "token",
1071
1030
  "reflect": false,
1072
1031
  "defaultValue": "''"
1073
1032
  },
@@ -1182,7 +1141,7 @@ export class ChatAPPModal {
1182
1141
  "optional": true,
1183
1142
  "docs": {
1184
1143
  "tags": [],
1185
- "text": "\u4F1A\u8BDDID"
1144
+ "text": "\u4F1A\u8BDDID\uFF0C\u4F20\u5165\u7EE7\u7EED\u5BF9\u8BDD\uFF0C\u5426\u5219\u521B\u5EFA\u65B0\u4F1A\u8BDD"
1186
1145
  },
1187
1146
  "getter": false,
1188
1147
  "setter": false,
@@ -1281,7 +1240,7 @@ export class ChatAPPModal {
1281
1240
  "optional": false,
1282
1241
  "docs": {
1283
1242
  "tags": [],
1284
- "text": "\u662F\u5426\u4EE5\u5168\u5C4F\u6A21\u5F0F\u6253\u5F00"
1243
+ "text": "\u662F\u5426\u4EE5\u5168\u5C4F\u6A21\u5F0F\u6253\u5F00\uFF0C\u79FB\u52A8\u7AEF\u5EFA\u8BAE\u8BBE\u7F6E\u4E3Atrue"
1285
1244
  },
1286
1245
  "getter": false,
1287
1246
  "setter": false,
@@ -1289,7 +1248,7 @@ export class ChatAPPModal {
1289
1248
  "reflect": false,
1290
1249
  "defaultValue": "false"
1291
1250
  },
1292
- "enableVoice": {
1251
+ "enableTTS": {
1293
1252
  "type": "boolean",
1294
1253
  "mutable": false,
1295
1254
  "complexType": {
@@ -1301,35 +1260,35 @@ export class ChatAPPModal {
1301
1260
  "optional": false,
1302
1261
  "docs": {
1303
1262
  "tags": [],
1304
- "text": "\u662F\u5426\u81EA\u52A8\u64AD\u653E\u8BED\u97F3\u95EE\u9898"
1263
+ "text": "\u662F\u5426\u542F\u7528\u8BED\u97F3\u64AD\u62A5\u529F\u80FD\r\ntrue: \u542F\u7528\u8BED\u97F3\u5408\u6210\r\nfalse: \u7981\u7528\u8BED\u97F3\u5408\u6210"
1305
1264
  },
1306
1265
  "getter": false,
1307
1266
  "setter": false,
1308
- "attribute": "enable-voice",
1267
+ "attribute": "enable-t-t-s",
1309
1268
  "reflect": false,
1310
- "defaultValue": "true"
1269
+ "defaultValue": "false"
1311
1270
  },
1312
- "displayContentStatus": {
1313
- "type": "string",
1271
+ "enableVoice": {
1272
+ "type": "boolean",
1314
1273
  "mutable": false,
1315
1274
  "complexType": {
1316
- "original": "string",
1317
- "resolved": "string",
1275
+ "original": "boolean",
1276
+ "resolved": "boolean",
1318
1277
  "references": {}
1319
1278
  },
1320
1279
  "required": false,
1321
1280
  "optional": false,
1322
1281
  "docs": {
1323
1282
  "tags": [],
1324
- "text": "\u662F\u5426\u663E\u793A\u9898\u5E72\u5185\u5BB9\r\n1: \u663E\u793A\u9898\u5E72\u5185\u5BB9\r\n0: \u4E0D\u663E\u793A\u9898\u5E72\u5185\u5BB9"
1283
+ "text": "\u662F\u5426\u81EA\u52A8\u64AD\u653E\u8BED\u97F3\u95EE\u9898"
1325
1284
  },
1326
1285
  "getter": false,
1327
1286
  "setter": false,
1328
- "attribute": "display-content-status",
1287
+ "attribute": "enable-voice",
1329
1288
  "reflect": false,
1330
- "defaultValue": "\"1\""
1289
+ "defaultValue": "false"
1331
1290
  },
1332
- "userId": {
1291
+ "displayContentStatus": {
1333
1292
  "type": "string",
1334
1293
  "mutable": false,
1335
1294
  "complexType": {
@@ -1341,13 +1300,13 @@ export class ChatAPPModal {
1341
1300
  "optional": false,
1342
1301
  "docs": {
1343
1302
  "tags": [],
1344
- "text": "\u7528\u6237ID"
1303
+ "text": "\u662F\u5426\u663E\u793A\u9898\u5E72\u5185\u5BB9\r\n1: \u663E\u793A\u9898\u5E72\u5185\u5BB9\r\n0: \u4E0D\u663E\u793A\u9898\u5E72\u5185\u5BB9"
1345
1304
  },
1346
1305
  "getter": false,
1347
1306
  "setter": false,
1348
- "attribute": "user-id",
1307
+ "attribute": "display-content-status",
1349
1308
  "reflect": false,
1350
- "defaultValue": "''"
1309
+ "defaultValue": "\"1\""
1351
1310
  },
1352
1311
  "interviewMode": {
1353
1312
  "type": "string",
@@ -1391,6 +1350,25 @@ export class ChatAPPModal {
1391
1350
  "getter": false,
1392
1351
  "setter": false,
1393
1352
  "defaultValue": "{}"
1353
+ },
1354
+ "botId": {
1355
+ "type": "string",
1356
+ "mutable": false,
1357
+ "complexType": {
1358
+ "original": "string",
1359
+ "resolved": "string",
1360
+ "references": {}
1361
+ },
1362
+ "required": false,
1363
+ "optional": true,
1364
+ "docs": {
1365
+ "tags": [],
1366
+ "text": "\u673A\u5668\u4EBAID"
1367
+ },
1368
+ "getter": false,
1369
+ "setter": false,
1370
+ "attribute": "bot-id",
1371
+ "reflect": false
1394
1372
  }
1395
1373
  };
1396
1374
  }