summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-19 22:47:29 +0800
committerGitHub <noreply@github.com>2024-05-19 22:47:29 +0800
commit9b7d93ee84435ac5eeb765662a08eae9cb4140ef (patch)
tree151672b3a0b2e0f5b76f2a532ffe52953b027e5d /src
parent7f21854b9aea22af0c609d6abe4ae07e9c472e25 (diff)
downloadaichat-9b7d93ee84435ac5eeb765662a08eae9cb4140ef.tar.gz
refactor: export LLM_FUNCTION_DATA when calling functions (#524)
Diffstat (limited to 'src')
-rw-r--r--src/function.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/function.rs b/src/function.rs
index 8ffb785..708321f 100644
--- a/src/function.rs
+++ b/src/function.rs
@@ -230,12 +230,10 @@ impl ToolCall {
.join(" ")
);
- let envs = if let Some(env_path) = config.read().function.env_path.clone() {
- let mut envs = HashMap::new();
+ let mut envs = HashMap::new();
+ envs.insert("LLM_FUNCTION_DATA".into(), self.arguments.to_string());
+ if let Some(env_path) = config.read().function.env_path.clone() {
envs.insert("PATH".into(), env_path);
- Some(envs)
- } else {
- None
};
let output = if self.is_execute_type() {
let proceed = if stdout().is_terminal() {
@@ -247,14 +245,14 @@ impl ToolCall {
if proceed {
#[cfg(windows)]
let name = polyfill_cmd_name(&name, &config.read().function.bin_dir);
- run_command(&name, &arguments, envs)?;
+ run_command(&name, &arguments, Some(envs))?;
}
Value::Null
} else {
println!("{}", dimmed_text(&prompt_text));
#[cfg(windows)]
let name = polyfill_cmd_name(&name, &config.read().function.bin_dir);
- let (success, stdout, stderr) = run_command_with_output(&name, &arguments, envs)?;
+ let (success, stdout, stderr) = run_command_with_output(&name, &arguments, Some(envs))?;
if success {
if !stderr.is_empty() {