Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabby): remove redundant empty string tokens participating in rag search from token lists #1327

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/tabby/src/services/completion/completion_prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,37 @@ def this_is_prefix():\n";
expected_built_prefix
);
}

/// Empty strings tokens are not participating rag search and therefore could be removed.
#[test]
fn test_tokenized_text_filter() {
let prefix = r#"public static String getFileExtension(String fullName) {
String fileName = (new File(fullName)).getName();
int dotIndex = fileName.lastIndexOf('.');
}"#;

// with filter
assert_eq!(
tokenize_text(prefix),
[
"public", "static", "String", "getFileExtension", "String", "fullName", "String",
"fileName", "new", "File", "fullName", "getName", "int", "dotIndex", "fileName",
"lastIndexOf",
]
);

let tokenized_vec: Vec<String> = TOKENIZER.split(prefix).map(|x| x.to_owned()).collect();

// without filter
assert_eq!(
tokenized_vec,
[
"public", "static", "String", "getFileExtension", "String", "fullName", "", "",
"", "", "", "", "", "", "", "", "", "String", "fileName", "", "", "", "new", "File",
"fullName", "", "", "getName", "", "", "", "", "", "", "", "", "", "", "", "int",
"dotIndex", "", "", "fileName", "lastIndexOf", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", ""
]
);
}
wsxiaoys marked this conversation as resolved.
Show resolved Hide resolved
}