Return an error from project index tool when embedding query fails (#11264)

Previously, a failure to embed the search query (due to a rate limit
error) would appear the same as if there were no results.

* Avoid repeatedly embedding the search query for each worktree
* Unify tasks for searching all worktree

Release Notes:

- N/A
This commit is contained in:
Max Brunsfeld 2024-05-01 12:15:44 -07:00 committed by GitHub
parent 4b767697af
commit 5831d80f51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 137 additions and 132 deletions

View file

@ -140,10 +140,9 @@ impl LanguageModelTool for ProjectIndexTool {
fn execute(&self, query: &Self::Input, cx: &mut WindowContext) -> Task<Result<Self::Output>> {
let project_index = self.project_index.read(cx);
let status = project_index.status();
let results = project_index.search(
query.query.as_str(),
query.query.clone(),
query.limit.unwrap_or(DEFAULT_SEARCH_LIMIT),
cx,
);
@ -151,7 +150,7 @@ impl LanguageModelTool for ProjectIndexTool {
let fs = self.fs.clone();
cx.spawn(|cx| async move {
let results = results.await;
let results = results.await?;
let excerpts = results.into_iter().map(|result| {
let abs_path = result