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,6 +1,5 @@
1
- import { p as proxyCustomElement, H, c as createEvent, h } from './p-CgDy4pJp.js';
2
- import { s as sendSSERequest, a as sendHttpRequest } from './index.js';
3
- import { d as defineCustomElement$2 } from './p-D0s1Q-3O.js';
1
+ import { p as proxyCustomElement, H, c as createEvent, s as sendSSERequest, a as sendHttpRequest, u as uploadFileToBackend, A as API_DOMAIN, h } from './index.js';
2
+ import { d as defineCustomElement$2 } from './p-LkDC0SN2.js';
4
3
 
5
4
  const pcmVideoChatModalCss = ":host{display:block}.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;overflow-y:auto;padding:20px;z-index:1000}.fullscreen-overlay{padding:0}.modal-container{background:white;border-radius:8px;width:100%;max-width:800px;display:flex;flex-direction:column;position:relative;margin:auto}.modal-container.fullscreen{width:100vw;max-width:none;height:100%;border-radius:0;margin:0;display:flex;flex-direction:column;height:100vh;max-height:100vh}.modal-container.fullscreen>div:not(.modal-header):not(.initial-upload){display:flex;flex-direction:column;flex:1;overflow:hidden;height:100%}.pc-layout{width:80%;max-width:800px;min-width:320px;min-height:400px}.mobile-layout{width:100%;height:100%;border-radius:0}@media screen and (max-width: 768px){.pc-layout{width:95%;}.modal-overlay{padding:0}.modal-container.fullscreen{height:-webkit-fill-available;max-height:-webkit-fill-available;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}.modal-container.mobile-layout{width:100%;height:100vh;max-height:100vh;min-height:100vh;border-radius:0;margin:0;display:flex;flex-direction:column}}.video-preview.placeholder{display:flex;justify-content:center;align-items:center;background:#EAEAEA}.placeholder-status{color:#00000066}.waiting-message p{margin:0;font-size:16px;color:white;font-weight:500}.recording-container{width:100%;display:flex;flex-direction:column;align-items:center}.video-area{width:100%;display:flex;flex-direction:column;align-items:center}.stop-recording-button{width:100%;height:100%;font-size:16px;background:#f44336;border-radius:6px;color:white;border:none;cursor:pointer}.stop-recording-button:hover{background:#d32f2f}.play-audio-container{width:100%;height:100%;display:flex;justify-content:center;align-items:center}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:4px 16px;height:50px;border-bottom:1px solid #e8e8e8;flex-shrink:0;}.header-left{display:flex;align-items:center;gap:8px}.header-icon{width:24px;height:24px}.close-button{background:transparent;border:none;cursor:pointer;padding:8px;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:4px}.close-button:hover{background-color:rgba(0, 0, 0, 0.04)}.close-button span{font-size:24px;line-height:1;color:#999}.close-button:hover span{color:#666}.chat-history{position:relative;flex:1;overflow-y:auto;padding:20px;scroll-behavior:smooth;min-height:200px;background:url(https://pcm-resource-1312611446.cos.ap-guangzhou.myqcloud.com/web/sdk/chat_bg.png);background-size:100%}.fullscreen .chat-history{height:auto;flex:1 1 auto}.message-input{padding:16px;border-top:1px solid #eee;display:flex;gap:8px;align-items:center}.message-input input{flex:1;padding:8px 12px;border:1px solid #ddd;border-radius:4px;outline:none;transition:border-color 0.2s ease}.message-input input:focus{border-color:#bbb}.message{margin-bottom:16px;opacity:1;transition:opacity 0.3s ease}.message-content{max-width:70%;padding:8px 12px;border-radius:8px;word-break:break-word}.message-content p{margin:0;word-break:break-word}.user-message{display:flex;justify-content:flex-end}.agent-message{display:flex;justify-content:flex-start}.user-message .message-content{background-color:#007bff;color:white}.agent-message .message-content{background-color:#f1f1f1}.message-time{font-size:12px;color:#999;margin-top:4px;display:block}.send-button{background-color:#1890ff;color:white;border:none;border-radius:4px;padding:8px 16px;cursor:pointer;font-weight:500}.send-button:disabled{background-color:#ccc;cursor:not-allowed}.empty-state{display:flex;justify-content:center;align-items:center;height:100%;color:#999;text-align:center}.loading-container{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:rgba(255, 255, 255, 0.98);z-index:1;opacity:1;transition:opacity 0.3s ease}.loading-container p{margin-top:16px;color:#666;font-size:14px}.loading-spinner{width:40px;height:40px;border:3px solid #f3f3f3;border-top:3px solid #1890ff;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.messages-wrapper{width:100%;min-height:100%;display:flex;flex-direction:column;justify-content:flex-end}.messages-wrapper.has-overflow{justify-content:flex-start}.suggested-questions{display:flex;flex-direction:column;gap:8px;padding:16px}.suggested-question{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background-color:#f3f4f6;border-radius:4px;cursor:pointer;font-size:14px;color:#374151;transition:background-color 0.2s}.suggested-question:hover{background-color:#e5e7eb}.arrow-right{margin-left:8px}.loading-suggestions{display:flex;justify-content:center;padding:16px}.loading-spinner-small{width:20px;height:20px;border:2px solid #e5e7eb;border-top-color:#6b7280;border-radius:50%;animation:spin 1s linear infinite}.upload-button{background:transparent;border:none;cursor:pointer;padding:8px;display:flex;align-items:center;justify-content:center;color:#666;border-radius:4px;transition:background-color 0.2s}.upload-button:hover{background-color:rgba(0, 0, 0, 0.04)}.upload-button svg{width:20px;height:20px}.selected-file{font-size:12px;color:#666;margin-left:8px;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.input-wrapper{flex:1;display:flex;align-items:center;border:1px solid #ddd;border-radius:4px;padding:0 4px;background:white}.input-wrapper input{border:none;flex:1;padding:8px;outline:none}.input-wrapper:focus-within{border-color:#bbb}.file-preview{padding:8px 16px;border-top:1px solid #eee;background-color:#f9f9f9}.function-select{margin-top:2rem}.function-options{display:flex;flex-wrap:wrap;gap:1rem;justify-content:center;margin-top:1rem}.function-button{padding:0.5rem 1rem;border:1px solid #ddd;border-radius:4px;background:white;cursor:pointer;transition:all 0.3s ease}.function-button:hover{border-color:#1890ff;color:#1890ff}.function-button.selected{background:#1890ff;color:white;border-color:#1890ff}.recording-section{border-top:1px solid #eee;display:flex;flex-direction:column;align-items:center;padding:20px;border-radius:14px 14px 0 0;flex:0 0 auto}.recording-section .video-preview{width:100%;height:200px;max-width:400px;position:relative;margin-bottom:10px;border:1px solid #ddd;border-radius:12px;overflow:hidden}.recording-section video{width:100%;height:100%;object-fit:cover}.recording-status{position:absolute;top:10px;left:10px;background-color:rgba(0, 0, 0, 0.6);color:white;padding:4px 8px;border-radius:4px;display:flex;align-items:center;gap:5px;font-size:0.8rem;z-index:2}.recording-status .recording-dot{display:inline-block;width:10px;height:10px;background-color:red;border-radius:50%;margin-right:5px;animation:blink 1s infinite}.recording-status.warning{color:#ff4d4f;animation:blink 1s infinite}@keyframes blink{0%{opacity:1}50%{opacity:0.5}100%{opacity:1}}.recording-section .stop-recording-button{background-color:#f44336;color:white;border:none;cursor:pointer;font-weight:bold}.recording-section .stop-recording-button:hover{background-color:#d32f2f}.fullscreen{width:100vw;border-radius:0;height:100vh;display:flex;flex-direction:column;overflow-y:auto}.recording-controls{margin-top:10px;height:53px;width:100%;max-width:400px;display:flex;justify-content:center}.recording-controls .waiting-message{text-align:center;color:white;font-size:1rem;background-image:linear-gradient(100deg, #4A9FFF 0%, #1058FF 100%);border-radius:6px;box-shadow:0 2px 8px rgba(0, 0, 0, 0.15);width:95%;display:flex;justify-content:center;align-items:center;cursor:pointer}.recording-controls .waiting-message.loading{background:#faad14}.recording-controls .waiting-message p{margin:0;font-size:16px;color:white;font-weight:500}.recording-controls .stop-recording-button{background-color:#dc3545;color:white;border:none;cursor:pointer;font-size:1rem}.recording-controls .stop-recording-button:hover{background-color:#c82333}.recording-controls .stop-recording-button.disabled{background:#ccc;cursor:not-allowed}.recording-controls .stop-recording-button.disabled:hover{background:#ccc}.progress-container{display:flex;justify-content:space-between;align-items:center;width:100%;max-width:400px;margin-top:10px;padding:0 5px}.progress-bar-container{height:4px;background-color:#E5E5E5;border-radius:2px;overflow:hidden;margin-right:10px;width:75px}.progress-bar{height:100%;background-image:linear-gradient(111deg, #4A9FFF 0%, #1058FF 100%);border-radius:2px;transition:width 0.3s ease}.progress-text{font-size:14px;color:#666;white-space:nowrap}";
