@@ -140,34 +140,34 @@ impl<'a, M: CompletionModel> PromptBuilder<'a, M> {
140140 }
141141
142142 /// Execute the tool calls if the LLM responds with a Tool call request, `true` by default
143- pub fn execute_tools ( mut self , execute : bool ) -> Self {
143+ # [ must_use ] pub fn execute_tools ( mut self , execute : bool ) -> Self {
144144 self . execute_tools = execute;
145145 self
146146 }
147147
148148 /// Wether to send any tool definitions with the prompt, `true` by default
149- pub fn with_tools ( mut self , no_tools : bool ) -> Self {
149+ # [ must_use ] pub fn with_tools ( mut self , no_tools : bool ) -> Self {
150150 self . with_tools = no_tools;
151151 self
152152 }
153153
154154 /// Create a `Message::User` with the tool reponses and append it to the client history, `false` by default
155- pub fn append_tool_response ( mut self , append : bool ) -> Self {
155+ # [ must_use ] pub fn append_tool_response ( mut self , append : bool ) -> Self {
156156 self . append_tool_response = append;
157157 self
158158 }
159159
160160 /// Wether to retrieve and append the context to the prompt, true by default.
161161 /// If true, the client's vector store will get looked up for the top matches to the prompt and
162162 /// the context will get appended to the prompt before being sent.
163- pub fn with_context ( mut self , append_context : bool ) -> Self {
163+ # [ must_use ] pub fn with_context ( mut self , append_context : bool ) -> Self {
164164 self . with_context = append_context;
165165 self
166166 }
167167
168168 /// Prompt the LLM with a custom history, and get a response.
169169 /// Response won't be stored in the client's history
170- pub fn one_shot ( mut self , one_shot : bool , history : Option < MessageHistory > ) -> Self {
170+ # [ must_use ] pub fn one_shot ( mut self , one_shot : bool , history : Option < MessageHistory > ) -> Self {
171171 self . one_shot = ( one_shot, history) ;
172172 self
173173 }
@@ -254,14 +254,14 @@ impl<'a, M: CompletionModel> PromptBuilder<'a, M> {
254254 } = response. clone ( )
255255 {
256256 if self . one_shot . 0 {
257- self . client . history . push ( response)
257+ self . client . history . push ( response) ;
258258 }
259259 let values = self . client . run_tools ( Some ( & calls) ) . await ?;
260260 if self . one_shot . 0 {
261261 self . client . history . pop ( ) ;
262262 }
263263 response = Message :: User {
264- content : "" . to_owned ( ) ,
264+ content : String :: new ( ) ,
265265 tool_responses : Some ( values. clone ( ) ) ,
266266 } ;
267267 if self . append_tool_response && !self . one_shot . 0 {
@@ -304,7 +304,7 @@ impl<M: CompletionModel + Send> Client<M> {
304304 self . history = history;
305305 }
306306
307- pub fn export_history ( & self ) -> & MessageHistory {
307+ # [ must_use ] pub fn export_history ( & self ) -> & MessageHistory {
308308 & self . history
309309 }
310310
@@ -408,7 +408,7 @@ impl<M: CompletionModel + Send> Client<M> {
408408 } ;
409409
410410 let message_with_context = Message :: User {
411- content : format ! ( "{}{}" , prompt , context ) ,
411+ content : format ! ( "{prompt}{context}" ) ,
412412 tool_responses : None ,
413413 } ;
414414
@@ -431,7 +431,7 @@ impl<M: CompletionModel + Send> Client<M> {
431431 return Ok ( None ) ;
432432 }
433433 let mut context = String :: new ( ) ;
434- for embedder in self . embedders . iter ( ) {
434+ for embedder in & self . embedders {
435435 let query_results = embedder. query ( prompt, DEFAULT_TOP_N ) . await ?;
436436 if query_results. is_empty ( ) {
437437 return Ok ( None ) ;
@@ -476,11 +476,11 @@ fn process_json_value(value: &mut serde_json::Value) {
476476 match value {
477477 serde_json:: Value :: Object ( obj) => {
478478 let fields_to_remove = [ "$schema" , "format" , "title" , "minimum" ] ;
479- fields_to_remove . iter ( ) . for_each ( | & f| {
479+ for & f in & fields_to_remove {
480480 if obj. get ( f) . map_or ( false , |v| v. is_string ( ) || v. is_number ( ) ) {
481481 obj. remove ( f) ;
482482 }
483- } ) ;
483+ }
484484 if let Some ( v) = obj. get ( "oneOf" ) . cloned ( ) {
485485 obj. remove ( "oneOf" ) ;
486486 obj. insert ( "anyOf" . to_string ( ) , v) ;
@@ -521,7 +521,7 @@ where
521521 S : Serializer ,
522522{
523523 let combined_content = match tool_calls {
524- Some ( calls) => & format ! ( "{} {:?}" , content , calls ) ,
524+ Some ( calls) => & format ! ( "{content } {calls :?}" ) ,
525525 None => content,
526526 } ;
527527 serializer. serialize_newtype_struct ( "assistant" , & combined_content)
0 commit comments