test: use function call style snippet for prompt builder unit test (#395)
* test: better tests for build_prefix() * chore * chore: resolve commentsenable-blog
parent
74073aa77a
commit
2472cf3b55
|
|
@ -361,31 +361,34 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build_prefix_readable() {
|
fn test_build_prefix_readable() {
|
||||||
let snippets = vec![
|
let snippets = vec![
|
||||||
"def snippet_1():\n print(\"This is snipptet 1\")\n".to_string(),
|
"res_1 = invoke_function_1(n)".to_string(),
|
||||||
"def snippet_2():\n print(\"This is snipptet 2\")\n".to_string(),
|
"res_2 = invoke_function_2(n)".to_string(),
|
||||||
"def snippet_3():\n print(\"This is snipptet 3\")\n".to_string(),
|
"res_3 = invoke_function_3(n)".to_string(),
|
||||||
"def snippet_4():\n print(\"This is snipptet 4\")\n".to_string(),
|
"res_4 = invoke_function_4(n)".to_string(),
|
||||||
"def snippet_5():\n print(\"This is snipptet 5\")\n".to_string(),
|
"res_5 = invoke_function_5(n)".to_string(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let prefix = "def this_is_prefix():\n";
|
let prefix = "\
|
||||||
|
'''
|
||||||
|
Use some invoke_function to do some job.
|
||||||
|
'''
|
||||||
|
def this_is_prefix():\n";
|
||||||
|
|
||||||
let expected_built_prefix = "\
|
let expected_built_prefix = "\
|
||||||
# Below are some relevant python snippets found in the repository:
|
# Below are some relevant python snippets found in the repository:
|
||||||
# == Snippet 1 ==
|
# == Snippet 1 ==
|
||||||
# def snippet_1():
|
# res_1 = invoke_function_1(n)
|
||||||
# print(\"This is snipptet 1\")
|
|
||||||
# == Snippet 2 ==
|
# == Snippet 2 ==
|
||||||
# def snippet_2():
|
# res_2 = invoke_function_2(n)
|
||||||
# print(\"This is snipptet 2\")
|
|
||||||
# == Snippet 3 ==
|
# == Snippet 3 ==
|
||||||
# def snippet_3():
|
# res_3 = invoke_function_3(n)
|
||||||
# print(\"This is snipptet 3\")
|
# == Snippet 4 ==
|
||||||
# == Snippet 4 ==\n# def snippet_4():
|
# res_4 = invoke_function_4(n)
|
||||||
# print(\"This is snipptet 4\")
|
|
||||||
# == Snippet 5 ==
|
# == Snippet 5 ==
|
||||||
# def snippet_5():
|
# res_5 = invoke_function_5(n)
|
||||||
# print(\"This is snipptet 5\")
|
'''
|
||||||
|
Use some invoke_function to do some job.
|
||||||
|
'''
|
||||||
def this_is_prefix():\n";
|
def this_is_prefix():\n";
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -399,7 +402,7 @@ def this_is_prefix():\n";
|
||||||
let snippets_expected = 4;
|
let snippets_expected = 4;
|
||||||
let snippet_payload = "a".repeat(MAX_SNIPPET_CHARS_IN_PROMPT / snippets_expected);
|
let snippet_payload = "a".repeat(MAX_SNIPPET_CHARS_IN_PROMPT / snippets_expected);
|
||||||
let mut snippets = vec![];
|
let mut snippets = vec![];
|
||||||
for _ in 0..snippets_expected {
|
for _ in 0..snippets_expected + 1 {
|
||||||
snippets.push(snippet_payload.clone());
|
snippets.push(snippet_payload.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue