@@ -65,9 +65,26 @@ fn set_args(chat: &mut Agent, key: &str, value: &str) {
6565}
6666
6767fn invoke_tool ( toolset : & tools:: ToolSet , request : & str ) -> Result < String > {
68- let ( tool, args) = parse_tool_invoke_json ( request) ?;
69- let result = toolset. invoke ( & tool, & args) ?;
70- Ok ( result)
68+ if let Ok ( ( tool, args) ) = parse_tool_invoke_json ( request) {
69+ let result = toolset. invoke ( & tool, & args) ?;
70+ Ok ( result)
71+ } else if request. contains ( "[[[[DOCUMENT]]]]" ) {
72+ Ok ( r#"File has been documented. Please keep up the good work!
73+
74+ Or, if you think you have finished your task and want to stop,
75+ please just output a special token [[[[DONE]]]]."#
76+ . to_string ( ) )
77+ } else {
78+ Err ( anyhow:: anyhow!(
79+ r#"
80+ I cannot find correct tool name or arguments in the request.
81+ Please check the format of the request and try again.
82+
83+ If you think you have finished your task and want to stop,
84+ please just output a special token [[[[DONE]]]].
85+ "#
86+ ) )
87+ }
7188}
7289
7390fn run_pipeline ( agent : & mut Agent , toolset : & tools:: ToolSet ) {
@@ -173,13 +190,14 @@ fn main() {
173190 let mut chat_agent = Agent :: new_with_config_file ( Path :: new ( & config_file) ) . unwrap ( ) ;
174191 let prompt = format ! (
175192 r#"
176- I would like you to help read a codebase. There are some tools you can use.
177- You can call them by providing the tool name and the arguments in JSON.
193+ I would like you to help write documentation for all source files (including those in the sub-crates) in a codebase.
194+
195+ There are some tools you can use. You can call them by providing the tool name and the arguments in JSON.
178196Here are the tools:
179197{}
180198
181199Now tell me what you want to do and I will return you the output of the tool.
182- Please output the special heading and than follow the format (must be wrapped in triple backticks):
200+ Please output a special heading and than JSON requests following the format (must be wrapped in triple backticks):
183201
184202[[[[INVOKE]]]]
185203```json
@@ -190,11 +208,14 @@ Please output the special heading and than follow the format (must be wrapped in
190208 }}
191209}}
192210
193- If you feel that you have finished your task, please return the output in the following token:
194- [[[[DONE]]]]
211+ If you would like to document a file, please output a special heading and than the documentation in Rust standard format:
212+ [[[[DOCUMENT]]]]
213+ <file name here with path on a new line>
214+
215+ Some documentation here...
195216```
196217
197- Please note that you can only call one tool at a time.
218+ Please note that you can only call ** one** tool **once** at a time. Otherwise errors will be returned .
198219"# ,
199220 help
200221 ) ;
0 commit comments