@@ -163,7 +163,7 @@ impl OpenAIClient {
163163 let mut request = client. request ( method, url) ;
164164
165165 if let Some ( api_key) = & self . api_key {
166- request = request. header ( "Authorization" , format ! ( "Bearer {}" , api_key ) ) ;
166+ request = request. header ( "Authorization" , format ! ( "Bearer {api_key}" ) ) ;
167167 }
168168
169169 if let Some ( organization) = & self . organization {
@@ -244,7 +244,7 @@ impl OpenAIClient {
244244 Ok ( parsed)
245245 }
246246 Err ( e) => Err ( APIError :: CustomError {
247- message : format ! ( "Failed to parse JSON: {} / response {}" , e , text ) ,
247+ message : format ! ( "Failed to parse JSON: {e } / response {text}" ) ,
248248 } ) ,
249249 }
250250 } else {
@@ -253,7 +253,7 @@ impl OpenAIClient {
253253 . await
254254 . unwrap_or_else ( |_| "Unknown error" . to_string ( ) ) ;
255255 Err ( APIError :: CustomError {
256- message : format ! ( "{}: {}" , status , error_message ) ,
256+ message : format ! ( "{status }: {error_message}" ) ,
257257 } )
258258 }
259259 }
@@ -320,11 +320,11 @@ impl OpenAIClient {
320320 & mut self ,
321321 file_id : String ,
322322 ) -> Result < FileRetrieveResponse , APIError > {
323- self . get ( & format ! ( "files/{}" , file_id ) ) . await
323+ self . get ( & format ! ( "files/{file_id}" ) ) . await
324324 }
325325
326326 pub async fn retrieve_file_content ( & self , file_id : String ) -> Result < Bytes , APIError > {
327- self . get_raw ( & format ! ( "files/{}/content" , file_id ) ) . await
327+ self . get_raw ( & format ! ( "files/{file_id }/content" ) ) . await
328328 }
329329
330330 pub async fn chat_completion (
@@ -495,23 +495,22 @@ impl OpenAIClient {
495495 & mut self ,
496496 assistant_id : String ,
497497 ) -> Result < AssistantObject , APIError > {
498- self . get ( & format ! ( "assistants/{}" , assistant_id ) ) . await
498+ self . get ( & format ! ( "assistants/{assistant_id}" ) ) . await
499499 }
500500
501501 pub async fn modify_assistant (
502502 & mut self ,
503503 assistant_id : String ,
504504 req : AssistantRequest ,
505505 ) -> Result < AssistantObject , APIError > {
506- self . post ( & format ! ( "assistants/{}" , assistant_id) , & req)
507- . await
506+ self . post ( & format ! ( "assistants/{assistant_id}" ) , & req) . await
508507 }
509508
510509 pub async fn delete_assistant (
511510 & mut self ,
512511 assistant_id : String ,
513512 ) -> Result < common:: DeletionStatus , APIError > {
514- self . delete ( & format ! ( "assistants/{}" , assistant_id ) ) . await
513+ self . delete ( & format ! ( "assistants/{assistant_id}" ) ) . await
515514 }
516515
517516 pub async fn list_assistant (
@@ -530,7 +529,7 @@ impl OpenAIClient {
530529 assistant_id : String ,
531530 req : AssistantFileRequest ,
532531 ) -> Result < AssistantFileObject , APIError > {
533- self . post ( & format ! ( "assistants/{}/files" , assistant_id ) , & req)
532+ self . post ( & format ! ( "assistants/{assistant_id }/files" ) , & req)
534533 . await
535534 }
536535
@@ -539,7 +538,7 @@ impl OpenAIClient {
539538 assistant_id : String ,
540539 file_id : String ,
541540 ) -> Result < AssistantFileObject , APIError > {
542- self . get ( & format ! ( "assistants/{}/files/{}" , assistant_id , file_id ) )
541+ self . get ( & format ! ( "assistants/{assistant_id }/files/{file_id}" ) )
543542 . await
544543 }
545544
@@ -548,7 +547,7 @@ impl OpenAIClient {
548547 assistant_id : String ,
549548 file_id : String ,
550549 ) -> Result < common:: DeletionStatus , APIError > {
551- self . delete ( & format ! ( "assistants/{}/files/{}" , assistant_id , file_id ) )
550+ self . delete ( & format ! ( "assistants/{assistant_id }/files/{file_id}" ) )
552551 . await
553552 }
554553
@@ -565,7 +564,7 @@ impl OpenAIClient {
565564 order,
566565 after,
567566 before,
568- format ! ( "assistants/{}/files" , assistant_id ) ,
567+ format ! ( "assistants/{assistant_id }/files" ) ,
569568 ) ;
570569 self . get ( & url) . await
571570 }
@@ -578,30 +577,30 @@ impl OpenAIClient {
578577 }
579578
580579 pub async fn retrieve_thread ( & mut self , thread_id : String ) -> Result < ThreadObject , APIError > {
581- self . get ( & format ! ( "threads/{}" , thread_id ) ) . await
580+ self . get ( & format ! ( "threads/{thread_id}" ) ) . await
582581 }
583582
584583 pub async fn modify_thread (
585584 & mut self ,
586585 thread_id : String ,
587586 req : ModifyThreadRequest ,
588587 ) -> Result < ThreadObject , APIError > {
589- self . post ( & format ! ( "threads/{}" , thread_id ) , & req) . await
588+ self . post ( & format ! ( "threads/{thread_id}" ) , & req) . await
590589 }
591590
592591 pub async fn delete_thread (
593592 & mut self ,
594593 thread_id : String ,
595594 ) -> Result < common:: DeletionStatus , APIError > {
596- self . delete ( & format ! ( "threads/{}" , thread_id ) ) . await
595+ self . delete ( & format ! ( "threads/{thread_id}" ) ) . await
597596 }
598597
599598 pub async fn create_message (
600599 & mut self ,
601600 thread_id : String ,
602601 req : CreateMessageRequest ,
603602 ) -> Result < MessageObject , APIError > {
604- self . post ( & format ! ( "threads/{}/messages" , thread_id ) , & req)
603+ self . post ( & format ! ( "threads/{thread_id }/messages" ) , & req)
605604 . await
606605 }
607606
@@ -610,7 +609,7 @@ impl OpenAIClient {
610609 thread_id : String ,
611610 message_id : String ,
612611 ) -> Result < MessageObject , APIError > {
613- self . get ( & format ! ( "threads/{}/messages/{}" , thread_id , message_id ) )
612+ self . get ( & format ! ( "threads/{thread_id }/messages/{message_id}" ) )
614613 . await
615614 }
616615
@@ -620,15 +619,12 @@ impl OpenAIClient {
620619 message_id : String ,
621620 req : ModifyMessageRequest ,
622621 ) -> Result < MessageObject , APIError > {
623- self . post (
624- & format ! ( "threads/{}/messages/{}" , thread_id, message_id) ,
625- & req,
626- )
627- . await
622+ self . post ( & format ! ( "threads/{thread_id}/messages/{message_id}" ) , & req)
623+ . await
628624 }
629625
630626 pub async fn list_messages ( & mut self , thread_id : String ) -> Result < ListMessage , APIError > {
631- self . get ( & format ! ( "threads/{}/messages" , thread_id ) ) . await
627+ self . get ( & format ! ( "threads/{thread_id }/messages" ) ) . await
632628 }
633629
634630 pub async fn retrieve_message_file (
@@ -638,8 +634,7 @@ impl OpenAIClient {
638634 file_id : String ,
639635 ) -> Result < MessageFileObject , APIError > {
640636 self . get ( & format ! (
641- "threads/{}/messages/{}/files/{}" ,
642- thread_id, message_id, file_id
637+ "threads/{thread_id}/messages/{message_id}/files/{file_id}"
643638 ) )
644639 . await
645640 }
@@ -658,7 +653,7 @@ impl OpenAIClient {
658653 order,
659654 after,
660655 before,
661- format ! ( "threads/{}/messages/{}/files" , thread_id , message_id ) ,
656+ format ! ( "threads/{thread_id }/messages/{message_id }/files" ) ,
662657 ) ;
663658 self . get ( & url) . await
664659 }
@@ -668,16 +663,15 @@ impl OpenAIClient {
668663 thread_id : String ,
669664 req : CreateRunRequest ,
670665 ) -> Result < RunObject , APIError > {
671- self . post ( & format ! ( "threads/{}/runs" , thread_id) , & req)
672- . await
666+ self . post ( & format ! ( "threads/{thread_id}/runs" ) , & req) . await
673667 }
674668
675669 pub async fn retrieve_run (
676670 & mut self ,
677671 thread_id : String ,
678672 run_id : String ,
679673 ) -> Result < RunObject , APIError > {
680- self . get ( & format ! ( "threads/{}/runs/{}" , thread_id , run_id ) )
674+ self . get ( & format ! ( "threads/{thread_id }/runs/{run_id}" ) )
681675 . await
682676 }
683677
@@ -687,7 +681,7 @@ impl OpenAIClient {
687681 run_id : String ,
688682 req : ModifyRunRequest ,
689683 ) -> Result < RunObject , APIError > {
690- self . post ( & format ! ( "threads/{}/runs/{}" , thread_id , run_id ) , & req)
684+ self . post ( & format ! ( "threads/{thread_id }/runs/{run_id}" ) , & req)
691685 . await
692686 }
693687
@@ -704,7 +698,7 @@ impl OpenAIClient {
704698 order,
705699 after,
706700 before,
707- format ! ( "threads/{}/runs" , thread_id ) ,
701+ format ! ( "threads/{thread_id }/runs" ) ,
708702 ) ;
709703 self . get ( & url) . await
710704 }
@@ -715,7 +709,7 @@ impl OpenAIClient {
715709 run_id : String ,
716710 ) -> Result < RunObject , APIError > {
717711 self . post (
718- & format ! ( "threads/{}/runs/{}/cancel" , thread_id , run_id ) ,
712+ & format ! ( "threads/{thread_id }/runs/{run_id }/cancel" ) ,
719713 & ModifyRunRequest :: default ( ) ,
720714 )
721715 . await
@@ -735,8 +729,7 @@ impl OpenAIClient {
735729 step_id : String ,
736730 ) -> Result < RunStepObject , APIError > {
737731 self . get ( & format ! (
738- "threads/{}/runs/{}/steps/{}" ,
739- thread_id, run_id, step_id
732+ "threads/{thread_id}/runs/{run_id}/steps/{step_id}"
740733 ) )
741734 . await
742735 }
@@ -755,7 +748,7 @@ impl OpenAIClient {
755748 order,
756749 after,
757750 before,
758- format ! ( "threads/{}/runs/{}/steps" , thread_id , run_id ) ,
751+ format ! ( "threads/{thread_id }/runs/{run_id }/steps" ) ,
759752 ) ;
760753 self . get ( & url) . await
761754 }
@@ -768,12 +761,12 @@ impl OpenAIClient {
768761 }
769762
770763 pub async fn retrieve_batch ( & mut self , batch_id : String ) -> Result < BatchResponse , APIError > {
771- self . get ( & format ! ( "batches/{}" , batch_id ) ) . await
764+ self . get ( & format ! ( "batches/{batch_id}" ) ) . await
772765 }
773766
774767 pub async fn cancel_batch ( & mut self , batch_id : String ) -> Result < BatchResponse , APIError > {
775768 self . post (
776- & format ! ( "batches/{}/cancel" , batch_id ) ,
769+ & format ! ( "batches/{batch_id }/cancel" ) ,
777770 & common:: EmptyRequestBody { } ,
778771 )
779772 . await
@@ -793,14 +786,14 @@ impl OpenAIClient {
793786 }
794787
795788 pub async fn retrieve_model ( & mut self , model_id : String ) -> Result < ModelResponse , APIError > {
796- self . get ( & format ! ( "models/{}" , model_id ) ) . await
789+ self . get ( & format ! ( "models/{model_id}" ) ) . await
797790 }
798791
799792 pub async fn delete_model (
800793 & mut self ,
801794 model_id : String ,
802795 ) -> Result < common:: DeletionStatus , APIError > {
803- self . delete ( & format ! ( "models/{}" , model_id ) ) . await
796+ self . delete ( & format ! ( "models/{model_id}" ) ) . await
804797 }
805798
806799 fn build_url_with_preserved_query ( & self , path : & str ) -> Result < String , url:: ParseError > {
@@ -829,16 +822,16 @@ impl OpenAIClient {
829822 ) -> String {
830823 let mut params = vec ! [ ] ;
831824 if let Some ( limit) = limit {
832- params. push ( format ! ( "limit={}" , limit ) ) ;
825+ params. push ( format ! ( "limit={limit}" ) ) ;
833826 }
834827 if let Some ( order) = order {
835- params. push ( format ! ( "order={}" , order ) ) ;
828+ params. push ( format ! ( "order={order}" ) ) ;
836829 }
837830 if let Some ( after) = after {
838- params. push ( format ! ( "after={}" , after ) ) ;
831+ params. push ( format ! ( "after={after}" ) ) ;
839832 }
840833 if let Some ( before) = before {
841- params. push ( format ! ( "before={}" , before ) ) ;
834+ params. push ( format ! ( "before={before}" ) ) ;
842835 }
843836 if !params. is_empty ( ) {
844837 url = format ! ( "{}?{}" , url, params. join( "&" ) ) ;
@@ -866,7 +859,7 @@ impl OpenAIClient {
866859 map. get ( file_field)
867860 . and_then ( |v| v. as_str ( ) )
868861 . ok_or ( APIError :: CustomError {
869- message : format ! ( "Field '{}' not found or not a string" , file_field ) ,
862+ message : format ! ( "Field '{file_field }' not found or not a string" ) ,
870863 } ) ?
871864 } else {
872865 return Err ( APIError :: CustomError {
0 commit comments