6
5
 
@@ -22,7 +21,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
22
21
  /**
23
22
  * API鉴权密钥
24
23
  */
25
- apiKey = '';
24
+ token = '';
26
25
  /**
27
26
  * 是否显示聊天模态框
28
27
  */
@@ -52,7 +51,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
52
51
  */
53
52
  isNeedClose = true;
54
53
  /**
55
- * 会话ID
54
+ * 会话ID,传入继续对话,否则创建新会话
56
55
  */
57
56
  conversationId;
58
57
  /**
@@ -74,7 +73,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
74
73
  // 添加新的 Event
75
74
  streamComplete;
76
75
  /**
77
- * 默认查询文本
76
+ * 首次对话提问文本
78
77
  */
79
78
  defaultQuery = '';
80
79
  // 添加新的状态
@@ -122,7 +121,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
122
121
  countdownWarningTime = 30;
123
122
  showCountdownWarning = false;
124
123
  /**
125
- * 是否以全屏模式打开
124
+ * 是否以全屏模式打开,移动端建议设置为true
126
125
  */
127
126
  fullscreen = false;
128
127
  // 添加新的状态来跟踪视频上传
@@ -203,6 +202,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
203
202
  response_mode: 'streaming',
204
203
  conversation_id: this.conversationId,
205
204
  query: queryText,
