Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 966d70c

Browse files
authored
Only show relevant paths when answering with respect to a specific file (#537)
* if only answering with respect to one file, only include that file's path in the prompt * address clippy warning
1 parent bac30ab commit 966d70c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

server/bleep/src/webserver/answer.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(super) async fn _handle(
137137
match item {
138138
Ok(Either::Left(exchange)) => yield exchange,
139139
Ok(Either::Right(n)) => next = n?,
140-
Err(e) => Err(anyhow!("reached timeout of {TIMEOUT_SECS}s"))?,
140+
Err(_) => Err(anyhow!("reached timeout of {TIMEOUT_SECS}s"))?,
141141
}
142142
}
143143

@@ -688,14 +688,6 @@ impl Conversation {
688688

689689
let mut s = "".to_owned();
690690

691-
if !self.paths.is_empty() {
692-
s += "##### PATHS #####\npath alias, path\n";
693-
694-
for (alias, path) in self.paths.iter().enumerate() {
695-
s += &format!("{alias}, {}\n", &path);
696-
}
697-
}
698-
699691
let mut path_aliases = aliases
700692
.into_iter()
701693
.filter(|alias| *alias < self.paths.len())
@@ -704,6 +696,22 @@ impl Conversation {
704696
path_aliases.sort();
705697
path_aliases.dedup();
706698

699+
if !self.paths.is_empty() {
700+
s += "##### PATHS #####\npath alias, path\n";
701+
702+
if path_aliases.len() == 1 {
703+
// Only show matching path
704+
let alias = path_aliases[0];
705+
let path = self.paths[alias].clone();
706+
s += &format!("{alias}, {}\n", &path);
707+
} else {
708+
// Show all paths that have been seen
709+
for (alias, path) in self.paths.iter().enumerate() {
710+
s += &format!("{alias}, {}\n", &path);
711+
}
712+
}
713+
}
714+
707715
if !self.code_chunks.is_empty() {
708716
s += "\n##### CODE CHUNKS #####\n\n";
709717
}

0 commit comments

Comments
 (0)