Skip to content

Commit 3f04bfd

Browse files
prompt engineering
1 parent 478b057 commit 3f04bfd

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

src/main.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ Please check the format of the request and try again.
8282
8383
If you think you have finished your task and want to stop,
8484
please just output a special token [[[[DONE]]]].
85+
86+
Otherwise, please either continue to use the tool with [[[[INVOKE]]]] or
87+
write the documentation with [[[[DOCUMENT]]]] without outputting any [[[[DONE]]]].
8588
"#
8689
))
8790
}
@@ -92,7 +95,7 @@ fn run_pipeline(agent: &mut Agent, toolset: &tools::ToolSet) {
9295
println!("\n============= LLM RESPONSE =============");
9396
if let Ok(response) = agent.post() {
9497
if response.trim().ends_with("[[[[DONE]]]]") {
95-
println!("Done.");
98+
println!("\n\nDone.");
9699
break;
97100
}
98101
agent.add_message("assistant", &response);
@@ -207,15 +210,42 @@ Please output a special heading and than JSON requests following the format (mus
207210
"arg2": value2
208211
}}
209212
}}
213+
```
210214
211-
If you would like to document a file, please output a special heading and than the documentation in Rust standard format:
215+
Please note that you can only call **one** tool **once** at a time. Otherwise errors will be returned.
216+
217+
If you would like to document a file, please output a special [[[[DOCUMENT]]]] token and then the
218+
documentation in Rust standard format:
212219
[[[[DOCUMENT]]]]
213220
<file name here with path on a new line>
214221
215-
Some documentation here...
216-
```
222+
<<<<<<< SEARCH
223+
LINE 00001: mod xxx;
224+
LINE 00002: use yyyy;
225+
======= REPLACE
226+
/// Some description here
227+
/// Some description here
228+
mod xxx;
229+
use yyyy;
230+
>>>>>>> FINISH
217231
218-
Please note that you can only call **one** tool **once** at a time. Otherwise errors will be returned.
232+
<<<<<<< SEARCH
233+
LINE 00123: fn foo() {{
234+
======= REPLACE
235+
/// Some description here
236+
/// Some description here
237+
fn foo() {{
238+
...
239+
>>>>>>> FINISH
240+
241+
Note that you **MUST** output "<<<<<<< SEARCH" and "======= REPLACE" and ">>>>>>> FINISH" signs!!!
242+
And you **MUST** keep the SEARCH part **AS SMALL AS POSSIBLE**, but you cannot mistake the line numbers.
243+
244+
You may make a plan first, determine all the files to be processed.
245+
During each step, you should always be checking if you are on the right track.
246+
Do not leave any files unprocessed. Remember to check and update the plan carefully.
247+
248+
Keep track of the files you have processed and the ones you have not.
219249
"#,
220250
help
221251
);

src/tools/read.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ impl Read {
3333

3434
pub fn invoke(&mut self, args: ReadToolProtocol) -> Result<String> {
3535
let path = args.path;
36-
let contents = std::fs::read_to_string(&path)?;
36+
let contents = std::fs::read_to_string(&path)?
37+
.lines()
38+
.into_iter()
39+
.enumerate()
40+
.map(|(i, line)| {
41+
format!("LINE {:05}: {}", i + 1, line)
42+
})
43+
.collect::<Vec<_>>()
44+
.join("\n");
3745
Ok(contents)
3846
}
3947
}

src/tools/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct TreeToolProtocol {
2525

2626
#[tool_protocol(
2727
help = "The maximum depth to recurse into the directory.",
28-
default = 2,
28+
default = 4,
2929
example = 3
3030
)]
3131
depth: u32,

0 commit comments

Comments
 (0)