205
+ bot_id: "3022316191018903",
206
206
  inputs: {
207
207
  id: this.resumeId
208
208
  }
@@ -212,10 +212,10 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
212
212
  requestData.inputs.video_url = videoUrl;
213
213
  }
214
214
  await sendSSERequest({
215
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/chat-messages`,
215
+ url: `/sdk/v1/chat/chat-messages`,
216
216
  method: 'POST',
217
217
  headers: {
218
- 'authorization': 'Bearer ' + this.apiKey
218
+ 'authorization': 'Bearer ' + this.token
219
219
  },
220
220
  data: requestData,
221
221
  onMessage: (data) => {
@@ -339,57 +339,45 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
339
339
  this.isLoadingHistory = true;
340
340
  console.log('加载历史消息...');
341
341
  try {
342
- await sendHttpRequest({
343
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/messages`,
342
+ const result = await sendHttpRequest({
343
+ url: '/sdk/v1/chat/messages',
344
344
  method: 'GET',
345
345
  headers: {
346
- 'authorization': 'Bearer ' + this.apiKey
346
+ 'authorization': 'Bearer ' + this.token
347
347
  },
348
348
  data: {
349
349
  conversation_id: this.conversationId,
350
+ bot_id: "3022316191018903",
350
351
  limit: 20
351
- },
352
- onMessage: (data) => {
353
- if (data.data) {
354
- const historyData = data.data || [];
355
- const formattedMessages = historyData.map(msg => {
356
- const time = new Date(msg.created_at * 1000);
357
- const hours = time.getHours().toString().padStart(2, '0');
358
- const minutes = time.getMinutes().toString().padStart(2, '0');
359
- const timeStr = `${hours}:${minutes}`;
360
- // 创建新的消息对象,不包含 inputs 字段
361
- const { inputs, ...msgWithoutInputs } = msg;
362
- return {
363
- ...msgWithoutInputs,
364
- time: timeStr,
365
- isStreaming: false,
366
- status: msg.status === 'error' ? 'error' : 'normal'
367
- };
368
- });
369
- this.messages = formattedMessages;
370
- this.isLoadingHistory = false;
371
- requestAnimationFrame(() => {
372
- this.shouldAutoScroll = true;
373
- this.scrollToBottom();
374
- });
375
- }
376
- else {
377
- this.isLoadingHistory = false;
378
- }
379
- },
380
- onError: (error) => {
381
- console.error('加载历史消息失败:', error);
382
- alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
383
- this.isLoadingHistory = false;
384
- },
385
- onComplete: () => {
386
- this.isLoadingHistory = false;
387
352
  }
388
353
  });
354
+ if (result.success && result.data) {
355
+ const historyData = result.data.data;
356
+ const formattedMessages = historyData.map(msg => {
357
+ const time = new Date(msg.created_at * 1000);
358
+ const hours = time.getHours().toString().padStart(2, '0');
359
+ const minutes = time.getMinutes().toString().padStart(2, '0');
360
+ const timeStr = `${hours}:${minutes}`;
361
+ const { inputs, ...msgWithoutInputs } = msg;
362
+ return {
363
+ ...msgWithoutInputs,
364
+ time: timeStr,
365
+ isStreaming: false,
366
+ status: msg.status === 'error' ? 'error' : 'normal'
367
+ };
368
+ });
369
+ this.messages = formattedMessages;
370
+ requestAnimationFrame(() => {
371
+ this.shouldAutoScroll = true;
372
+ this.scrollToBottom();
373
+ });
374
+ }
389
375
  }
390
376
  catch (error) {
391
377
  console.error('加载历史消息失败:', error);
392
378
  alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
379
+ }
380
+ finally {
393
381
  this.isLoadingHistory = false;
394
382
  }
395
383
  }
