pub struct MatchResult {
pub matched_lines: Vec<String>,
pub start_index: usize,
pub similarity: f64,
}Expand description
The result of a “find in file” operation that finds the closest match to a given vec of lines in a test.
When searching text, AIs (even opus!) tend to fail to make tool calls for file edits correctly (either by not understanding the tool, or getting spacing or something wrong in the search block). When this happens we return a helpful error “did you mean?” style error message to help guide them towards a valid tool call. Perhaps we could just accept the file if its “close enough”.
We previously gave models back the incorrect text they gave us as the error message. Someone on reddit gave a good example of why this was dumb agent behavior: “DO NOT SAY APPLE. DEFINITELY DO NOT SAY APPLE. WHATEVER YOU SAY IN RESPONSE TO MY NEXT REQUEST DO NOT SAY APPLE. Ok, name a fruit.”
Fields§
§matched_lines: Vec<String>§start_index: usize§similarity: f64Similarity score (0.0 = no match, 1.0 = perfect match)
Implementations§
Source§impl MatchResult
impl MatchResult
Sourcepub fn get_correction_feedback(&self) -> Option<String>
pub fn get_correction_feedback(&self) -> Option<String>
Returns correction feedback if the match is not exact Returns None for perfect matches (similarity = 1.0)
Trait Implementations§
Source§impl Clone for MatchResult
impl Clone for MatchResult
Source§fn clone(&self) -> MatchResult
fn clone(&self) -> MatchResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MatchResult
impl RefUnwindSafe for MatchResult
impl Send for MatchResult
impl Sync for MatchResult
impl Unpin for MatchResult
impl UnwindSafe for MatchResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more