diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-10 18:53:58 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 18:53:58 +0800 |
| commit | 4ea6f3933fff4974334e3f9ecb2a423aab43a787 (patch) | |
| tree | 37e27557072165ebd7a61b27e21b7e3e55d713dd /src/utils | |
| parent | 48219d2808bafc88fa4fa4d6997aa9dc92e6f686 (diff) | |
| download | aichat-4ea6f3933fff4974334e3f9ecb2a423aab43a787.tar.gz | |
feat: adjust the way of obtaining function call results (#695)
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/mod.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 40967ab..35f41a2 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -22,7 +22,7 @@ use anyhow::{Context, Result}; use fancy_regex::Regex; use is_terminal::IsTerminal; use lazy_static::lazy_static; -use std::{env, path::PathBuf}; +use std::{env, path::PathBuf, process}; lazy_static! { pub static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*)```").unwrap(); @@ -42,14 +42,6 @@ pub fn get_env_name(key: &str) -> String { ) } -pub fn get_env_bool(key: &str) -> bool { - if let Ok(value) = env::var(get_env_name(key)) { - value == "1" || value == "true" - } else { - false - } -} - pub fn tokenize(text: &str) -> Vec<&str> { if text.is_ascii() { text.split_inclusive(|c: char| c.is_ascii_whitespace()) @@ -158,8 +150,9 @@ pub fn dimmed_text(input: &str) -> String { pub fn temp_file(prefix: &str, suffix: &str) -> PathBuf { env::temp_dir().join(format!( - "{}{prefix}{}{suffix}", + "{}-{}{prefix}{}{suffix}", env!("CARGO_CRATE_NAME").to_lowercase(), + process::id(), uuid::Uuid::new_v4() )) } |
