summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-01-20 07:59:34 +0800
committerGitHub <noreply@github.com>2025-01-20 07:59:34 +0800
commitb44fc628fe8b36e4d48ff4295f74ee4225166d1b (patch)
tree2dbd39016321a8846a13602461ccef2d425a0a92 /src/config
parent77d6c33d9e1438338a7a530c98f717a5f9f10e67 (diff)
downloadaichat-b44fc628fe8b36e4d48ff4295f74ee4225166d1b.tar.gz
refactor: several improvements (#1106)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/input.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/config/input.rs b/src/config/input.rs
index c21bc62..618bd33 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -88,7 +88,7 @@ impl Input {
}
}
}
- let (files, medias, data_urls) =
+ let (documents, medias, data_urls) =
load_documents(config, external_cmds, local_paths, remote_urls)
.await
.context("Failed to load files")?;
@@ -104,17 +104,22 @@ impl Input {
last_reply = Some(v.clone());
}
if let Some(v) = last_reply.clone() {
- texts.push(format!("\n{v}\n"));
+ texts.push(format!("\n{v}"));
}
}
- if last_reply.is_none() && files.is_empty() && medias.is_empty() {
+ if last_reply.is_none() && documents.is_empty() && medias.is_empty() {
bail!("No last reply found");
}
}
- for (kind, path, contents) in files {
- texts.push(format!(
- "\n============ {kind}: {path} ============\n{contents}"
- ));
+ let documents_len = documents.len();
+ for (kind, path, contents) in documents {
+ if documents_len == 1 {
+ texts.push(format!("\n{contents}"));
+ } else {
+ texts.push(format!(
+ "\n============ {kind}: {path} ============\n{contents}"
+ ));
+ }
}
let (role, with_session, with_agent) = resolve_role(&config.read(), role);
Ok(Self {