@@ -660,32 +648,29 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
660
648
  this.videoRef = null;
661
649
  }
662
650
  }
663
- // 上传录制的视频
651
+ // 修改上传录制的视频方法
664
652
  async uploadRecordedVideo() {
665
653
  if (!this.recordedBlob)
666
654
  return;
667
655
  try {
668
- this.isUploadingVideo = true; // 开始上传时设置状态
669
- this.showRecordingUI = false; // 隐藏视频预览
656
+ this.isUploadingVideo = true;
657
+ this.showRecordingUI = false;
670
658
  // 根据Blob类型确定文件扩展名
671
659
  const fileExtension = this.recordedBlob.type.includes('webm') ? 'webm' : 'mp4';
672
660
  const fileName = `answer.${fileExtension}`;
673
- const formData = new FormData();
674
- formData.append('file', this.recordedBlob, fileName);
675
- const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/files/upload', {
676
- method: 'POST',
677
- headers: {
678
- 'authorization': 'Bearer ' + this.apiKey
679
- },
680
- body: formData
661
+ // 创建File对象
662
+ const file = new File([this.recordedBlob], fileName, { type: this.recordedBlob.type });
663
+ // 使用uploadFileToBackend上传文件
664
+ const uploadResult = await uploadFileToBackend(file, {
665
+ 'authorization': 'Bearer ' + this.token
681
666
  });
682
- const result = await response.json();
683
- console.log('视频上传结果:', result);
684
- if (result && result.cos_key) {
667
+ console.log('视频上传结果:', uploadResult);
668
+ // 使用 cos_key 作为视频标识符
669
+ if (uploadResult.cos_key) {
685
670
  // 调用音频转文字API
686
- const transcriptionText = await this.convertAudioToText(result.cos_key);
671
+ const transcriptionText = await this.convertAudioToText(uploadResult.cos_key);
687
672
  // 发送转换后的文本和视频URL到下一个请求
688
- await this.sendMessageToAPI(transcriptionText || "下一题", result.cos_key);
673
+ await this.sendMessageToAPI(transcriptionText || "下一题", uploadResult.cos_key);
689
674
  }
690
675
  else {
691
676
  throw new Error('视频上传失败');
@@ -700,43 +685,32 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
700
685
  });
701
686
  }
702
687
  finally {
703
- this.isUploadingVideo = false; // 上传完成后重置状态
688
+ this.isUploadingVideo = false;
704
689
  this.showRecordingUI = false;
705
690
  this.recordedBlob = null;
706
691
  }
707
692
  }
