myagent-ai 1.16.3 → 1.16.4
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/package.json +1 -1
- package/web/api_server.py +10 -1
- package/web/ui/chat/chat.css +14 -2
- package/web/ui/chat/chat_container.html +1 -1
- package/web/ui/chat/chat_main.js +11 -10
package/package.json
CHANGED
package/web/api_server.py
CHANGED
|
@@ -1093,10 +1093,19 @@ class ApiServer:
|
|
|
1093
1093
|
|
|
1094
1094
|
# ── 尝试 faster-whisper ──
|
|
1095
1095
|
try:
|
|
1096
|
+
# [v1.16.3] 抑制 HuggingFace 未认证警告和 pydub ffmpeg 警告
|
|
1097
|
+
import warnings
|
|
1098
|
+
warnings.filterwarnings("ignore", message=".*HF_TOKEN.*", category=UserWarning)
|
|
1099
|
+
warnings.filterwarnings("ignore", message=".*huggingface_hub.*token.*", category=UserWarning)
|
|
1100
|
+
warnings.filterwarnings("ignore", message=".*ffmpeg or avconv.*", category=RuntimeWarning)
|
|
1101
|
+
# 抑制 HF Hub telemetry 和进度条
|
|
1102
|
+
os.environ.setdefault("HF_HUB_DISABLE_TELEMETRY", "1")
|
|
1103
|
+
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
|
1104
|
+
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
|
|
1105
|
+
|
|
1096
1106
|
from faster_whisper import WhisperModel
|
|
1097
1107
|
whisper_model = getattr(self, '_whisper_model', None)
|
|
1098
1108
|
if whisper_model is None:
|
|
1099
|
-
import os
|
|
1100
1109
|
model_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'models', 'whisper')
|
|
1101
1110
|
# 使用 tiny 模型(最轻量,~39MB),CPU int8 量化
|
|
1102
1111
|
self._whisper_model = WhisperModel("tiny", device="cpu", compute_type="int8",
|
package/web/ui/chat/chat.css
CHANGED
|
@@ -720,9 +720,21 @@ input,textarea,select{font:inherit}
|
|
|
720
720
|
line-height: 1.6;
|
|
721
721
|
white-space: pre-wrap;
|
|
722
722
|
word-break: break-word;
|
|
723
|
-
min-height:
|
|
723
|
+
min-height: 48px;
|
|
724
724
|
max-height: 120px;
|
|
725
|
-
|
|
725
|
+
width: 100%;
|
|
726
|
+
border: 1px solid var(--border);
|
|
727
|
+
border-radius: var(--radius-sm);
|
|
728
|
+
padding: 8px 10px;
|
|
729
|
+
background: var(--bg);
|
|
730
|
+
resize: none;
|
|
731
|
+
outline: none;
|
|
732
|
+
font-family: inherit;
|
|
733
|
+
box-sizing: border-box;
|
|
734
|
+
transition: border-color 0.15s;
|
|
735
|
+
}
|
|
736
|
+
.voice-preview-text:focus {
|
|
737
|
+
border-color: var(--accent);
|
|
726
738
|
}
|
|
727
739
|
.voice-preview-actions {
|
|
728
740
|
display: flex;
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
</div>
|
|
178
178
|
<div class="voice-preview" id="voicePreview" style="display:none">
|
|
179
179
|
<div class="voice-preview-label">语音输入 · <span id="voicePreviewHint">识别中...</span></div>
|
|
180
|
-
<
|
|
180
|
+
<textarea class="voice-preview-text" id="voicePreviewText" placeholder="识别结果..." rows="2"></textarea>
|
|
181
181
|
<div class="voice-preview-actions">
|
|
182
182
|
<button class="voice-preview-cancel" onclick="cancelVoicePreview()">取消</button>
|
|
183
183
|
<button class="voice-preview-send" id="voicePreviewSend" onclick="sendVoiceMessage()">发送</button>
|
package/web/ui/chat/chat_main.js
CHANGED
|
@@ -4590,7 +4590,7 @@ var VoiceInput = {
|
|
|
4590
4590
|
// 显示预览区域
|
|
4591
4591
|
if (voiceArea) voiceArea.style.display = 'none';
|
|
4592
4592
|
if (voicePreview) voicePreview.style.display = 'block';
|
|
4593
|
-
if (previewText) previewText.
|
|
4593
|
+
if (previewText) previewText.value = '识别中...';
|
|
4594
4594
|
if (previewHint) previewHint.textContent = '正在发送到本地STT引擎';
|
|
4595
4595
|
if (previewSend) previewSend.disabled = true;
|
|
4596
4596
|
|
|
@@ -4614,11 +4614,11 @@ var VoiceInput = {
|
|
|
4614
4614
|
if (data && data.text && data.text.trim()) {
|
|
4615
4615
|
this.rawText = data.text.trim();
|
|
4616
4616
|
this._sttEngine = data.engine || 'unknown';
|
|
4617
|
-
if (previewText) previewText.
|
|
4618
|
-
if (previewHint) previewHint.textContent = '已识别 (' + (this._sttEngine || 'local') + ')';
|
|
4617
|
+
if (previewText) previewText.value = this.rawText;
|
|
4618
|
+
if (previewHint) previewHint.textContent = '已识别 (' + (this._sttEngine || 'local') + '),可编辑后发送';
|
|
4619
4619
|
} else if (data && data.error) {
|
|
4620
4620
|
if (previewHint) previewHint.textContent = '识别失败';
|
|
4621
|
-
if (previewText) previewText.
|
|
4621
|
+
if (previewText) previewText.value = data.error;
|
|
4622
4622
|
console.warn('Voice STT error:', data.error);
|
|
4623
4623
|
// 如果没有STT引擎,给出提示
|
|
4624
4624
|
if (data.available === false) {
|
|
@@ -4629,12 +4629,12 @@ var VoiceInput = {
|
|
|
4629
4629
|
}
|
|
4630
4630
|
} else {
|
|
4631
4631
|
if (previewHint) previewHint.textContent = '未识别到文字';
|
|
4632
|
-
if (previewText) previewText.
|
|
4632
|
+
if (previewText) previewText.value = '未识别到文字,请重试';
|
|
4633
4633
|
}
|
|
4634
4634
|
} catch (e) {
|
|
4635
4635
|
console.error('Voice STT request error:', e);
|
|
4636
4636
|
if (previewHint) previewHint.textContent = '网络错误';
|
|
4637
|
-
if (previewText) previewText.
|
|
4637
|
+
if (previewText) previewText.value = 'STT请求失败,请重试';
|
|
4638
4638
|
}
|
|
4639
4639
|
|
|
4640
4640
|
this._cleanupStream();
|
|
@@ -4669,11 +4669,12 @@ var VoiceInput = {
|
|
|
4669
4669
|
this.audioChunks = [];
|
|
4670
4670
|
},
|
|
4671
4671
|
|
|
4672
|
-
/** Send the voice text as a message
|
|
4672
|
+
/** Send the voice text as a message(支持用户编辑识别结果后再发送) */
|
|
4673
4673
|
sendMessage: function() {
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
var text =
|
|
4674
|
+
// 从 textarea 读取编辑后的文本
|
|
4675
|
+
var previewText = document.getElementById('voicePreviewText');
|
|
4676
|
+
var text = previewText ? previewText.value.trim() : '';
|
|
4677
|
+
if (!text) return;
|
|
4677
4678
|
|
|
4678
4679
|
// 切回文本模式
|
|
4679
4680
|
this.switchMode('text');
|