飞书渠道剥离思维链内容,不显示<think>标签
This commit is contained in:
parent
5d62141658
commit
ceb8234a30
@ -1620,6 +1620,15 @@ impl Default for MdPatterns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FeishuChannel {
|
impl FeishuChannel {
|
||||||
|
fn strip_thinking_tags(content: &str) -> String {
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
static THINK_RE: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
|
Regex::new(r"(?s)<think>.*?</think>").unwrap()
|
||||||
|
});
|
||||||
|
let stripped = THINK_RE.replace_all(content, "");
|
||||||
|
stripped.trim().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
/// Determine the optimal Feishu message format for content.
|
/// Determine the optimal Feishu message format for content.
|
||||||
fn detect_msg_format(content: &str) -> MsgFormat {
|
fn detect_msg_format(content: &str) -> MsgFormat {
|
||||||
let patterns = MdPatterns::new();
|
let patterns = MdPatterns::new();
|
||||||
@ -2075,6 +2084,10 @@ impl Channel for FeishuChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn send(&self, msg: OutboundMessage) -> Result<(), ChannelError> {
|
async fn send(&self, msg: OutboundMessage) -> Result<(), ChannelError> {
|
||||||
|
let msg = OutboundMessage {
|
||||||
|
content: Self::strip_thinking_tags(&msg.content),
|
||||||
|
..msg
|
||||||
|
};
|
||||||
let receive_id = if msg.chat_id.starts_with("oc_") { &msg.chat_id } else { &msg.reply_to.as_ref().unwrap_or(&msg.chat_id) };
|
let receive_id = if msg.chat_id.starts_with("oc_") { &msg.chat_id } else { &msg.reply_to.as_ref().unwrap_or(&msg.chat_id) };
|
||||||
let receive_id_type = if msg.chat_id.starts_with("oc_") { "chat_id" } else { "open_id" };
|
let receive_id_type = if msg.chat_id.starts_with("oc_") { "chat_id" } else { "open_id" };
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user