summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-03-03 09:57:50 +0800
committerGitHub <noreply@github.com>2024-03-03 09:57:50 +0800
commit8421f23b450643ca3c66cb3f6fd21ef862a2369d (patch)
treed64addd1104a01f3d60193f9912b4d0a3508edf3 /src/utils
parentb2f86f2899b79b291eb56435f99402509105b7ec (diff)
downloadaichat-8421f23b450643ca3c66cb3f6fd21ef862a2369d.tar.gz
feat: allow overriding execute/code role (#331)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index da98cc6..15af4ca 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -17,7 +17,7 @@ use std::env;
use std::process::Command;
lazy_static! {
- static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*?)```").unwrap();
+ pub static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*)```").unwrap();
}
pub fn now() -> String {
@@ -165,7 +165,11 @@ pub fn extract_block(input: &str) -> String {
.map(|m| String::from(m.as_str()))
})
.collect();
- output.trim().to_string()
+ if output.is_empty() {
+ input.trim().to_string()
+ } else {
+ output.trim().to_string()
+ }
}
#[cfg(test)]