708
- // 修改音频转文字方法
693
+ // 修改音频转文字方法,使用 cos_key
709
694
  async convertAudioToText(cosKey) {
710
695
  try {
711
- // 创建一个Promise来处理响应
712
- return new Promise((resolve, reject) => {
713
- sendHttpRequest({
714
- url: `https://pcm_api.ylzhaopin.com/external/v1/tts/audio_to_text`,
715
- method: 'POST',
716
- headers: {
717
- 'Content-Type': 'application/json',
718
- 'authorization': 'Bearer ' + this.apiKey
719
- },
720
- data: {
721
- cos_key: cosKey
722
- },
723
- onMessage: (data) => {
724
- // 检查返回结果中是否包含转换后的文本
725
- if (data && data.text) {
726
- console.log('转换后的文本:', data.text);
727
- resolve(data.text);
728
- }
729
- else {
730
- console.warn('音频转文字返回结果格式不正确');
731
- resolve(null);
732
- }
733
- },
734
- onError: (error) => {
735
- console.error('音频转文字请求失败:', error);
736
- reject(error);
737
- }
738
- });
696
+ const result = await sendHttpRequest({
697
+ url: '/sdk/v1/tts/audio_to_text',
698
+ method: 'POST',
699
+ headers: {
700
+ 'authorization': 'Bearer ' + this.token
701
+ },
702
+ data: {
703
+ cos_key: cosKey
704
+ }
739
705
  });
706
+ if (result.success && result.data?.text) {
707
+ console.log('转换后的文本:', result.data.text);
708
+ return result.data.text;
709
+ }
710
+ else {
711
+ console.warn('音频转文字返回结果格式不正确');
712
+ return null;
713
+ }
740
714
  }
741
715
  catch (error) {
742
716
  console.error('音频转文字错误:', error);
@@ -753,6 +727,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
753
727
  response_mode: 'streaming',
754
728
  conversation_id: this.conversationId,
755
729
  query: queryText,
730
+ bot_id: "3022316191018903",
756
731
  inputs: {
757
732
  id: this.resumeId
758
733
  }
@@ -763,10 +738,10 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
763
738
  }
764
739
  // 不使用 await,直接发送请求
765
740
  sendSSERequest({
766
- url: `https://pcm_api.ylzhaopin.com/external/v1/chat/chat-messages`,
741
+ url: `/sdk/v1/chat/chat-messages`,
767
742
  method: 'POST',
768
743
  headers: {
769
- 'authorization': 'Bearer ' + this.apiKey
744
+ 'authorization': 'Bearer ' + this.token
770
745
  },
771
746
  data: requestData,
772
747
  }).catch(error => {
@@ -776,11 +751,11 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
776
751
  // 添加TTS合成音频的方法
777
752
  async synthesizeAudio(text) {
778
753
  try {
779
- const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/tts/synthesize_audio', {
754
+ const response = await fetch(`${API_DOMAIN}/sdk/v1/tts/synthesize_audio`, {
780
755
  method: 'POST',
781
756
  headers: {
782
757
  'Content-Type': 'application/json',
783
- 'authorization': 'Bearer ' + this.apiKey
758
+ 'authorization': 'Bearer ' + this.token
784
759
  },
785
760
  body: JSON.stringify({ text })
786
761
  });
@@ -922,7 +897,7 @@ const VideoChatModal = /*@__PURE__*/ proxyCustomElement(class VideoChatModal ext
922
897
  static get style() { return pcmVideoChatModalCss; }
923
898
  }, [1, "pcm-video-chat-modal", {
924
899
  "modalTitle": [1, "modal-title"],
925
- "apiKey": [1, "api-key"],
900
+ "token": [1],
926
901
  "isOpen": [1028, "is-open"],
927
902
  "icon": [1],
928
903
  "zIndex": [2, "z-index"],