mirror of
https://github.com/xszyou/Fay.git
synced 2026-08-30 17:33:39 +08:00
feat: 聊天图片在GUI显示并推送到数字人接口
- fay_core: 提取消息中的 markdown 图片 URL,通过 Images 字段推送到 10002 数字人text/audio通道,并从语音朗读文本中剥离图片语法 - gui: 调整 markdown-body img 缩略样式;修正 convertImagePaths 正则,避免误匹配 HTTP URL 的路径部分 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+19
-1
@@ -1548,6 +1548,9 @@ class FeiFei:
|
||||
|
||||
|
||||
tts_text = self.__remove_prestart_tags(text) if text else text
|
||||
# 移除 markdown 图片语法,避免TTS朗读图片链接
|
||||
if tts_text:
|
||||
tts_text = re.sub(r'!\[.*?\]\(https?://[^\s\)]+\)', '', tts_text).strip()
|
||||
|
||||
|
||||
|
||||
@@ -2251,6 +2254,13 @@ class FeiFei:
|
||||
|
||||
content["Data"]["Sentiment"] = sentiment_value
|
||||
|
||||
# 提取文本中的 markdown 图片 URL 并附加到消息
|
||||
audio_image_urls = re.findall(r'!\[.*?\]\((https?://[^\s\)]+)\)', text or "")
|
||||
if audio_image_urls:
|
||||
content["Data"]["Images"] = audio_image_urls
|
||||
# 从 Text 中移除图片语法,避免语音朗读图片链接
|
||||
content["Data"]["Text"] = re.sub(r'!\[.*?\]\(https?://[^\s\)]+\)', '', text).strip()
|
||||
|
||||
# 计算 Action
|
||||
action_signal = resolve_action_signal(text)
|
||||
if action_signal:
|
||||
@@ -2888,6 +2898,9 @@ class FeiFei:
|
||||
"""
|
||||
|
||||
|
||||
# 从原始文本中提取 markdown 图片 URL(在清理前提取)
|
||||
image_urls = re.findall(r'!\[.*?\]\((https?://[^\s\)]+)\)', text or "")
|
||||
|
||||
# 移除 prestart 标签内容,不发送给数字人
|
||||
|
||||
|
||||
@@ -2897,7 +2910,9 @@ class FeiFei:
|
||||
full_text = self.__remove_emojis(cleaned_text.replace("*", "")) if cleaned_text else ""
|
||||
|
||||
|
||||
|
||||
# 从清理后的文本中移除 markdown 图片语法,避免数字人语音朗读图片链接
|
||||
if image_urls:
|
||||
full_text = re.sub(r'!\[.*?\]\(https?://[^\s\)]+\)', '', full_text).strip()
|
||||
|
||||
|
||||
# 如果文本为空且不是结束标记,则不发送,但需保留 is_first
|
||||
@@ -2955,6 +2970,9 @@ class FeiFei:
|
||||
|
||||
}
|
||||
|
||||
if image_urls:
|
||||
content['Data']['Images'] = image_urls
|
||||
|
||||
|
||||
wsa_server.get_instance().add_cmd(content)
|
||||
|
||||
|
||||
@@ -782,6 +782,15 @@ html {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.markdown-body img {
|
||||
max-width: 100%;
|
||||
max-height: 300px;
|
||||
border-radius: 6px;
|
||||
margin: 6px 0;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.markdown-body strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@@ -1096,7 +1096,7 @@ unadoptText(id) {
|
||||
// Windows: D:\path\to\image.png 或 D:/path/to/image.png
|
||||
// Unix: /path/to/image.png
|
||||
// 支持的图片格式: png, jpg, jpeg, gif, bmp, webp
|
||||
const imagePathRegex = /([A-Za-z]:[\\\/][^\s<>"']+\.(png|jpg|jpeg|gif|bmp|webp)|\/[^\s<>"']+\.(png|jpg|jpeg|gif|bmp|webp))/gi;
|
||||
const imagePathRegex = /([A-Za-z]:[\\\/][^\s<>"']+\.(png|jpg|jpeg|gif|bmp|webp))/gi;
|
||||
|
||||
const baseUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user